mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-12-25 13:29:59 +00:00
Improve indirect function call code generation
This commit is contained in:
parent
9fe7d4d29d
commit
5dd829161b
@ -50,7 +50,7 @@ TESTLIB: testlib.pla $(PLVM) $(PLASM)
|
||||
test: test.pla TESTLIB $(PLVM) $(PLASM)
|
||||
./$(PLASM) -AM < test.pla > test.a
|
||||
acme --setpc 4096 -o TEST.REL test.a
|
||||
./$(PLVM) TEST.REL MAIN
|
||||
./$(PLVM) TEST.REL
|
||||
|
||||
debug: test.pla TESTLIB $(PLVM) $(PLASM)
|
||||
./$(PLASM) -AM < test.pla > test.a
|
||||
|
@ -428,19 +428,7 @@ int parse_value(int rvalue)
|
||||
/*
|
||||
* Function call
|
||||
*/
|
||||
if (!emit_value)
|
||||
{
|
||||
if (type & VAR_TYPE)
|
||||
{
|
||||
if (type & LOCAL_TYPE)
|
||||
emit_llw(value);
|
||||
else
|
||||
emit_law(value, type);
|
||||
}
|
||||
else if (type & PTR_TYPE)
|
||||
emit_lw();
|
||||
}
|
||||
if (!(type & (FUNC_TYPE | CONST_TYPE)))
|
||||
if (emit_value && !(type & (FUNC_TYPE | CONST_TYPE)))
|
||||
{
|
||||
if (scan_lookahead() != CLOSE_PAREN_TOKEN)
|
||||
emit_push();
|
||||
@ -461,8 +449,21 @@ int parse_value(int rvalue)
|
||||
emit_call(value, type);
|
||||
else
|
||||
{
|
||||
if (cparams)
|
||||
emit_pull();
|
||||
if (!emit_value)
|
||||
{
|
||||
if (type & VAR_TYPE)
|
||||
{
|
||||
if (type & LOCAL_TYPE)
|
||||
emit_llw(value);
|
||||
else
|
||||
emit_law(value, type);
|
||||
}
|
||||
else if (type & PTR_TYPE)
|
||||
emit_lw();
|
||||
}
|
||||
else
|
||||
if (cparams)
|
||||
emit_pull();
|
||||
emit_ical();
|
||||
}
|
||||
emit_value = 1;
|
||||
|
@ -27,17 +27,17 @@ def ascii
|
||||
next
|
||||
end
|
||||
|
||||
def nums
|
||||
def nums(range)
|
||||
word i
|
||||
for i = -10 to 10
|
||||
for i = -10 to range
|
||||
puti(i)
|
||||
putnl
|
||||
next
|
||||
end
|
||||
|
||||
export def main
|
||||
export def main(range)
|
||||
cls
|
||||
nums
|
||||
nums(range)
|
||||
viewport(12, 12, 16, 8)
|
||||
ascii
|
||||
viewport(0, 0, 40, 24)
|
||||
@ -48,7 +48,7 @@ end
|
||||
export def indirect
|
||||
word mainptr
|
||||
mainptr = @main
|
||||
*mainptr()
|
||||
return mainptr(10)
|
||||
end
|
||||
|
||||
indirect
|
||||
|
Loading…
Reference in New Issue
Block a user