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 "UserFunction.h"
00027 #include "smart_ptr.h"
00028
00029
00030 namespace gnash {
00031 class action_buffer;
00032 class as_object;
00033 }
00034
00035 namespace gnash {
00036
00037 class TargetGuard
00038 {
00039 public:
00040
00041
00042
00043 TargetGuard(as_environment& e, DisplayObject* ch, DisplayObject* och);
00044 ~TargetGuard();
00045
00046 private:
00047
00048 as_environment& env;
00049 DisplayObject* from;
00050 DisplayObject* from_orig;
00051
00052 };
00053
00055
00059
00061 class Function : public UserFunction
00062 {
00063
00064 public:
00065
00066 typedef std::vector<as_object*> ScopeStack;
00067
00071
00072 Function(const action_buffer& ab, as_environment& env, size_t start,
00073 const ScopeStack& with_stack);
00074
00075 virtual ~Function() {}
00076
00077 const ScopeStack& getScopeStack() const {
00078 return _scopeStack;
00079 }
00080
00081 const action_buffer& getActionBuffer() const {
00082 return _action_buffer;
00083 }
00084
00085 size_t getStartPC() const {
00086 return _startPC;
00087 }
00088
00089 size_t getLength() const {
00090 return _length;
00091 }
00092
00094
00096 virtual boost::uint8_t registers() const {
00097 return 0;
00098 }
00099
00101
00104
00107
00110 void add_arg(boost::uint8_t reg, string_table::key name) {
00111 _args.push_back(Argument(reg, name));
00112 }
00113
00115 void setLength(size_t len);
00116
00118 virtual as_value call(const fn_call& fn);
00119
00120 #ifdef GNASH_USE_GC
00121
00122
00126 virtual void markReachableResources() const;
00127 #endif // GNASH_USE_GC
00128
00129 protected:
00130
00131 struct Argument
00132 {
00133 Argument(boost::uint8_t r, string_table::key n) : reg(r), name(n) {}
00134 boost::uint8_t reg;
00135 string_table::key name;
00136 };
00137
00138 std::vector<Argument> _args;
00139
00141 as_environment& _env;
00142
00143 private:
00144
00146 const action_buffer& _action_buffer;
00147
00149 ScopeStack _scopeStack;
00150
00154 size_t _startPC;
00155
00157
00161 size_t _length;
00162
00163
00164 };
00165
00167
00170 as_object* getArguments(Function& callee, as_object& args,
00171 const fn_call& fn, as_object* caller);
00172
00173
00174 }
00175
00176 #endif
00177