Beispiel #1
0
void execute_call (instruction* instr){
	avm_memcell* func = avm_translate_operand(&instr->result, &ax);
	assert(func);
	avm_callsaveenvironment();

	char* s;
	switch(func->type)
		{
		case userfunc_m:
			pc = func->data.funcVal;
			assert(pc < AVM_ENDING_PC);
			assert(code[pc].opcode == funcenter_v);
			break;
		case string_m:
			avm_calllibfunc(func->data.strVal);
			break;
		case libfunc_m:
			avm_calllibfunc(func->data.libfuncVal);
			break;
		default:
			s = avm_tostring(func);
			avm_error("call: can not bind '%s' to function!\n", s);
			free(s);
			executionFinished = 1;
		}
}
Beispiel #2
0
void execute_call(instruction* instr){
	//printf("exec_call\n");
	avm_memcell* func = avm_translate_operand(&instr->result, &ax);
	assert(func);
	avm_callsaveenviroment();

	switch (func->type){		
		case userfunc_m: {
			pc = func->data.funcVal;
			assert(pc < AVM_ENDING_PC);
			assert(instr[pc].opcode = funcenter_v);
			break;
		}
		
		case string_m: {
			avm_calllibfunc(func->data.strVal);
			break;
		}
		
		case libfunc_m: {
			avm_calllibfunc(func->data.strVal);
			break;
		}
		
		default: {
			char *s = (char*) malloc(sizeof(char));
			s = avm_tostring(func);
			avm_error("call: cannot bind '%s' to function!");
			free(s);
			executionFinished = 1;
		}
	}
}