We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
环境:playscript-java与FirstClassFunction.play
问题描述:当解释执行FirstClassFunction.play文件时,该文件中的bar(foo);函数无法正确执行。
产生原因:解释执行bar(foo);时,解释器无法找到bar函数。其原因是进行闭包foo匹配时,由于foo调用多次从而导致返回参数类型个数不停的增加,从而导致函数匹配失败。
public class Function extends Scope implements FunctionType { ... @Override public List<Type> getParamTypes() { if (paramTypes == null) { paramTypes = new LinkedList<Type>(); } //当某个函数调用多次时,paramTypes的数量会不停的增加 for (Variable param : parameters) { paramTypes.add(param.type); } return paramTypes; } ...
解决方案1:进行去重操作,判断param.type是否是同一对象,如果不是,才添加到paramTypes集合中。
param.type
paramTypes
public class Function extends Scope implements FunctionType { ... @Override public List<Type> getParamTypes() { if (paramTypes == null) { paramTypes = new LinkedList<>(); } for (Variable param : parameters) { boolean isExist = false; //由于函数参数注定不会很多,所以认为这里使用for循环的时间复杂度可接受 for (Type type : paramTypes) { if (type == param.type) { isExist = true; break; } } if (!isExist) { paramTypes.add(param.type); } } return paramTypes; } ... }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
环境:playscript-java与FirstClassFunction.play
问题描述:当解释执行FirstClassFunction.play文件时,该文件中的bar(foo);函数无法正确执行。
产生原因:解释执行bar(foo);时,解释器无法找到bar函数。其原因是进行闭包foo匹配时,由于foo调用多次从而导致返回参数类型个数不停的增加,从而导致函数匹配失败。
解决方案1:进行去重操作,判断
param.type
是否是同一对象,如果不是,才添加到paramTypes
集合中。The text was updated successfully, but these errors were encountered: