2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
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.
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.
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
19 #ifndef GNASH_FUNCTION2_H
20 #define GNASH_FUNCTION2_H
24 // Forward declarations
32 /// Function2 adds extra sauce to ordinary Functions.
34 /// The Function2 was introduced in version 6 of the player. Differences from
35 /// ordinary functions are:
36 /// 1. Up to 256 local registers.
37 /// 2. Ability to suppress super, this, arguments
38 /// 3. Ability to store super, this, arguments, _global, _root, and _parent
40 class Function2
: public Function
45 enum DefineFunction2Flags
47 /// Bind one register to "this"
50 /// No "this" variable accessible by name
53 /// Bind one register to "arguments"
54 PRELOAD_ARGUMENTS
= 0x04,
56 /// No "argument" variable accessible by name
57 SUPPRESS_ARGUMENTS
= 0x08,
59 /// Bind one register to "super"
62 /// No "super" variable accessible by name
63 SUPPRESS_SUPER
= 0x20,
65 /// Bind one register to "_root"
68 /// Bind one register to "_parent"
69 PRELOAD_PARENT
= 0x80,
71 /// Bind one register to "_global"
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
);
79 virtual ~Function2() {}
81 /// Return the number of registers to allocate for this function.
82 virtual boost::uint8_t registers() const {
83 return _registerCount
;
86 void setRegisterCount(boost::uint8_t ct
) {
90 void setFlags(boost::uint16_t flags
) {
91 _function2Flags
= flags
;
95 virtual as_value
call(const fn_call
& fn
);
99 /// The number of registers required.
100 boost::uint8_t _registerCount
;
102 /// Used to control implicit arg register assignments
103 boost::uint16_t _function2Flags
;
108 } // end of gnash namespace