in src/main/java/com/ql/util/express/InstructionSet.java [151:188]
public CallResult execute(RunEnvironment environment, InstructionSetContext context, List<String> errorList,
boolean isReturnLastData) throws Exception {
//将函数export到上下文中,这儿就是重入也没有关系,不需要考虑并发
if (cacheFunctionSet == null) {
Map<String, Object> tempMap = new HashMap<>();
for (FunctionInstructionSet s : this.functionDefine.values()) {
tempMap.put(s.name, s.instructionSet);
}
cacheFunctionSet = tempMap;
}
context.addSymbol(cacheFunctionSet);
this.executeInnerOriginalInstruction(environment, errorList);
// 是在执行完所有的指令后结束的代码
if (!environment.isExit()) {
if (environment.getDataStackSize() > 0) {
OperateData tmpObject = environment.pop();
if (tmpObject == null) {
environment.quitExpress(null);
} else {
if (isReturnLastData) {
if (tmpObject.getType(context) != null && tmpObject.getType(context).equals(void.class)) {
environment.quitExpress(null);
} else {
environment.quitExpress(tmpObject.getObject(context));
}
} else {
environment.quitExpress(tmpObject);
}
}
}
}
if (environment.getDataStackSize() > 1) {
throw new QLException("在表达式执行完毕后,堆栈中还存在多个数据");
}
return OperateDataCacheManager.fetchCallResult(environment.getReturnValue(), environment.isExit());
}