• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

Function.h

Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
00003 //   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_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 // Forward declarations
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         // @param ch : target to set temporarely
00042         // @param och : original target to set temporarily
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 } // end of gnash namespace
00175 
00176 #endif
00177 

Generated on Thu Sep 30 2010 14:34:58 for Gnash by  doxygen 1.7.1