00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "skParseNode.h"
00024 #include "skExecutableIterator.h"
00025 #include "skRValueTable.h"
00026
00030 class P_Interpreter
00031 {
00032 public:
00034 P_Interpreter(skInterpreter * owner);
00036 ~P_Interpreter();
00037
00038
00039
00040
00047 skRValue evaluate(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skExprNode * n);
00054 skRValue evalMethod(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skIdListNode * ids);
00065 void makeMethodCall(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skRValue& robject,const skString& method_name,skExprNode * array_index, const skString& attribute,skExprListNode * exprs,skRValue& ret);
00066
00067
00068
00075 void executeAssignStat(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skAssignNode * n);
00076
00077
00078
00087 bool executeStat(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skStatNode * pstat,skRValue& r);
00088
00097 bool executeStats(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skStatListNode * n,skRValue& r);
00098
00107 bool executeReturnStat(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skReturnNode * n,skRValue& r);
00108
00117 bool executeIfStat(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skIfNode * n,skRValue& r);
00118
00127 bool executeWhileStat(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skWhileNode * n,skRValue& r);
00128
00137 bool executeSwitchStat(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skSwitchNode * n,skRValue& r);
00138
00147 bool executeForEachStat(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skForEachNode * n,skRValue& r);
00148
00157 bool executeForStat(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skForNode * n,skRValue& r);
00158
00159
00160
00166 void addLocalVariable(skRValueTable& var,const skString& name,skRValue value);
00173 skString checkIndirectId(skContext& ctxt,skiExecutable * obj,skRValueTable& var,const skString& name);
00183 skRValue findValue(skContext& ctxt,skiExecutable * obj,skRValueTable& var,const skString& name,skExprNode * array_index,const skString& attribute);
00189 void runtimeError(skContext& ctxt,const skString& s);
00197 void followIdList(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skIdListNode * idList,skRValue& object);
00198
00202 void trace(const skString& s);
00203
00214 bool extractFieldArrayValue(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skRValue& robject,const skString& field_name,skExprNode * array_index,const skString& attrib,skRValue& ret);
00224 bool extractArrayValue(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skRValue& robject,skExprNode * array_index,const skString& attrib,skRValue& ret) ;
00232 bool extractValue(skContext& ctxt,skRValue& robject,const skString& name,const skString& attrib,skRValue& ret) ;
00233
00242 bool insertArrayValue(skContext& ctxt,skiExecutable * obj,skRValueTable& var,skRValue& robject, skExprNode * array_index,const skString& attr,const skRValue& value);
00250 bool insertValue(skContext& ctxt,skRValue& robject,const skString& name, const skString& attr,const skRValue& value);
00251
00252
00254 skRValueTable m_GlobalVars;
00256 bool m_Tracing;
00258 skTraceCallback * m_TraceCallback;
00260 skStatementStepper * m_StatementStepper;
00261 skInterpreter * pown;
00262 };
00263
00264
00265 inline skString P_Interpreter::checkIndirectId(skContext& ctxt,skiExecutable * obj,skRValueTable& var,const skString& name)
00266
00267 {
00268
00269 skString ret=name;
00270 if (name.at(0)=='@'){
00271 ret=name.substr(1,name.length()-1);
00272 skRValue new_name=findValue(ctxt,obj,var,ret,0,skString());
00273 ret=new_name.str();
00274 }
00275 return ret;
00276 }