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
00045 skRValue evaluate(skStackFrame& frame,skExprNode * n);
00050 skRValue evalMethod(skStackFrame& frame,skIdListNode * ids);
00060 void makeMethodCall(skStackFrame& frame,skRValue& robject,const skString& method_name,skExprNode * array_index, const skString& attribute,skExprListNode * exprs,skRValue& ret);
00061
00062
00063
00068 void executeAssignStat(skStackFrame& frame,skAssignNode * n);
00069
00070
00071
00078 bool executeStat(skStackFrame& frame,skStatNode * pstat,skRValue& r);
00079
00086 bool executeStats(skStackFrame& frame,skStatListNode * n,skRValue& r);
00087
00094 bool executeReturnStat(skStackFrame& frame,skReturnNode * n,skRValue& r);
00095
00102 bool executeIfStat(skStackFrame& frame,skIfNode * n,skRValue& r);
00103
00110 bool executeWhileStat(skStackFrame& frame,skWhileNode * n,skRValue& r);
00111
00118 bool executeSwitchStat(skStackFrame& frame,skSwitchNode * n,skRValue& r);
00119
00126 bool executeForEachStat(skStackFrame& frame,skForEachNode * n,skRValue& r);
00127
00134 bool executeForStat(skStackFrame& frame,skForNode * n,skRValue& r);
00135
00136
00137
00143 void addLocalVariable(skRValueTable& var,const skString& name,skRValue value);
00150 skString checkIndirectId(skStackFrame& frame,const skString& name);
00158 skRValue findValue(skStackFrame& frame,const skString& name,skExprNode * array_index,const skString& attribute);
00164 void runtimeError(skStackFrame& frame,const skString& s);
00170 void followIdList(skStackFrame& frame,skIdListNode * idList,skRValue& object);
00171
00175 void trace(const skString& s);
00176
00185 bool extractFieldArrayValue(skStackFrame& frame,skRValue& robject,const skString& field_name,skExprNode * array_index,const skString& attrib,skRValue& ret);
00193 bool extractArrayValue(skStackFrame& frame,skRValue& robject,skExprNode * array_index,const skString& attrib,skRValue& ret) ;
00201 bool extractValue(skStackFrame& frame,skRValue& robject,const skString& name,const skString& attrib,skRValue& ret) ;
00202
00210 bool insertArrayValue(skStackFrame& frame,skRValue& robject, skExprNode * array_index,const skString& attr,const skRValue& value);
00218 bool insertValue(skStackFrame& frame,skRValue& robject,const skString& name, const skString& attr,const skRValue& value);
00219
00220
00222 skRValueTable m_GlobalVars;
00224 bool m_Tracing;
00226 skTraceCallback * m_TraceCallback;
00228 skStatementStepper * m_StatementStepper;
00229 skInterpreter * pown;
00230 };
00231
00232
00233 inline skString P_Interpreter::checkIndirectId(skStackFrame& frame,const skString& name)
00234
00235 {
00236
00237 skString ret=name;
00238 if (name.at(0)=='@'){
00239 ret=name.substr(1,name.length()-1);
00240 skRValue new_name=findValue(frame,ret,0,skString());
00241 ret=new_name.str();
00242 }
00243 return ret;
00244 }