Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GNASH_VM_CALL_STACK_H
00020 #define GNASH_VM_CALL_STACK_H
00021
00022 #include <vector>
00023
00024 #include "as_value.h"
00025 #include "string_table.h"
00026
00027
00028 namespace gnash {
00029 class as_object;
00030 class UserFunction;
00031 }
00032
00033 namespace gnash {
00034
00036
00039
00043 class CallFrame
00044 {
00045 public:
00046
00047 typedef std::vector<as_value> Registers;
00048
00050
00054 CallFrame(UserFunction* func);
00055
00057 CallFrame(const CallFrame& other)
00058 :
00059 _locals(other._locals),
00060 _func(other._func),
00061 _registers(other._registers)
00062 {}
00063
00065 CallFrame& operator=(const CallFrame& other) {
00066 _locals = other._locals;
00067 _func = other._func;
00068 _registers = other._registers;
00069 return *this;
00070 }
00071
00073 as_object& locals() {
00074 return *_locals;
00075 }
00076
00078 UserFunction& function() {
00079 return *_func;
00080 }
00081
00083
00087 const as_value* getLocalRegister(size_t i) const {
00088 if (i >= _registers.size()) return 0;
00089 return &_registers[i];
00090 }
00091
00093
00095
00098 void setLocalRegister(size_t i, const as_value& val);
00099
00101
00104 bool hasRegisters() const {
00105 return !_registers.empty();
00106 }
00107
00109
00112 void markReachableResources() const;
00113
00114
00115 private:
00116
00117 friend std::ostream& operator<<(std::ostream&, const CallFrame&);
00118
00120 as_object* _locals;
00121
00122 UserFunction* _func;
00123
00125 Registers _registers;
00126
00127 };
00128
00130
00132
00135 void declareLocal(CallFrame& c, string_table::key name);
00136
00138
00140
00144 void setLocal(CallFrame& c, string_table::key name, const as_value& val);
00145
00146 typedef std::vector<CallFrame> CallStack;
00147
00148 std::ostream& operator<<(std::ostream& o, const CallFrame& fr);
00149
00150 }
00151
00152 #endif // GNASH_VM_CALL_STACK_H