mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
interpreter: migration to universial stdlib support (without varargs yet)
This commit is contained in:
parent
318ebc72aa
commit
58f0bfc0b9
9 changed files with 163 additions and 119 deletions
|
|
@ -324,7 +324,7 @@ void analyze(uint32_t mod_id) {
|
|||
break;
|
||||
case Cmd::CALLF: {
|
||||
// TODO: find link to real function and replace call (need to save all
|
||||
// modules in one space)
|
||||
// modules in one space) <- optimization
|
||||
|
||||
ip_read_int_unsafe(¤t_ip); // function name (str)
|
||||
uint args_count = ip_read_int_unsafe(¤t_ip);
|
||||
|
|
@ -344,23 +344,24 @@ void analyze(uint32_t mod_id) {
|
|||
}
|
||||
++current_stack_depth;
|
||||
break;
|
||||
case Cmd::Lread:
|
||||
++current_stack_depth;
|
||||
break;
|
||||
case Cmd::Lwrite:
|
||||
case Cmd::Llength:
|
||||
case Cmd::Lstring:
|
||||
if (current_stack_depth < 1) {
|
||||
ip_failure(saved_current_ip, mod_id, "not enough elements in stack");
|
||||
}
|
||||
break;
|
||||
case Cmd::Barray:
|
||||
current_stack_depth -= ip_read_int_unsafe(¤t_ip); // elem count
|
||||
if (current_stack_depth < 0) {
|
||||
ip_failure(saved_current_ip, mod_id, "not enough elements in stack");
|
||||
}
|
||||
++current_stack_depth;
|
||||
break;
|
||||
// NOTE: no longer used
|
||||
// case Cmd::Lread:
|
||||
// ++current_stack_depth;
|
||||
// break;
|
||||
// case Cmd::Lwrite:
|
||||
// case Cmd::Llength:
|
||||
// case Cmd::Lstring:
|
||||
// if (current_stack_depth < 1) {
|
||||
// ip_failure(saved_current_ip, mod_id, "not enough elements in stack");
|
||||
// }
|
||||
// break;
|
||||
// case Cmd::Barray:
|
||||
// current_stack_depth -= ip_read_int_unsafe(¤t_ip); // elem count
|
||||
// if (current_stack_depth < 0) {
|
||||
// ip_failure(saved_current_ip, mod_id, "not enough elements in stack");
|
||||
// }
|
||||
// ++current_stack_depth;
|
||||
// break;
|
||||
case Cmd::EXIT:
|
||||
ip_failure(saved_current_ip, mod_id,
|
||||
"exit should be unreachable"); // NOTE: not sure
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue