Gnash 0.8.9
|
00001 // 00002 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 00003 // 2011 Free Software Foundation, Inc 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 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 // Forward declarations 00028 namespace gnash { 00029 class as_object; 00030 struct ObjectURI; 00031 class UserFunction; 00032 } 00033 00034 namespace gnash { 00035 00037 // 00040 // 00044 class CallFrame 00045 { 00046 public: 00047 00048 typedef std::vector<as_value> Registers; 00049 00051 // 00055 CallFrame(UserFunction* func); 00056 00058 CallFrame(const CallFrame& other) 00059 : 00060 _locals(other._locals), 00061 _func(other._func), 00062 _registers(other._registers) 00063 {} 00064 00066 CallFrame& operator=(const CallFrame& other) { 00067 _locals = other._locals; 00068 _func = other._func; 00069 _registers = other._registers; 00070 return *this; 00071 } 00072 00074 as_object& locals() { 00075 return *_locals; 00076 } 00077 00079 UserFunction& function() { 00080 return *_func; 00081 } 00082 00084 // 00088 const as_value* getLocalRegister(size_t i) const { 00089 if (i >= _registers.size()) return 0; 00090 return &_registers[i]; 00091 } 00092 00094 // 00096 // 00099 void setLocalRegister(size_t i, const as_value& val); 00100 00102 // 00105 bool hasRegisters() const { 00106 return !_registers.empty(); 00107 } 00108 00110 // 00113 void markReachableResources() const; 00114 00115 00116 private: 00117 00118 friend std::ostream& operator<<(std::ostream&, const CallFrame&); 00119 00121 as_object* _locals; 00122 00123 UserFunction* _func; 00124 00126 Registers _registers; 00127 00128 }; 00129 00131 // 00133 // 00136 void declareLocal(CallFrame& c, const ObjectURI& name); 00137 00139 // 00141 // 00145 void setLocal(CallFrame& c, const ObjectURI& name, const as_value& val); 00146 00147 typedef std::vector<CallFrame> CallStack; 00148 00149 std::ostream& operator<<(std::ostream& o, const CallFrame& fr); 00150 00151 } // namespace gnash 00152 00153 #endif // GNASH_VM_CALL_STACK_H