1- import type { TData , TDataName } from '../../@types/data' ;
2- import type { IVariable , TPCOverride } from '../../@types/execution' ;
3-
41import { addGlobalSymbol , getGlobalSymbol } from '../scope' ;
52import { setPCOverride , clearPCOverride , setExecutionItem , getNextElement } from '../parser' ;
63
@@ -11,7 +8,11 @@ import {
118} from '../../syntax/elements/elementArgument' ;
129import { ElementStatement , ElementBlock } from '../../syntax/elements/elementInstruction' ;
1310
14- // -- private functions ----------------------------------------------------------------------------
11+ // -- types ----------------------------------------------------------------------------------------
12+
13+ import type { TData , TDataName } from '../../@types/data' ;
14+ import type { IVariable , TPCOverride } from '../../@types/execution' ;
15+ import type { IContext , ISymbolTable } from '../../@types/scope' ;
1516
1617// -- public functions -----------------------------------------------------------------------------
1718
@@ -63,13 +64,28 @@ export function releaseProgramCounter(): void {
6364 * Runs a process, routine, or crumb stack from start to end.
6465 * @param nodeID syntax tree node ID of the starting node
6566 */
66- export function run ( nodeID : string ) : void {
67+ export function run (
68+ nodeID : string ,
69+ scope : {
70+ context : IContext < Record < string , unknown > > ;
71+ symbolTable : ISymbolTable ;
72+ }
73+ ) : void {
6774 abstract class ElementDataCover extends ElementData < TData > {
68- abstract evaluate ( ) : void ;
75+ abstract evaluate ( scope : {
76+ context : IContext < Record < string , unknown > > ;
77+ symbolTable : ISymbolTable ;
78+ } ) : void ;
6979 }
7080
7181 abstract class ElementExpressionCover extends ElementExpression < TData > {
72- abstract evaluate ( params : { [ key : string ] : TData } ) : void ;
82+ abstract evaluate (
83+ scope : {
84+ context : IContext < Record < string , unknown > > ;
85+ symbolTable : ISymbolTable ;
86+ } ,
87+ params : { [ key : string ] : TData }
88+ ) : void ;
7389 }
7490
7591 setExecutionItem ( nodeID ) ;
@@ -86,9 +102,9 @@ export function run(nodeID: string): void {
86102 const { instance, type, marker } = element ;
87103 if ( type === 'Argument' ) {
88104 if ( instance instanceof ElementDataCover ) {
89- instance . evaluate ( ) ;
105+ instance . evaluate ( scope ) ;
90106 } /* instance instanceof ElementExpressionCover */ else {
91- ( instance as ElementExpressionCover ) . evaluate ( memo ) ;
107+ ( instance as ElementExpressionCover ) . evaluate ( scope , memo ) ;
92108 }
93109
94110 const value = ( instance as unknown as ElementArgument < TData > ) . value ;
@@ -98,12 +114,12 @@ export function run(nodeID: string): void {
98114 }
99115 } else {
100116 if ( instance instanceof ElementStatement ) {
101- instance . onVisit ( memo ) ;
117+ instance . onVisit ( scope , memo ) ;
102118 } /* instance instanceof ElementBlock */ else {
103119 if ( marker !== '__rollback__' ) {
104- ( instance as ElementBlock ) . onVisit ( memo ) ;
120+ ( instance as ElementBlock ) . onVisit ( scope , memo ) ;
105121 } else {
106- ( instance as ElementBlock ) . onExit ( ) ;
122+ ( instance as ElementBlock ) . onExit ( scope , { } ) ;
107123 }
108124 }
109125 }
0 commit comments