Public Types | Public Member Functions

gnash::as_environment Class Reference

ActionScript execution environment. More...

#include <as_environment.h>

Collaboration diagram for gnash::as_environment:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::vector< as_object * > ScopeStack
 A stack of objects used for variables/members lookup.

Public Member Functions

 as_environment (VM &vm)
VMgetVM () const
DisplayObjectget_target () const
void set_target (DisplayObject *target)
 Set default target for timeline opcodes.
void set_original_target (DisplayObject *target)
DisplayObjectget_original_target ()
void reset_target ()
void push (const as_value &val)
 Push a value on the stack.
as_value pop ()
 Pops an as_value off the stack top and return it.
as_valuetop (size_t dist)
 Get stack value at the given distance from top.
as_valuebottom (size_t index) const
 Get stack value at the given distance from bottom.
void drop (size_t count)
 Drop 'count' values off the top of the stack.
size_t stack_size () const
bool delVariableRaw (const std::string &varname, const ScopeStack &scopeStack)
 Delete a variable, w/out support for the path, using a ScopeStack.
as_value get_variable (const std::string &varname, const ScopeStack &scopeStack, as_object **retTarget=NULL) const
 Return the (possibly UNDEFINED) value of the named var.
void set_variable (const std::string &path, const as_value &val, const ScopeStack &scopeStack)
 Given a path to variable, set its value.
void markReachableResources () const
 Mark all reachable resources.
DisplayObjectfind_target (const std::string &path) const
 Find the sprite/movie referenced by the given path.
as_objectfind_object (const std::string &path, const ScopeStack *scopeStack=0) const
 Find the object referenced by the given path.
int get_version () const
 Return the SWF version we're running for.

Detailed Description

ActionScript execution environment.


Member Typedef Documentation

A stack of objects used for variables/members lookup.


Constructor & Destructor Documentation

gnash::as_environment::as_environment ( VM vm  ) 

Member Function Documentation

as_value& gnash::as_environment::bottom ( size_t  index  )  const [inline]

Get stack value at the given distance from bottom.

bottom(stack_size()-1) is actual stack top

Throw StackException if index is out of range

References gnash::SafeStack< T >::value().

bool gnash::as_environment::delVariableRaw ( const std::string &  varname,
const ScopeStack scopeStack 
)

Delete a variable, w/out support for the path, using a ScopeStack.

Parameters:
varname Variable name. Must not contain path elements. TODO: should be case-insensitive up to SWF6. NOTE: no case conversion is performed currently, so make sure you do it yourself. Note that ActionExec performs the conversion before calling this method.
scopeStack The Scope stack to use for lookups.

Referenced by gnash::ActionExec::delVariable().

void gnash::as_environment::drop ( size_t  count  )  [inline]

Drop 'count' values off the top of the stack.

References gnash::SafeStack< T >::drop(), and gnash::SafeStack< T >::size().

Referenced by gnash::ActionExec::operator()().

as_object * gnash::as_environment::find_object ( const std::string &  path,
const ScopeStack scopeStack = 0 
) const

Find the object referenced by the given path.

Supports both /slash/syntax and dot.syntax Case insensitive for SWF up to 6, sensitive from 7 up

DisplayObject * gnash::as_environment::find_target ( const std::string &  path_in  )  const

Find the sprite/movie referenced by the given path.

Supports both /slash/syntax and dot.syntax Case insensitive for SWF up to 6, sensitive from 7 up

Supports both /slash/syntax and dot.syntax

Returns:
The found DisplayObject or 0 if it is not a DisplayObject.

References gnash::key::p.

DisplayObject* gnash::as_environment::get_original_target (  )  [inline]
DisplayObject* gnash::as_environment::get_target (  )  const [inline]
as_value gnash::as_environment::get_variable ( const std::string &  varname,
const ScopeStack scopeStack,
as_object **  retTarget = NULL 
) const

Return the (possibly UNDEFINED) value of the named var.

Parameters:
varname Variable name. Can contain path elements. TODO: should be case-insensitive up to SWF6. NOTE: no case conversion is performed currently, so make sure you do it yourself. Note that ActionExec performs the conversion before calling this method.
scopeStack The Scope stack to use for lookups.
retTarget If not NULL, the pointer will be set to the actual object containing the found variable (if found).

Referenced by gnash::ActionExec::getVariable().

int gnash::as_environment::get_version (  )  const

Return the SWF version we're running for.

NOTE: this is the version encoded in the first loaded movie, and cannot be changed during play even if replacing the root movie with an externally loaded one.

VM& gnash::as_environment::getVM (  )  const [inline]
void gnash::as_environment::markReachableResources (  )  const

Mark all reachable resources.

Reachable resources from an as_environment would be global registers, stack (expected to be empty actually), stack frames and targets (original and current).

as_value gnash::as_environment::pop (  )  [inline]

Pops an as_value off the stack top and return it.

References gnash::SafeStack< T >::pop().

void gnash::as_environment::push ( const as_value val  )  [inline]

Push a value on the stack.

References gnash::SafeStack< T >::push().

Referenced by gnash::PropertyList::enumerateKeys().

void gnash::as_environment::reset_target (  )  [inline]
void gnash::as_environment::set_original_target ( DisplayObject target  )  [inline]
void gnash::as_environment::set_target ( DisplayObject target  ) 

Set default target for timeline opcodes.

Parameters:
target A DisplayObject to apply timeline opcodes on. Zero is a valid target, disabling timeline opcodes (would get ignored).

Referenced by gnash::Function::call(), and gnash::TargetGuard::~TargetGuard().

void gnash::as_environment::set_variable ( const std::string &  path,
const as_value val,
const ScopeStack scopeStack 
)

Given a path to variable, set its value.

If no variable with that name is found, a new one is created.

For path-less variables, this would act as a proxy for set_variable_raw.

Parameters:
path Variable path. TODO: should be case-insensitive up to SWF6.
val The value to assign to the variable.
scopeStack The Scope stack to use for lookups.

Referenced by gnash::ActionExec::setLocalVariable(), and gnash::ActionExec::setVariable().

size_t gnash::as_environment::stack_size (  )  const [inline]
as_value& gnash::as_environment::top ( size_t  dist  )  [inline]

Get stack value at the given distance from top.

top(0) is actual stack top

Throw StackException if index is out of range

References gnash::SafeStack< T >::top().

Referenced by gnash::ActionExec::operator()().


The documentation for this class was generated from the following files: