1 #include "ScriptableAnalyzer.h"
2 #include "ScriptEngine.h"
3 #include "script/ScriptException.h"
7 ScriptableAnalyzer::ScriptableAnalyzer(Core
*core
, ScriptEngine
*vm
, const char *scriptname
)
8 : Analyzer(core
), script::Scriptable(vm
) {
11 compileFile(scriptname
);
12 } catch( script::ScriptException
& ex
) {
13 throw ScriptException( ex
.message() );
17 ScriptableAnalyzer::~ScriptableAnalyzer() {
20 void ScriptableAnalyzer::callHelper(const char *method
) {
22 if( hasMethod(method
) ) {
24 Scriptable::call(0, 0);
26 } catch( script::ScriptException
& ex
) {
27 throw ScriptException( ex
.message() );
31 void ScriptableAnalyzer::callHelperb(const char *method
, bool b
) {
33 if( hasMethod(method
) ) {
36 Scriptable::call(1, 0);
38 } catch( script::ScriptException
& ex
) {
39 throw ScriptException( ex
.message() );
43 void ScriptableAnalyzer::callHelper(const char *method
, float x
) {
45 if( hasMethod(method
) ) {
48 Scriptable::call(1, 0);
50 } catch( script::ScriptException
& ex
) {
51 throw ScriptException( ex
.message() );
55 void ScriptableAnalyzer::callHelperb(const char *method
, float x
, bool b
) {
57 if( hasMethod(method
) ) {
61 Scriptable::call(2, 0);
63 } catch( script::ScriptException
& ex
) {
64 throw ScriptException( ex
.message() );
68 void ScriptableAnalyzer::callHelper(const char *method
, float x
, float y
) {
70 if( hasMethod(method
) ) {
74 Scriptable::call(2, 0);
76 } catch( script::ScriptException
& ex
) {
77 throw ScriptException( ex
.message() );
81 void ScriptableAnalyzer::reset(unsigned int type
) {
82 const char *methodName
= "reset";
83 callHelper(methodName
, type
);
86 void ScriptableAnalyzer::step(dword address
, lword ticks
) {
87 const char *methodName
= "step";
88 callHelper(methodName
, address
, ticks
);
91 void ScriptableAnalyzer::readRegister(int r
, byte val
) {
92 const char *methodName
= "readRegister";
93 callHelper(methodName
, r
, val
);
96 void ScriptableAnalyzer::writeRegister(int r
, byte val
) {
97 const char *methodName
= "writeRegister";
98 callHelper(methodName
, r
, val
);
101 void ScriptableAnalyzer::readStatus(byte val
) {
102 const char *methodName
= "readStatus";
103 callHelper(methodName
, val
);
106 void ScriptableAnalyzer::writeStatus(byte val
) {
107 const char *methodName
= "writeStatus";
108 callHelper(methodName
, val
);
111 void ScriptableAnalyzer::readIORegister(int r
, byte val
) {
112 const char *methodName
= "readIORegister";
113 callHelper(methodName
, r
, val
);
116 void ScriptableAnalyzer::writeIORegister(int r
, byte val
) {
117 const char *methodName
= "writeIORegister";
118 callHelper(methodName
, r
, val
);
121 void ScriptableAnalyzer::readByte(unsigned int addr
, byte val
) {
122 const char *methodName
= "readByte";
123 callHelper(methodName
, addr
, val
);
126 void ScriptableAnalyzer::writeByte(unsigned int addr
, byte val
) {
127 const char *methodName
= "writeByte";
128 callHelper(methodName
, addr
, val
);
131 void ScriptableAnalyzer::readFlash(unsigned int addr
, byte val
) {
132 const char *methodName
= "readFlash";
133 callHelper(methodName
, addr
, val
);
136 void ScriptableAnalyzer::writeFlash(unsigned int addr
, word val
) {
137 const char *methodName
= "writeFlash";
138 callHelper(methodName
, addr
, val
);
141 void ScriptableAnalyzer::fetchOperand(word val
) {
142 const char *methodName
= "fetchOperand";
143 callHelper(methodName
, val
);
146 void ScriptableAnalyzer::push(byte val
) {
147 const char *methodName
= "push";
148 callHelper(methodName
, val
);
151 void ScriptableAnalyzer::pop(byte val
) {
152 const char *methodName
= "pop";
153 callHelper(methodName
, val
);
156 void ScriptableAnalyzer::jump(sbyte offset
, bool push
) {
157 const char *methodName
= "jump";
158 callHelperb(methodName
, offset
, push
);
161 void ScriptableAnalyzer::skip() {
162 const char *methodName
= "skip";
163 callHelper(methodName
);
166 void ScriptableAnalyzer::call(dword address
, bool push
) {
167 const char *methodName
= "call";
168 callHelperb(methodName
, address
, push
);
171 void ScriptableAnalyzer::ret(bool interrupt
) {
172 const char *methodName
= "ret";
173 callHelperb(methodName
, interrupt
);
176 void ScriptableAnalyzer::sleep(unsigned int mode
) {
177 const char *methodName
= "sleep";
178 callHelper(methodName
, mode
);
181 void ScriptableAnalyzer::interrupt(unsigned int vector
, unsigned int addr
) {
182 const char *methodName
= "interrupt";
183 callHelper(methodName
, vector
, addr
);