File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
modules/runtime/src/interpreter Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -16,15 +16,29 @@ export class IRInterpreter {
1616 load ( program : IRProgram ) : void {
1717 this . context = new ExecutionContext ( program ) ;
1818
19- // Initialize the instruction pointer to the first instruction of the 'start2' function
20- // (We'll use 'start2' as the entry point based on the mock program)
21- const startFunction = program . functions . get ( 'start2' ) ;
19+ let startFunction = program . functions . get ( 'start1' ) ;
20+ let entryPointName = 'start1' ;
21+
22+ if ( ! startFunction ) {
23+ startFunction = program . functions . get ( 'start2' ) ;
24+ entryPointName = 'start2' ;
25+ }
26+
27+ if ( ! startFunction ) {
28+ startFunction = program . functions . get ( 'main' ) ;
29+ entryPointName = 'main' ;
30+ }
31+
2232 if ( ! startFunction || startFunction . blocks . length === 0 ) {
23- throw new Error ( 'Program must have a start2 function with at least one block' ) ;
33+ const availableFunctions = Array . from ( program . functions . keys ( ) ) ;
34+ throw new Error (
35+ `Program must have a start1, start2, or main function with at least one block. ` +
36+ `Available functions: ${ availableFunctions . join ( ', ' ) } ` ,
37+ ) ;
2438 }
2539
2640 this . context . instructionPointer = {
27- functionName : 'start2' ,
41+ functionName : entryPointName ,
2842 blockLabel : startFunction . blocks [ 0 ] . label ,
2943 instructionIndex : 0 ,
3044 } ;
You can’t perform that action at this time.
0 commit comments