feat: us const & and std::move
This commit is contained in:
@ -56,7 +56,7 @@ std::any FucntionContainer::CallFunction(const std::string &name,
|
||||
is_first = false;
|
||||
double *value_ptr = std::any_cast<double>(&args[i].value);
|
||||
if (!value_ptr) {
|
||||
std::string buf = Any2String(args[i].value);
|
||||
std::string buf = std::move(Any2String(args[i].value));
|
||||
std::cout << buf;
|
||||
} else
|
||||
std::cout << std::fixed << std::setprecision(6) << *value_ptr;
|
||||
@ -67,10 +67,10 @@ std::any FucntionContainer::CallFunction(const std::string &name,
|
||||
if (args.size() != 1)
|
||||
throw InterpretException(
|
||||
"CallFunction: str() should take exactly one argument", 23);
|
||||
return Any2String(args[0].value);
|
||||
return std::move(Any2String(args[0].value));
|
||||
} else if (name == "int") {
|
||||
if (args.size() == 1) {
|
||||
return Any2Int(args[0].value);
|
||||
return std::move(Any2Int(args[0].value));
|
||||
} else {
|
||||
throw InterpretException(
|
||||
"CallFunction: int() should take exactly one argument", 24);
|
||||
@ -128,7 +128,7 @@ std::any FucntionContainer::CallFunction(const std::string &name,
|
||||
args_with_data.insert(func.para_list[i].name);
|
||||
}
|
||||
EvalVisitor vis;
|
||||
std::any res = vis.visit(func.code_address);
|
||||
std::any res = std::move(vis.visit(func.code_address));
|
||||
Variables.DestroyFrame();
|
||||
// std::cerr << "function called " << std::endl;
|
||||
FlowType *flow = std::any_cast<FlowType>(&res);
|
||||
@ -136,9 +136,9 @@ std::any FucntionContainer::CallFunction(const std::string &name,
|
||||
if (flow->ReturnValueLists.size() == 0)
|
||||
return NoneType();
|
||||
else if (flow->ReturnValueLists.size() == 1)
|
||||
return flow->ReturnValueLists[0];
|
||||
return std::move(flow->ReturnValueLists[0]);
|
||||
else
|
||||
return flow->ReturnValueLists;
|
||||
return std::move(flow->ReturnValueLists);
|
||||
}
|
||||
// std::cerr<<"Return value isn't FlowType"<<std::endl;
|
||||
return NoneType();
|
||||
|
Reference in New Issue
Block a user