Add patch to fix #35635, mmap problems with a hardened kernel.
[gnash.git] / libcore / Function2.h
blob2b2160f6e36fc45fff1c03451835b1fc2bfc91c7
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
19 #ifndef GNASH_FUNCTION2_H
20 #define GNASH_FUNCTION2_H
22 #include "Function.h"
24 // Forward declarations
25 namespace gnash {
26 class action_buffer;
27 class as_object;
30 namespace gnash {
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
39 /// in registers.
40 class Function2 : public Function
43 public:
45 enum DefineFunction2Flags
47 /// Bind one register to "this"
48 PRELOAD_THIS = 0x01,
50 /// No "this" variable accessible by name
51 SUPPRESS_THIS = 0x02,
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"
60 PRELOAD_SUPER = 0x10,
62 /// No "super" variable accessible by name
63 SUPPRESS_SUPER = 0x20,
65 /// Bind one register to "_root"
66 PRELOAD_ROOT = 0x40,
68 /// Bind one register to "_parent"
69 PRELOAD_PARENT = 0x80,
71 /// Bind one register to "_global"
72 PRELOAD_GLOBAL = 256
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) {
87 _registerCount = ct;
90 void setFlags(boost::uint16_t flags) {
91 _function2Flags = flags;
94 /// Dispatch.
95 virtual as_value call(const fn_call& fn);
97 private:
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
110 #endif