#include <as_environment.h>
Public Types | |
| typedef std::vector < boost::intrusive_ptr < as_object > > | ScopeStack |
| A stack of objects used for variables/members lookup. | |
| typedef std::map< std::string, as_value, StringNoCaseLessThen > | Variables |
| The variables container (case-insensitive). | |
| typedef boost::intrusive_ptr < as_object > | LocalVars |
| The locals container. | |
| typedef std::vector< as_value > | Registers |
Public Member Functions | |
| as_environment () | |
| character * | get_target () |
| void | set_target (character *target) |
| character * | get_original_target () |
| void | reset_target () |
| as_value | get_variable (const std::string &varname) const |
| Return the (possibly UNDEFINED) value of the named variable. | |
| bool | del_variable_raw (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) |
| Given a path to variable, set its value. Variable name can contain path elements. | |
| void | set_variable_raw (const std::string &var, const as_value &val) |
| Given a variable name, set its value (no support for path). | |
| void | set_variable (const std::string &path, const as_value &val, const ScopeStack &scopeStack) |
| Given a path to variable, set its value. | |
| void | set_local (const std::string &varname, const as_value &val) |
| Set/initialize the value of the local variable. | |
| void | add_local (const std::string &varname, const as_value &val) |
| Add a local var with the given name and value to our current local frame. | |
| void | declare_local (const std::string &varname) |
| Create the specified local var if it doesn't exist already. | |
| void | add_local_registers (unsigned int register_count) |
| Add 'count' local registers (add space to end). | |
| size_t | num_local_registers () const |
| Return the number of local registers currently available. | |
| as_value & | local_register (boost::uint8_t n) |
| Return a reference to the Nth local register. | |
| void | set_local_register (boost::uint8_t n, as_value &val) |
| Set the Nth local register to something. | |
| as_value & | global_register (unsigned int n) |
| Return a reference to the Nth global register. | |
| void | set_global_register (boost::uint8_t n, as_value &val) |
| Set the Nth local register to something. | |
| character * | find_target (const std::string &path) const |
| Find the sprite/movie referenced by the given path. | |
| as_object * | find_object (const std::string &path, const ScopeStack *scopeStack=NULL) const |
| Find the object referenced by the given path. | |
| void | dump_stack (std::ostream &out=std::cerr) |
| Dump content of the stack to a std::ostream. | |
| void | dump_local_registers (std::ostream &out=std::cerr) const |
| Dump the local registers to a std::ostream. | |
| void | dump_global_registers (std::ostream &out=std::cerr) const |
| Dump the global registers to a std::ostream. | |
| void | dump_local_variables (std::ostream &out=std::cerr) const |
| Dump the local variables to a std::ostream. | |
| int | get_version () const |
| Return the SWF version we're running for. | |
| bool | parse_path (const std::string &var_path, as_object **target, as_value &val) |
| Try to parse a string as a variable path. | |
| CallFrame & | topCallFrame () |
| Get top element of the call stack. | |
| size_t | callStackDepth () |
| Return the depth of call stack. | |
| void | push (const as_value &val) |
| Stack access/manipulation. | |
| as_value | pop () |
| Pops an as_value off the stack top and return it. | |
| as_value & | top (size_t dist) |
| Get stack value at the given distance from top. | |
| as_value & | bottom (size_t index) |
| Get stack value at the given distance from bottom. | |
| void | drop (size_t count) |
| Drop 'count' values off the top of the stack. | |
| void | padStack (size_t offset, size_t count) |
| Insert 'count' undefined values before 'offset'. | |
| int | get_top_index () const |
| Returns index of top stack element. | |
| size_t | stack_size () const |
Static Public Member Functions | |
| static bool | parse_path (const std::string &var_path, std::string &path, std::string &var) |
Public Attributes | |
| std::vector< as_value > | m_stack |
| Stack of as_values in this environment. | |
Classes | |
| struct | CallFrame |
| class | FrameGuard |
| typedef std::vector< boost::intrusive_ptr<as_object> > gnash::as_environment::ScopeStack |
A stack of objects used for variables/members lookup.
| typedef std::map<std::string, as_value, StringNoCaseLessThen> gnash::as_environment::Variables |
The variables container (case-insensitive).
| typedef boost::intrusive_ptr<as_object> gnash::as_environment::LocalVars |
The locals container.
| typedef std::vector<as_value> gnash::as_environment::Registers |
| gnash::as_environment::as_environment | ( | ) | [inline] |
| character* gnash::as_environment::get_target | ( | ) | [inline] |
| void gnash::as_environment::set_target | ( | character * | target | ) |
| character* gnash::as_environment::get_original_target | ( | ) | [inline] |
| void gnash::as_environment::reset_target | ( | ) | [inline] |
| void gnash::as_environment::push | ( | const as_value & | val | ) | [inline] |
Stack access/manipulation.
Push a value on the stack
| 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
| as_value& gnash::as_environment::bottom | ( | size_t | index | ) | [inline] |
Get stack value at the given distance from bottom.
bottom(stack_size()-1) is actual stack top
| void gnash::as_environment::drop | ( | size_t | count | ) | [inline] |
Drop 'count' values off the top of the stack.
| void gnash::as_environment::padStack | ( | size_t | offset, | |
| size_t | count | |||
| ) |
Insert 'count' undefined values before 'offset'.
An offset of 0 will prepend the values, An offset of size() [too far] will append the values.
| int gnash::as_environment::get_top_index | ( | ) | const [inline] |
Returns index of top stack element.
| size_t gnash::as_environment::stack_size | ( | ) | const [inline] |
| as_value gnash::as_environment::get_variable | ( | const std::string & | varname | ) | const |
Return the (possibly UNDEFINED) value of the named variable.
stack access/manipulation
| 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. |
| bool gnash::as_environment::del_variable_raw | ( | const std::string & | varname, | |
| const ScopeStack & | scopeStack | |||
| ) |
Delete a variable, w/out support for the path, using a ScopeStack.
| varname | Variable name. Can 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. |
| 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.
| 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). |
| void gnash::as_environment::set_variable | ( | const std::string & | path, | |
| const as_value & | val | |||
| ) |
Given a path to variable, set its value. Variable name can contain path elements.
| path | Variable path. 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. | |
| val | The value to assign to the variable, if found. |
| void gnash::as_environment::set_variable_raw | ( | const std::string & | var, | |
| const as_value & | val | |||
| ) |
Given a variable name, set its value (no support for path).
If no variable with that name is found, a new one will be created as a member of current target.
| var | Variable name. Can not contain path elements. TODO: should be case-insensitive up to SWF6. | |
| val | The value to assign to the variable, if found. |
| 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.
| void gnash::as_environment::set_local | ( | const std::string & | varname, | |
| const as_value & | val | |||
| ) |
Set/initialize the value of the local variable.
If no *local* variable with that name is found, a new one will be created.
| varname | Variable name. Can not contain path elements. TODO: should be case-insensitive up to SWF6. | |
| val | The value to assign to the variable. |
| void gnash::as_environment::add_local | ( | const std::string & | varname, | |
| const as_value & | val | |||
| ) |
Add a local var with the given name and value to our current local frame.
Use this when you know the var doesn't exist yet, since it's faster than set_local(); e.g. when setting up args for a function.
| void gnash::as_environment::declare_local | ( | const std::string & | varname | ) |
Create the specified local var if it doesn't exist already.
| void gnash::as_environment::add_local_registers | ( | unsigned int | register_count | ) | [inline] |
Add 'count' local registers (add space to end).
Local registers are only meaningful within a function2 context.
| size_t gnash::as_environment::num_local_registers | ( | ) | const [inline] |
Return the number of local registers currently available.
Local registers are only meaningful within a function2 context.
| as_value& gnash::as_environment::local_register | ( | boost::uint8_t | n | ) | [inline] |
Return a reference to the Nth local register.
Local registers are only meaningful within a function2 context.
| void gnash::as_environment::set_local_register | ( | boost::uint8_t | n, | |
| as_value & | val | |||
| ) | [inline] |
Set the Nth local register to something.
| as_value& gnash::as_environment::global_register | ( | unsigned int | n | ) | [inline] |
Return a reference to the Nth global register.
| void gnash::as_environment::set_global_register | ( | boost::uint8_t | n, | |
| as_value & | val | |||
| ) | [inline] |
Set the Nth local register to something.
| character * gnash::as_environment::find_target | ( | const std::string & | path | ) | const |
| as_object * gnash::as_environment::find_object | ( | const std::string & | path, | |
| const ScopeStack * | scopeStack = NULL | |||
| ) | const |
| void gnash::as_environment::dump_stack | ( | std::ostream & | out = std::cerr |
) | [inline] |
Dump content of the stack to a std::ostream.
| void gnash::as_environment::dump_local_registers | ( | std::ostream & | out = std::cerr |
) | const |
Dump the local registers to a std::ostream.
NOTE that nothing will be written to the stream if NO local registers are set
| void gnash::as_environment::dump_global_registers | ( | std::ostream & | out = std::cerr |
) | const |
Dump the global registers to a std::ostream.
| void gnash::as_environment::dump_local_variables | ( | std::ostream & | out = std::cerr |
) | const |
Dump the local variables to a std::ostream.
| 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.
| bool gnash::as_environment::parse_path | ( | const std::string & | var_path, | |
| std::string & | path, | |||
| std::string & | var | |||
| ) | [static] |
See if the given variable name is actually a sprite path followed by a variable name. These come in the format:
/path/to/some/sprite/:varname
(or same thing, without the last '/')
or path.to.some.var
If that's the format, puts the path part (no colon or trailing slash) in *path, and the varname part (no colon, no dot) in *var and returns true.
If no colon or dot, returns false and leaves *path & *var alone.
TODO: return an integer: 0 not a path, 1 a slash-based path, 2 a dot-based path
| bool gnash::as_environment::parse_path | ( | const std::string & | var_path, | |
| as_object ** | target, | |||
| as_value & | val | |||
| ) |
Try to parse a string as a variable path.
Variable paths come in the form:
/path/to/some/sprite/:varname
or
/path/to/some/sprite
or path.to.some.var
If there's no dot nor colon, or if the 'path' part does not resolve to an object, this function returns false. Otherwise, true is returned and 'target' and 'val' parameters are appropriaterly set.
Note that if the parser variable name doesn't exist in the found target, the 'val' will be undefined, but no other way to tell whether the variable existed or not from the caller...
| CallFrame& gnash::as_environment::topCallFrame | ( | ) | [inline] |
Get top element of the call stack.
| size_t gnash::as_environment::callStackDepth | ( | ) | [inline] |
Return the depth of call stack.
| std::vector<as_value> gnash::as_environment::m_stack |
Stack of as_values in this environment.
1.5.4