@@ -7,7 +7,6 @@ import { AiScriptError, NonAiScriptError, AiScriptNamespaceError, AiScriptIndexO
77import * as Ast from '../node.js' ;
88import { nodeToJs } from '../utils/node-to-js.js' ;
99import { Scope } from './scope.js' ;
10- import { std } from './lib/std.js' ;
1110import { RETURN , unWrapRet , BREAK , CONTINUE , assertValue , isControl , type Control , unWrapLabeledBreak } from './control.js' ;
1211import { assertNumber , assertString , assertFunction , assertBoolean , assertObject , assertArray , eq , isObject , isArray , expectAny , reprValue , isFunction } from './util.js' ;
1312import { NULL , FN_NATIVE , BOOL , NUM , STR , ARR , OBJ , FN , ERROR } from './value.js' ;
@@ -36,12 +35,11 @@ export class Interpreter {
3635 private abortHandlers : ( ( ) => void ) [ ] = [ ] ;
3736 private pauseHandlers : ( ( ) => void ) [ ] = [ ] ;
3837 private unpauseHandlers : ( ( ) => void ) [ ] = [ ] ;
39- private vars : Record < string , Variable > = { } ;
4038 private irqRate : number ;
4139 private irqSleep : ( ) => Promise < void > ;
4240
4341 constructor (
44- consts : Record < string , Value > ,
42+ globals : Record < string , Value > ,
4543 private opts : {
4644 in ?( q : string ) : Promise < string > ;
4745 out ?( value : Value ) : void ;
@@ -67,13 +65,12 @@ export class Interpreter {
6765 } ) ,
6866 } ;
6967
70- this . vars = Object . fromEntries ( Object . entries ( {
71- ...consts ,
72- ...std ,
73- ...io ,
74- } ) . map ( ( [ k , v ] ) => [ k , Variable . const ( v ) ] ) ) ;
75-
76- this . scope = new Scope ( [ new Map ( Object . entries ( this . vars ) ) ] ) ;
68+ this . scope = new Scope ( [
69+ new Map (
70+ Object . entries ( { ...globals , ...io } )
71+ . map ( ( [ k , v ] ) => [ k , Variable . const ( v ) ] ) ,
72+ ) ,
73+ ] ) ;
7774 this . scope . opts . log = ( type , params ) : void => {
7875 switch ( type ) {
7976 case 'add' : this . log ( 'var:add' , params ) ; break ;
0 commit comments