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_SWF_FUNCTION_H
00020 #define GNASH_SWF_FUNCTION_H
00021
00022 #include <vector>
00023 #include <cassert>
00024 #include <string>
00025
00026 #include "ConstantPool.h"
00027 #include "UserFunction.h"
00028 #include "ObjectURI.h"
00029
00030
00031 namespace gnash {
00032 class action_buffer;
00033 class as_object;
00034 class VM;
00035 }
00036
00037 namespace gnash {
00038
00039 class TargetGuard
00040 {
00041 public:
00042
00043
00044
00045 TargetGuard(as_environment& e, DisplayObject* ch, DisplayObject* och);
00046 ~TargetGuard();
00047
00048 private:
00049
00050 as_environment& env;
00051 DisplayObject* from;
00052 DisplayObject* from_orig;
00053
00054 };
00055
00057
00061
00063 class Function : public UserFunction
00064 {
00065
00066 public:
00067
00068 typedef std::vector<as_object*> ScopeStack;
00069
00073
00074 Function(const action_buffer& ab, as_environment& env, size_t start,
00075 const ScopeStack& with_stack);
00076
00077 virtual ~Function() {}
00078
00079 const ScopeStack& getScopeStack() const {
00080 return _scopeStack;
00081 }
00082
00083 const action_buffer& getActionBuffer() const {
00084 return _action_buffer;
00085 }
00086
00087 size_t getStartPC() const {
00088 return _startPC;
00089 }
00090
00091 size_t getLength() const {
00092 return _length;
00093 }
00094
00096
00098 virtual boost::uint8_t registers() const {
00099 return 0;
00100 }
00101
00103
00106
00109
00112 void add_arg(boost::uint8_t reg, const ObjectURI& name) {
00113 _args.push_back(Argument(reg, name));
00114 }
00115
00117 void setLength(size_t len);
00118
00120 virtual as_value call(const fn_call& fn);
00121
00123
00127 virtual void markReachableResources() const;
00128
00129 protected:
00130
00131 struct Argument
00132 {
00133 Argument(boost::uint8_t r, const ObjectURI& n) : reg(r), name(n) {}
00134 boost::uint8_t reg;
00135 ObjectURI name;
00136 };
00137
00138 std::vector<Argument> _args;
00139
00141 as_environment& _env;
00142
00144 const ConstantPool* _pool;
00145
00146 private:
00147
00149 const action_buffer& _action_buffer;
00150
00152 ScopeStack _scopeStack;
00153
00157 size_t _startPC;
00158
00160
00164 size_t _length;
00165
00166 };
00167
00169
00172 as_object* getArguments(Function& callee, as_object& args,
00173 const fn_call& fn, as_object* caller);
00174
00175
00176 }
00177
00178 #endif
00179