Gnash
0.8.11dev
|
The AVM1 virtual machine. More...
#include <VM.h>
Public Types | |
typedef as_value(* | as_c_function_ptr) (const fn_call &fn) |
typedef boost::mt11213b | RNG |
Public Member Functions | |
VM (movie_root &root, VirtualClock &clock) | |
Initializes the VM. More... | |
~VM () | |
SafeStack< as_value > & | getStack () |
Accessor for the VM's stack. More... | |
VirtualClock & | getClock () |
Get the VM clock. More... | |
int | getSWFVersion () const |
Get SWF version context for the currently running actions. More... | |
void | setSWFVersion (int v) |
Set SWF version of the currently executing code. More... | |
unsigned long int | getTime () const |
Get the number of milliseconds since VM was started. More... | |
string_table & | getStringTable () const |
Get a reference to the string table used by the VM. More... | |
const std::string & | getPlayerVersion () const |
Get version of the player, in a compatible representation. More... | |
std::string | getOSName () const |
std::string | getSystemLanguage () const |
RNG & | randomNumberGenerator () |
movie_root & | getRoot () const |
Get a pointer to this VM's Root movie (stage) More... | |
SharedObjectLibrary & | getSharedObjectLibrary () const |
Return the Shared Object Library. More... | |
Global_as * | getGlobal () const |
Get a pointer to this VM's _global Object. More... | |
void | markReachableResources () const |
Mark all reachable resources (for GC) More... | |
void | registerNative (as_c_function_ptr fun, unsigned int x, unsigned int y) |
NativeFunction * | getNative (unsigned int x, unsigned int y) const |
Return a native function or null. More... | |
const as_value * | getRegister (size_t index) |
Get value of a register (local or global). More... | |
void | setRegister (size_t index, const as_value &val) |
Set value of a register (local or global). More... | |
CallFrame & | pushCallFrame (UserFunction &f) |
Add a function call to the call frame. More... | |
void | popCallFrame () |
Remove a function call from the call frame. More... | |
CallFrame & | currentCall () |
Return the CallFrame of the currently executing function. More... | |
bool | calling () const |
Whether a function call is in progress. More... | |
void | dumpState (std::ostream &o, size_t limit=0) |
Print stack, call stack, and registers to the specified ostream. More... | |
void | setConstantPool (const ConstantPool *pool) |
const ConstantPool * | getConstantPool () const |
The AVM1 virtual machine.
The VM class has no code for execution, but rather stores the resources needed for execution: 1. The stack
typedef boost::mt11213b gnash::VM::RNG |
gnash::VM::VM | ( | movie_root & | root, |
VirtualClock & | clock | ||
) |
Initializes the VM.
root | The movie_root that owns this VM |
clock | The clock to use for advances. |
References gnash::NSV::loadStrings(), gnash::Global_as::registerClasses(), and gnash::VirtualClock::restart().
gnash::VM::~VM | ( | ) |
|
inline |
Whether a function call is in progress.
References gnash::key::o.
Referenced by gnash::Function2::call(), gnash::Function::call(), and gnash::parsePath().
CallFrame & gnash::VM::currentCall | ( | ) |
Return the CallFrame of the currently executing function.
Callers must ensure that there is a current function before calling this!
Referenced by gnash::ActionExec::ActionExec(), gnash::Function2::call(), gnash::Function::call(), getRegister(), gnash::parsePath(), and setRegister().
void gnash::VM::dumpState | ( | std::ostream & | o, |
size_t | limit = 0 |
||
) |
Print stack, call stack, and registers to the specified ostream.
References gnash::key::e, gnash::key::i, gnash::as_value::is_undefined(), gnash::key::n, and test::v.
Referenced by gnash::ActionExec::operator()().
|
inline |
Get the VM clock.
NOTE: this clock should drive all internal operations but maybe accessing it trough VM isn't the best idea. TODO: consider making this accessible trough RunResources instead.
|
inline |
Global_as * gnash::VM::getGlobal | ( | ) | const |
Get a pointer to this VM's _global Object.
Referenced by gnash::Function2::call(), gnash::MovieLoader::clear(), gnash::doubleToString(), gnash::SWF::SymbolClassTag::executeActions(), gnash::getGlobal(), gnash::movie_root::init(), gnash::parsePath(), gnash::registerSharedObjectNative(), and gnash::movie_root::testInvariant().
NativeFunction * gnash::VM::getNative | ( | unsigned int | x, |
unsigned int | y | ||
) | const |
Return a native function or null.
References gnash::NSV::CLASS_FUNCTION, gnash::as_object::DefaultFlags, gnash::key::f, gnash::getMember(), gnash::getOwnProperty(), gnash::as_object::init_member(), gnash::PropFlags::onlySWF6Up, gnash::NSV::PROP_CONSTRUCTOR, gnash::NSV::PROP_PROTOTYPE, gnash::NSV::PROP_uuPROTOuu, and gnash::as_value::to_function().
Referenced by gnash::array_class_init(), gnash::arrayKey(), gnash::attachAsBroadcasterStaticInterface(), gnash::attachKeyInterface(), gnash::boolean_class_init(), gnash::BufferedAudioStreamer::cleanAudioQueue(), gnash::color_class_init(), gnash::externalinterface_class_init(), gnash::function_class_init(), gnash::initObjectClass(), gnash::loadvars_class_init(), gnash::Global_as::makeObject(), gnash::mouse_class_init(), gnash::moviecliploader_class_init(), gnash::number_class_init(), gnash::registerAccessibilityNative(), gnash::registerBitmapClass(), gnash::registerBitmapDataNative(), gnash::registerBooleanNative(), gnash::registerCameraNative(), gnash::Global_as::registerClasses(), gnash::registerColorTransformNative(), gnash::registerDateNative(), gnash::registerLocalConnectionNative(), gnash::registerMicrophoneNative(), gnash::registerMovieClipNative(), gnash::registerSelectionNative(), gnash::registerSharedObjectNative(), gnash::registerSoundNative(), gnash::registerSystemNative(), gnash::registerTextFieldNative(), gnash::registerVideoNative(), gnash::registerXMLNative(), gnash::registerXMLSocketNative(), gnash::string_class_init(), gnash::textformat_class_init(), and gnash::xmlnode_class_init().
std::string gnash::VM::getOSName | ( | ) | const |
Get current OS name. This is used for System.capabilites.os. If defined in gnashrc, that takes precedence. For Linux, the string includes the kernel version (unname -sr). Only works for systems with sys/utsname.h (POSIX 4.4).
References DEFAULT_FLASH_SYSTEM_OS.
Referenced by gnash::registerSystemNative().
const std::string & gnash::VM::getPlayerVersion | ( | ) | const |
Get version of the player, in a compatible representation.
This information will be used for the System.capabilities.version and $version ActionScript variables.
Referenced by gnash::MovieClip::constructAsScriptObject(), and gnash::registerSystemNative().
const as_value * gnash::VM::getRegister | ( | size_t | index | ) |
Get value of a register (local or global).
When not in a function context the selected register will be global or not at all (if index is not in the valid range of global registers).
When in a function context defining no registers, we'll behave the same as for a non-function context.
When in a function context defining non-zero number of local registers, the register set will be either local or not at all (if index is not in the valid range of local registers).
index | The index of the register to retrieve. |
References currentCall(), gnash::CallFrame::getLocalRegister(), and gnash::CallFrame::hasRegisters().
movie_root & gnash::VM::getRoot | ( | ) | const |
Get a pointer to this VM's Root movie (stage)
Referenced by gnash::SWF::SWFHandlers::execute(), gnash::getRoot(), gnash::getRunResources(), gnash::ActionExec::operator()(), pushCallFrame(), gnash::registerSystemNative(), and gnash::Gui::setInvalidatedRegions().
|
inline |
Return the Shared Object Library.
References gnash::key::f, gnash::getGlobal(), x, and y.
Referenced by gnash::registerSharedObjectNative().
Accessor for the VM's stack.
TODO: drop
Referenced by gnash::movie_root::getRegisteredClass(), gnash::movie_root::removeAdvanceCallback(), and gnash::movie_root::reset().
|
inline |
Get a reference to the string table used by the VM.
Referenced by gnash::getStringTable(), gnash::DisplayObject::getTarget(), gnash::getURI(), gnash::DisplayObject::pathElement(), and gnash::toString().
|
inline |
Get SWF version context for the currently running actions.
This information will drive operations of the virtual machine
References test::v.
Referenced by gnash::MovieLoader::clear(), gnash::convertToBoolean(), gnash::convertToNumber(), gnash::convertToPrimitive(), gnash::convertToString(), gnash::equals(), gnash::as_environment::get_version(), gnash::getSWFVersion(), gnash::newAdd(), gnash::ActionExec::operator()(), gnash::parsePath(), gnash::movie_root::processInvoke(), gnash::Gui::setInvalidatedRegions(), gnash::toBool(), gnash::toInt(), gnash::toNumber(), and gnash::NetConnection_as::update().
std::string gnash::VM::getSystemLanguage | ( | ) | const |
Return the current language of the system. This is used for System.capabilities.language. Only works for systems with a language environment variable.
Referenced by gnash::registerSystemNative().
unsigned long int gnash::VM::getTime | ( | ) | const |
Get the number of milliseconds since VM was started.
References gnash::VirtualClock::elapsed().
Referenced by gnash::movie_root::advance(), gnash::Timer::clearInterval(), gnash::movie_root::init(), gnash::movie_root::processInvoke(), gnash::registerLocalConnectionNative(), and gnash::movie_root::timeToNextFrame().
void gnash::VM::markReachableResources | ( | ) | const |
Mark all reachable resources (for GC)
References gnash::renderer::opengl::for_each(), gnash::key::i, gnash::key::n, gnash::GcResource::setReachable(), and gnash::as_value::setReachable().
Referenced by gnash::movie_root::markReachableResources().
void gnash::VM::popCallFrame | ( | ) |
Remove a function call from the call frame.
This should be called on return from the function.
CallFrame & gnash::VM::pushCallFrame | ( | UserFunction & | f | ) |
Add a function call to the call frame.
This should be called for all user-defined functions before the function is executed
References _, gnash::movie_root::getRecursionLimit(), and getRoot().
VM::RNG & gnash::VM::randomNumberGenerator | ( | ) |
Referenced by gnash::SWF::SWFHandlers::execute(), and gnash::math_class_init().
void gnash::VM::registerNative | ( | as_c_function_ptr | fun, |
unsigned int | x, | ||
unsigned int | y | ||
) |
Referenced by gnash::Global_as::makeObject(), gnash::registerAccessibilityNative(), gnash::registerArrayNative(), gnash::registerBitmapDataNative(), gnash::registerBitmapFilterNative(), gnash::registerBooleanNative(), gnash::registerButtonNative(), gnash::registerCameraNative(), gnash::registerColorNative(), gnash::registerColorTransformNative(), gnash::registerDateNative(), gnash::registerExternalInterfaceNative(), gnash::registerFunctionNative(), gnash::registerKeyNative(), gnash::registerLoadableNative(), gnash::registerLocalConnectionNative(), gnash::registerMathNative(), gnash::registerMicrophoneNative(), gnash::registerMovieClipLoaderNative(), gnash::registerMovieClipNative(), gnash::Mouse_as::registerNative(), gnash::AsBroadcaster::registerNative(), gnash::registerNetStreamNative(), gnash::registerNumberNative(), gnash::registerObjectNative(), gnash::registerSelectionNative(), gnash::registerSharedObjectNative(), gnash::registerSoundNative(), gnash::registerStageNative(), gnash::registerStringNative(), gnash::registerSystemNative(), gnash::registerTextFieldNative(), gnash::registerTextFormatNative(), gnash::registerTextSnapshotNative(), gnash::registerVideoNative(), gnash::registerXMLNative(), gnash::registerXMLNodeNative(), and gnash::registerXMLSocketNative().
|
inline |
Referenced by gnash::movie_root::getRegisteredClass(), and gnash::PoolGuard::~PoolGuard().
void gnash::VM::setRegister | ( | size_t | index, |
const as_value & | val | ||
) |
Set value of a register (local or global).
When not in a function context the set register will be global or not at all (if index is not in the valid range of global registers).
When in a function context defining no registers, we'll behave the same as for a non-function context.
When in a function context defining non-zero number of local registers, the register set will be either local or not at all (if index is not in the valid range of local registers).
index | The index of the register to set. If the index is invalid, this is a no-op. |
val | The value to set the register to. |
References _, currentCall(), gnash::CallFrame::hasRegisters(), IF_VERBOSE_ACTION, gnash::log_action(), and gnash::CallFrame::setLocalRegister().
Referenced by gnash::ActionExec::operator()().
void gnash::VM::setSWFVersion | ( | int | v | ) |
Set SWF version of the currently executing code.
References test::v.
Referenced by gnash::movie_root::init(), and gnash::ActionExec::operator()().