Gnash  0.8.11dev
Function2.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_FUNCTION2_H
20 #define GNASH_FUNCTION2_H
21 
22 #include "Function.h"
23 
24 // Forward declarations
25 namespace gnash {
26  class action_buffer;
27  class as_object;
28 }
29 
30 namespace gnash {
31 
33 //
40 class Function2 : public Function
41 {
42 
43 public:
44 
46  {
48  PRELOAD_THIS = 0x01,
49 
51  SUPPRESS_THIS = 0x02,
52 
55 
58 
60  PRELOAD_SUPER = 0x10,
61 
64 
66  PRELOAD_ROOT = 0x40,
67 
70 
72  PRELOAD_GLOBAL = 256
73  };
74 
75  // Create a function defined in a DefineFunction2 opcode.
76  Function2(const action_buffer& ab, as_environment& env, size_t start,
77  const ScopeStack& with_stack);
78 
79  virtual ~Function2() {}
80 
82  virtual std::uint8_t registers() const {
83  return _registerCount;
84  }
85 
86  void setRegisterCount(std::uint8_t ct) {
87  _registerCount = ct;
88  }
89 
90  void setFlags(std::uint16_t flags) {
91  _function2Flags = flags;
92  }
93 
95  virtual as_value call(const fn_call& fn);
96 
97 private:
98 
100  std::uint8_t _registerCount;
101 
103  std::uint16_t _function2Flags;
104 
105 };
106 
107 
108 } // end of gnash namespace
109 
110 #endif
111 
action_buffer.h
gnash::Function::_args
std::vector< Argument > _args
Definition: Function.h:138
gnash::DisplayObject::getAsRoot
virtual MovieClip * getAsRoot()
Return the _root ActionScript property of this DisplayObject.
Definition: DisplayObject.cpp:847
gnash::fn_call::super
as_object * super
The "super" object in this function call context.
Definition: fn_call.h:175
gnash::Function2
Function2 adds extra sauce to ordinary Functions.
Definition: Function2.h:41
name
std::string name
Definition: LocalConnection_as.cpp:149
gnash::as_object
The base class for all ActionScript objects.
Definition: as_object.h:162
gnash::Function2::~Function2
virtual ~Function2()
Definition: Function2.h:79
gnash::FrameGuard::callFrame
CallFrame & callFrame()
Get the CallFrame we've just pushed.
Definition: VM.h:329
gnash::key::i
@ i
Definition: GnashKey.h:155
gnash::setLocal
void setLocal(CallFrame &c, const ObjectURI &name, const as_value &val)
Set a local variable in this CallFrame.
Definition: CallStack.cpp:80
gnash::Function
A simple SWF-defined Function.
Definition: Function.h:64
CallStack.h
gnash::as_environment
Provides information about timeline context.
Definition: as_environment.h:51
gnash::VM
The AVM1 virtual machine.
Definition: VM.h:72
gnash::Function2::Function2
Function2(const action_buffer &ab, as_environment &env, size_t start, const ScopeStack &with_stack)
Definition: Function2.cpp:35
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
ActionExec.h
gnash::NSV::PROP_SUPER
@ PROP_SUPER
Definition: namedStrings.h:93
gnash::VM::getGlobal
Global_as * getGlobal() const
Get a pointer to this VM's _global Object.
Definition: VM.cpp:149
gnash::Function2::PRELOAD_ARGUMENTS
@ PRELOAD_ARGUMENTS
Bind one register to "arguments".
Definition: Function2.h:54
gnash::Function2::PRELOAD_GLOBAL
@ PRELOAD_GLOBAL
Bind one register to "_global".
Definition: Function2.h:72
NativeFunction.h
gnash::key::n
@ n
Definition: GnashKey.h:160
start
@ start
Definition: klash_part.cpp:330
Global_as.h
gnash::ActionExec
Executor of an action_buffer.
Definition: ActionExec.h:119
gnash::getGlobal
Global_as & getGlobal(const as_environment &env)
Definition: as_environment.cpp:651
gnash::getVM
VM & getVM(const as_environment &env)
Definition: as_environment.h:222
gnash::CallFrame::setLocalRegister
void setLocalRegister(size_t i, const as_value &val)
Set a specific register in this CallFrame.
Definition: CallStack.cpp:57
gnash::Function2::SUPPRESS_THIS
@ SUPPRESS_THIS
No "this" variable accessible by name.
Definition: Function2.h:51
Function2.h
gnash::fn_call
Parameters/environment for builtin or user-defined functions callable from ActionScript.
Definition: fn_call.h:118
gnash::key::r
@ r
Definition: GnashKey.h:164
gnash::Function2::setRegisterCount
void setRegisterCount(std::uint8_t ct)
Definition: Function2.h:86
gnash::Function2::SUPPRESS_SUPER
@ SUPPRESS_SUPER
No "super" variable accessible by name.
Definition: Function2.h:63
gnash::Function2::registers
virtual std::uint8_t registers() const
Return the number of registers to allocate for this function.
Definition: Function2.h:82
gnash::Function2::PRELOAD_THIS
@ PRELOAD_THIS
Bind one register to "this".
Definition: Function2.h:48
gnash::Function::_env
as_environment & _env
@ might need some kind of ref count here, but beware cycles
Definition: Function.h:141
MovieClip.h
gnash::key::p
@ p
Definition: GnashKey.h:162
gnash::Function2::SUPPRESS_ARGUMENTS
@ SUPPRESS_ARGUMENTS
No "argument" variable accessible by name.
Definition: Function2.h:57
gnash::fn_call::nargs
Args::size_type nargs
Number of arguments to this ActionScript function call.
Definition: fn_call.h:178
gnash::as_environment::target
DisplayObject * target() const
Definition: as_environment.h:61
gnash::VM::calling
bool calling() const
Whether a function call is in progress.
Definition: VM.h:240
gnash::Function::ScopeStack
std::vector< as_object * > ScopeStack
Definition: Function.h:68
gnash::Function2::PRELOAD_SUPER
@ PRELOAD_SUPER
Bind one register to "super".
Definition: Function2.h:60
gnash::TargetGuard
Definition: Function.h:40
gnash::as_value
ActionScript value type.
Definition: as_value.h:95
gnash::Global_as::createArray
as_object * createArray()
Construct an Array.
Definition: Global_as.cpp:207
gnash::getArguments
as_object * getArguments(Function &callee, as_object &args, const fn_call &fn, as_object *caller)
Add properties to an 'arguments' object.
Definition: Function.cpp:169
VM.h
gnash::NSV::PROP_ARGUMENTS
@ PROP_ARGUMENTS
Definition: namedStrings.h:60
gnash::CallFrame::function
UserFunction & function()
Get the function for which this CallFrame provides a scope.
Definition: CallStack.h:78
gnash::fn_call::arg
const Args::value_type & arg(unsigned int n) const
Access a particular argument.
Definition: fn_call.h:194
gnash::Function::_pool
const ConstantPool * _pool
The ConstantPool in effect at time of function definition.
Definition: Function.h:144
gnash::FrameGuard
Definition: VM.h:318
gnash::as_object::vm
VM & vm() const
Return a reference to this as_object's global object.
Definition: as_object.h:205
DisplayObject.h
log.h
gnash::DisplayObject::parent
DisplayObject * parent() const
Return the parent of this DisplayObject, or NULL if the DisplayObject has no parent.
Definition: DisplayObject.h:252
fn_call.h
gnash::as_environment::get_original_target
DisplayObject * get_original_target() const
Definition: as_environment.h:77
gnash::getObject
as_object * getObject(const DisplayObject *d)
Return the as_object associated with a DisplayObject if it exists.
Definition: DisplayObject.h:1160
namedStrings.h
gnash::getSWFVersion
int getSWFVersion(const as_environment &env)
Definition: as_environment.cpp:657
gnash::Function2::DefineFunction2Flags
DefineFunction2Flags
Definition: Function2.h:46
Function.h
gnash::PoolGuard
Definition: ConstantPool.h:35
gnash::DisplayObject
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:169
gnash::action_buffer
A code segment.
Definition: action_buffer.h:50
gnash::declareLocal
void declareLocal(CallFrame &c, const ObjectURI &name)
Declare a local variable in this CallFrame.
Definition: CallStack.cpp:71
gnash::CallFrame
A CallFrame is an element of a CallStack.
Definition: CallStack.h:44
gnash::fn_call::this_ptr
as_object * this_ptr
Definition: fn_call.h:170
gnash::Function2::call
virtual as_value call(const fn_call &fn)
Dispatch.
Definition: Function2.cpp:46
gnash::Function2::setFlags
void setFlags(std::uint16_t flags)
Definition: Function2.h:90
gnash::Function2::PRELOAD_ROOT
@ PRELOAD_ROOT
Bind one register to "_root".
Definition: Function2.h:66
gnash::Function2::PRELOAD_PARENT
@ PRELOAD_PARENT
Bind one register to "_parent".
Definition: Function2.h:69
gnash::NSV::PROP_THIS
@ PROP_THIS
Definition: namedStrings.h:96
gnash::as_object::get_super
virtual as_object * get_super(const ObjectURI &fname)
Definition: as_object.cpp:445
gnash::VM::currentCall
CallFrame & currentCall()
Return the CallFrame of the currently executing function.
Definition: VM.cpp:229