Skip to content

Commit 4146790

Browse files
committed
[[ LCB ]] Fix minor errors in code gen for indirect calls.
1 parent 78bf775 commit 4146790

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

libscript/src/script-builder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ void MCScriptBeginInvokeEvaluateInModule(MCScriptModuleBuilderRef self, uindex_t
13681368
}
13691369
#endif
13701370

1371-
void MCScriptBeginIndirectInvokeInModule(MCScriptModuleBuilderRef self, uindex_t p_handler_reg, uindex_t p_result_reg)
1371+
void MCScriptBeginInvokeIndirectInModule(MCScriptModuleBuilderRef self, uindex_t p_handler_reg, uindex_t p_result_reg)
13721372
{
13731373
if (self == nil || !self -> valid)
13741374
return;

toolchain/lc-compile/src/emit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ void EmitBeginInvoke(long index, long contextreg, long resultreg)
984984

985985
void EmitBeginIndirectInvoke(long handlerreg, long contextreg, long resultreg)
986986
{
987-
MCScriptBeginInvokeInModule(s_builder, handlerreg, resultreg);
987+
MCScriptBeginInvokeIndirectInModule(s_builder, handlerreg, resultreg);
988988
MCLog("[Emit] BeginExecuteIndirectInvoke(%ld, %ld, %ld)", handlerreg, contextreg, resultreg);
989989
}
990990

toolchain/lc-compile/src/generate.g

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@
13691369
-- If the Id is not a handler it must be a variable
13701370
ne(Kind, handler)
13711371
EmitCreateRegister(-> HandlerReg)
1372-
EmitFetchVar(Kind, Index, HandlerReg)
1372+
EmitFetchVar(Kind, HandlerReg, Index)
13731373
||
13741374
where(-1 -> HandlerReg)
13751375
|)
@@ -1501,12 +1501,13 @@
15011501
15021502
'action' EmitFetchVar(SYMBOLKIND, INT, INT)
15031503
1504-
'rule' EmitFetchVar(variable, Reg, Var):
1505-
EmitFetchGlobal(Reg, Var)
1506-
1507-
'rule' EmitFetchVar(_, Reg, Var):
1504+
'rule' EmitFetchVar(local, Reg, Var):
15081505
EmitFetchLocal(Reg, Var)
15091506
1507+
-- This catches all module-scope things, including variables and handler references.
1508+
'rule' EmitFetchVar(_, Reg, Var):
1509+
EmitFetchGlobal(Reg, Var)
1510+
15101511
'action' EmitInvokeRegisterList(INTLIST)
15111512
15121513
'rule' EmitInvokeRegisterList(intlist(Head, Tail)):

0 commit comments

Comments
 (0)