Gnash  0.8.10
Namespaces | Defines | Functions
Machine.cpp File Reference
#include "Machine.h"
#include "as_object.h"
#include "ClassHierarchy.h"
#include "namedStrings.h"
#include "AbcBlock.h"
#include "MultiName.h"
#include "fn_call.h"
#include "abc_function.h"
#include "VM.h"
#include "Globals.h"
#include "Global_as.h"
#include "Class.h"
#include "CodeStream.h"
#include "SWF.h"

Namespaces

namespace  gnash
 

Anonymous namespace for callbacks, local functions, event handlers etc.


namespace  gnash::abc
 

ABC-only resources for parsing and execution.


Defines

#define ENSURE_NUMBER(vte)
 ENSURE_NUMBER makes sure that the given argument is a number, calling the valueOf method if necessary -- it's a macro so that the valueOf method may be pushed if needed, and then whatever opcode asked for this will be re-entered.
#define ENSURE_OBJECT(vte)
#define ENSURE_STRING(vte)
#define ABSTRACT_COMPARE(store, rv1, rv2, truth_of_undefined)
#define ABSTRACT_TYPELATE(st, checkval, matchval)
#define JUMPIF(jtruth)

Functions

bool gnash::abc::abstractEquality (const as_value &a, const as_value &b, bool strictness_on)

Define Documentation

#define ABSTRACT_COMPARE (   store,
  rv1,
  rv2,
  truth_of_undefined 
)
Value:
{                                                                                                                                                       \
        as_value &a = rv1; /* Don't call rv1 multiple times */                                  \
        as_value &b = rv2; /* Don't call rv2 multiple times */                                  \
        if (a.ptype() == PTYPE_STRING && b.ptype() == PTYPE_STRING)                     \
        {                                                                                                                                               \
                ENSURE_STRING(a);                                                                                                       \
                ENSURE_STRING(b);                                                                                                       \
                store = a.to_string() < b.to_string();                                                          \
        }                                                                                                                                               \
        else                                                                                                                                    \
        {                                                                                                                                               \
                ENSURE_NUMBER(a);                                                                                                       \
                ENSURE_NUMBER(b);                                                                                                       \
                double ad = a.to_number(); double bd = b.to_number();                           \
                if (isNaN(ad) || isNaN(bd))                                                                                     \
                        store = truth_of_undefined;                                                                     \
                else if (isInf(ad) && ad > 0)                                                                           \
                        store = false;                                                                                                  \
                else if (isInf(bd) && bd > 0)                                                                           \
                        store = true;                                                                                                   \
                else if (isInf(bd) && bd < 0)                                                                           \
                        store = false;                                                                                                  \
                else if (isInf(ad) && ad < 0)                                                                           \
                        store = true;                                                                                                   \
                else                                                                                                                            \
                        store = ad < bd;                                                                                                \
        }                                                                                                                                               \
}

ABSTRACT_COMPARE is the abstract comparison as described in the ECMA standard. The 'truth_of_undefined' is used to specify which value should be set for NaN values. It's a macro so that calls may be pushed in the ENSURE_STRING and ENSURE_NUMBER macros.

Referenced by gnash::abc::Machine::execute().

#define ABSTRACT_TYPELATE (   st,
  checkval,
  matchval 
)
Value:
{                                                                                                                                                       \
        bool *store = &st;                                                                                                              \
        /*as_value &a = checkval;  Don't call checkval multiple times */                \
        as_value &b = matchval; /* Don't call matchval multiple times */                \
        *store = true;                                                                                                                  \
        if (b.is_object())                                                                                                              \
        {                                                                                                                                               \
                as_value v;                                                                                                                     \
                b.to_object(*_global)->get_member(NSV::INTERNAL_TYPE, &v);                                      \
                if (true) /*(!a.conforms_to(mST.find(v.to_string()))) */        \
                        *store = false;                                                                                                 \
        }                                                                                                                                               \
        else if (b.is_string())                                                                                                 \
        {                                                                                                                                               \
                if (true) /*(!a.conforms_to(mST.find(b.to_string())))   */          \
                        *store = false;                                                                                                 \
        }                                                                                                                                               \
        else                                                                                                                                    \
                *store = false;                                                                                                         \
}

NB: the stubbed but unimplemented as_value::conforms_to no longer exists, but the code is left here for later reference.

Referenced by gnash::abc::Machine::execute().

#define ENSURE_NUMBER (   vte)
Value:
{                                                                                                                                                       \
        as_value *e = &vte;                                                                                                             \
        if (e->is_object())                                                                                                             \
        {                                                                                                                                               \
                Property *b = e->to_object(*_global)->findProperty(NSV::PROP_VALUE_OF, 0);      \
                if (b)                                                                                                                          \
                {                                                                                                                                       \
                        mStream->seekTo(opStart);                                                                               \
                        pushGet(e->to_object(*_global), *e, b);                                                 \
                        break;                                                                                                                  \
                }                                                                                                                                       \
        }                                                                                                                                               \
}

ENSURE_NUMBER makes sure that the given argument is a number, calling the valueOf method if necessary -- it's a macro so that the valueOf method may be pushed if needed, and then whatever opcode asked for this will be re-entered.

Referenced by gnash::abc::Machine::execute().

#define ENSURE_OBJECT (   vte)

ENSURE_OBJECT will throw an exception if the argument isn't an object. It's a macro to match with the other ENSURE_ macros.

Referenced by gnash::abc::Machine::execute().

#define ENSURE_STRING (   vte)
Value:
{                                                                                                                                                       \
        as_value *c = &vte; /* Don't call vte multiple times */                                 \
        if (c->is_object())                                                                                                             \
        {                                                                                                                                               \
                Property *d = c->to_object(*_global)->findProperty(NSV::PROP_TO_STRING, 0);     \
                if (d)                                                                                                                          \
                {                                                                                                                                       \
                        mStream->seekTo(opStart);                                                                               \
                        pushGet(c->to_object(*_global), *c, d);                                                 \
                        break;                                                                                                                  \
                }                                                                                                                                       \
        }                                                                                                                                               \
}

ENSURE_STRING makes sure that the given argument is a string, calling the toString method if necessary -- it's a macro so that the toString may be pushed if needed, and then whatever opcode asked for this will be re-entered.

Referenced by gnash::abc::Machine::execute().

#define JUMPIF (   jtruth)
Value:
{                                                                                                                                                       \
        boost::int32_t jumpOffset = mStream->read_S24();                                                                \
        if (jtruth)                                                                                                                             \
                mStream->seekBy(jumpOffset);                                                                            \
        break;                                                                                                                                  \
}

Referenced by gnash::abc::Machine::execute().


Variable Documentation

VM::AVMVersion _ver
VM& _vm