void avm_assign(avm_memcell* lv, avm_memcell* rv){ if(lv == rv) { return; } if((lv->type == table_m)&&(rv->type == table_m)&&(lv->data.tableVal == rv->data.tableVal)) { return; } if(rv->type == undef_m) { avm_warning("Assigning from 'undef' content!\n"); } avm_memcellclear(lv); memcpy(lv, rv, sizeof(avm_memcell)); if(lv->type == string_m) { lv->data.strVal = strdup(rv->data.strVal); } else if(lv->type = table_m) { avm_tableincrefcounter(lv->data.tableVal); } }
void execute_newtable(instruction* instr){ //printf("exec_newtable\n"); avm_memcell* lv = avm_translate_operand(&instr->result,(avm_memcell*) 0); assert(lv && (&stack[AVM_STACKSIZE-1] >= lv && lv > &stack[top] || lv == &retval)); avm_memcellclear(lv); lv->type = table_m; lv->data.tableVal = avm_tablenew(); avm_tableincrefcounter(lv->data.tableVal); }