00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <spl/interp/Program.h>
00018
00019 Program::Program()
00020 : m_cdata(), m_code(), m_argCount(0)
00021 {
00022 m_exitInstr.opCode = JSOP_EXIT;
00023 m_exitInstr.argSrc = JSOPARG_NONE;
00024 m_exitInstr.argIdx = 0;
00025 }
00026
00027 Program::Program(const Program& program)
00028 : m_cdata(program.m_cdata),
00029 m_code(program.m_code),
00030 m_exitInstr(program.m_exitInstr),
00031 m_argCount(program.m_argCount)
00032 {
00033 }
00034
00035 Program& Program::operator =(const Program& program)
00036 {
00037 m_cdata = program.m_cdata;
00038 m_code = program.m_code;
00039 m_argCount = program.m_argCount;
00040
00041 return *this;
00042 }
00043
00044 Program::~Program()
00045 {
00046 }
00047
00048 void Program::Clear()
00049 {
00050 m_cdata.Clear();
00051 m_code.Clear();
00052 m_argCount = 0;
00053 }
00054
00055 int Program::AddToTable(const String& s)
00056 {
00057 m_cdata.Add(VariantPtr(new Variant(s)));
00058 return m_cdata.Count() - 1;
00059 }
00060
00061 int Program::AddToTable(const int32 i)
00062 {
00063 m_cdata.Add(VariantPtr(new Variant(i)));
00064 return m_cdata.Count() - 1;
00065 }
00066
00067 int Program::AddToTable(const float64 f)
00068 {
00069 m_cdata.Add(VariantPtr(new Variant(f)));
00070 return m_cdata.Count() - 1;
00071 }
00072
00073 int Program::AddToTable(const Date& dt)
00074 {
00075 m_cdata.Add(VariantPtr(new Variant(dt)));
00076 return m_cdata.Count() - 1;
00077 }
00078
00079 int Program::AddToTable(const DateTime& dtm)
00080 {
00081 m_cdata.Add(VariantPtr(new Variant(dtm)));
00082 return m_cdata.Count() - 1;
00083 }
00084
00085 int Program::AppendCode(enum JsOpCode c, JsOpCodeArgSrc s, int32 idx)
00086 {
00087 Instruction i;
00088
00089 i.opCode = c;
00090 i.argSrc = s;
00091 i.argIdx = idx;
00092
00093 m_code.Add(i);
00094
00095 return m_code.Count() - 1;
00096 }
00097
00098 void Program::FixupCode(int pos, int32 idx)
00099 {
00100 m_code.ElementAtRef(pos).argIdx = idx;
00101 }
00102
00103 #if defined(DEBUG) || defined(_DEBUG)
00104 void Program::CheckMem() const
00105 {
00106 m_cdata.CheckMem();
00107 m_code.CheckMem();
00108 }
00109
00110 void Program::ValidateMem() const
00111 {
00112 m_cdata.ValidateMem();
00113 m_code.CheckMem();
00114 }
00115 #endif