runcall.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "__run.h"
  2. enum ResultType setFunction(INTER_FUNCTIONSIG) {
  3. LinkValue *tmp = makeLinkValue(NULL, NULL, inter);
  4. setResultCore(result);
  5. tmp->value = makeFunctionValue(st->u.set_function.function, st->u.set_function.parameter, var_list, inter);
  6. assCore(st->u.set_function.name, tmp, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result));
  7. if (run_continue(result))
  8. setResult(result, inter);
  9. return result->type;
  10. }
  11. enum ResultType callFunction(INTER_FUNCTIONSIG) {
  12. LinkValue *function_value = NULL;
  13. VarList *function_var = NULL;
  14. setResultCore(result);
  15. if (operationSafeInterStatement(CALL_INTER_FUNCTIONSIG(st->u.call_function.function, var_list, result)))
  16. goto return_;
  17. if (result->value->value->type != function){
  18. setResultError(result, inter, "TypeException", "Object is not callable", st, true);
  19. goto return_;
  20. }
  21. function_value = result->value;
  22. function_var = pushVarList(function_value->value->data.function.var, inter);
  23. gcAddTmp(&function_var->hashtable->gc_status);
  24. runFREEZE(inter, var_list, function_var, true);
  25. freeResult(result);
  26. setParameter(st->u.call_function.parameter, function_value->value->data.function.pt, function_var,
  27. st, CALL_INTER_FUNCTIONSIG_NOT_ST(var_list, result));
  28. if (!run_continue(result)) {
  29. gcAddTmp(&function_var->hashtable->gc_status);
  30. runFREEZE(inter, var_list, function_var, false);
  31. popVarList(function_var);
  32. goto return_;
  33. }
  34. else
  35. freeResult(result);
  36. functionSafeInterStatement(CALL_INTER_FUNCTIONSIG(function_value->value->data.function.function, function_var, result));
  37. gcFreeTmpLink(&function_var->hashtable->gc_status);
  38. runFREEZE(inter, var_list, function_var, false);
  39. popVarList(function_var);
  40. setResultError(result, inter, NULL, NULL, st, false); // 自带检查
  41. return_:
  42. return result->type;
  43. }