Fixed problem in DeviceSettings::strParam, returned wrong string
[avr-sim.git] / src / ScriptableAnalyzer.h
blob8f9708e08c6d13e03ac4419078eef02962642048
1 #ifndef AVR_SCRIPTABLEANALYZER_H
2 #define AVR_SCRIPTABLEANALYZER_H
4 #include "Analyzer.h"
5 #include "script/Scriptable.h"
6 #include "script/ScriptUtil.h"
8 namespace avr {
10 class ScriptEngine;
12 /**
13 * @author Tom Haber
14 * @date May 13, 2008
15 * @brief Scriptable Analyzer
17 * This class passes all core state changes to a script.
19 class ScriptableAnalyzer : public Analyzer, public script::Scriptable {
20 public:
21 ScriptableAnalyzer(Core *core, ScriptEngine *vm, const char *scriptname);
22 ~ScriptableAnalyzer();
24 public:
25 virtual void reset(unsigned int type);
26 virtual void trace(dword address);
27 virtual void step(lword ticks);
29 public:
30 virtual void readRegister(unsigned int r, byte val);
31 virtual void writeRegister(unsigned int r, byte val);
32 virtual void readByte(unsigned int addr, byte val);
33 virtual void writeByte(unsigned int addr, byte val);
34 virtual void readFlash(unsigned int addr, byte val);
35 virtual void writeFlash(unsigned int addr, word data);
36 virtual void fetchOperand(word val);
38 public:
39 virtual void push(byte val);
40 virtual void pop(byte val);
41 virtual void jump(dword address, bool push);
42 virtual void skip();
43 virtual void call(dword address, bool push);
44 virtual void ret(bool interrupt);
46 public:
47 virtual void sleep(unsigned int mode);
48 virtual void systemBreak();
49 virtual void interrupt(unsigned int vector, unsigned int addr);
51 public:
52 /**
53 * When a (C++) method is called from a script, this function
54 * is executed and unique method identifier is passed as parameter.
55 * Derived classes must override this if they add new scriptable methods.
56 * @param vm Script virtual machine executing the method.
57 * @param i Unique identifier (index) of the called method.
58 * @return Number of arguments returned in the script stack.
60 int methodCall(int i);
62 private:
63 void callHelper(const char *method);
64 void callHelper(const char *method, float x);
65 void callHelperb(const char *method, bool b);
66 void callHelper(const char *method, float x, float y);
67 void callHelperb(const char *method, float x, bool val);
69 private:
70 const char *scriptname;
72 // scripting
73 int methodBase;
74 static script::ScriptMethod<ScriptableAnalyzer> sm_methods[];
76 private:
77 int script_breakSystem(const char *funcName);
78 int script_register(const char *funcName);
79 int script_ioregister(const char *funcName);
84 #endif /*AVR_SCRIPTABLEANALYZER_H*/