forked from xxq250/Nasal-Interpreter
✨ add special variable "arg"
This commit is contained in:
@@ -1091,7 +1091,18 @@ const error& codegen::compile(parse& parse, linker& import) {
|
||||
fileindex = 0;
|
||||
file = import.filelist().data();
|
||||
in_iterloop.push(0);
|
||||
|
||||
// add special symbol globals, which is a hash stores all global variables
|
||||
add_symbol("globals");
|
||||
// add special symbol arg here, which is used to store function arguments
|
||||
// for example:
|
||||
// var f = func(a) {print(arg)}
|
||||
// f(1, 2, 3);
|
||||
// then the arg is [2, 3], because 1 is accepted by "a"
|
||||
// so in fact "f" is the same as:
|
||||
// var f = func(a, arg...) {return(arg)}
|
||||
add_symbol("arg");
|
||||
|
||||
find_symbol(parse.tree()); // search symbols first
|
||||
gen(op_intg, global.size(), 0);
|
||||
block_gen(parse.tree()); // generate main block
|
||||
|
||||
Reference in New Issue
Block a user