00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <celscript/function.h>
00011 #include <celscript/statement.h>
00012 #include <celscript/execution.h>
00013
00014 using namespace celx;
00015 using namespace std;
00016
00017
00018 Function::Function(vector<string>* _args, Statement* _body) :
00019 arguments(_args), body(_body)
00020 {
00021 }
00022
00023 Function::Function(const Function& f) :
00024 arguments(f.arguments), body(f.body)
00025 {
00026 }
00027
00028 Function::~Function()
00029 {
00030
00031
00032 }
00033
00034
00035 Value Function::call(ExecutionContext& context)
00036 {
00037 Statement::Control control = body->execute(context);
00038 if (control == Statement::ControlReturn)
00039 {
00040 return context.popReturnValue();
00041 }
00042 else
00043 {
00044 return Value();
00045 }
00046 }
00047