/usr/include/gnash/vm/CallStack.h is in gnash-dev 0.8.11~git20160109-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | //
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
// Free Software Foundation, Inc
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef GNASH_VM_CALL_STACK_H
#define GNASH_VM_CALL_STACK_H
#include <vector>
#include "as_value.h"
// Forward declarations
namespace gnash {
class as_object;
struct ObjectURI;
class UserFunction;
}
namespace gnash {
/// A CallFrame is an element of a CallStack.
//
/// A CallFrame exists for the duration of a UserFunction call. NativeFunctions
/// have no call frame.
//
/// The CallFrame provides space for local registers and local variables.
/// These values are discarded when the CallFrame is destroyed at the end of
/// a function call. It provides a scope for the function's execution.
class CallFrame
{
public:
typedef std::vector<as_value> Registers;
/// Construct a CallFrame for a specific UserFunction
//
/// @param func The UserFunction to create the CallFrame for. This
/// must provide information about the amount of registers
/// to allocate.
CallFrame(UserFunction* func);
/// Copy constructor for containers
CallFrame(const CallFrame& other)
:
_locals(other._locals),
_func(other._func),
_registers(other._registers)
{}
/// Assignment operator for containers.
CallFrame& operator=(const CallFrame& other) {
_locals = other._locals;
_func = other._func;
_registers = other._registers;
return *this;
}
/// Access the local variables for this function call.
as_object& locals() {
return *_locals;
}
/// Get the function for which this CallFrame provides a scope.
UserFunction& function() {
return *_func;
}
/// Get a specific register in this CallFrame
//
/// @param i The index of the register to return.
/// @return A pointer to the value in the register or 0 if no such
/// register exists.
const as_value* getLocalRegister(size_t i) const {
if (i >= _registers.size()) return nullptr;
return &_registers[i];
}
/// Set a specific register in this CallFrame
//
/// If the register doesn't exist, nothing happens.
//
/// @param i The index of the register to set.
/// @param val The value to set the register to.
void setLocalRegister(size_t i, const as_value& val);
/// Set the number of registers for this CallFrame.
//
/// The number of registers may only be set once! This is to ensure
/// that pointers to the register values are always valid.
bool hasRegisters() const {
return !_registers.empty();
}
/// Mark all reachable resources
//
/// Reachable resources would be registers and
/// locals (expected to be empty?) and function.
void markReachableResources() const;
private:
friend std::ostream& operator<<(std::ostream&, const CallFrame&);
/// Local variables.
as_object* _locals;
UserFunction* _func;
/// Local registers.
Registers _registers;
};
/// Declare a local variable in this CallFrame
//
/// The variable is declared and set to undefined if it doesn't exist already.
//
/// @param c The CallFrame to set the variable in.
/// @param name The name of the variable to declare.
void declareLocal(CallFrame& c, const ObjectURI& name);
/// Set a local variable in this CallFrame
//
/// If the variable does not already exist, it is created.
//
/// @param c The CallFrame to set the variable in.
/// @param name The name of the variable to set.
/// @param val The value to set the variable to.
void setLocal(CallFrame& c, const ObjectURI& name, const as_value& val);
typedef std::vector<CallFrame> CallStack;
std::ostream& operator<<(std::ostream& o, const CallFrame& fr);
} // namespace gnash
#endif // GNASH_VM_CALL_STACK_H
|