Gnash  0.8.11dev
Namespaces | Macros | 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

 gnash
 Anonymous namespace for callbacks, local functions, event handlers etc.
 
 gnash::abc
 ABC-only resources for parsing and execution.
 

Macros

#define ENSURE_NUMBER(vte)
 
#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)
 

Macro Definition Documentation

§ ABSTRACT_COMPARE

#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; \
} \
} /* end of ABSTRACT_COMPARE */
Definition: GnashKey.h:147
bool isNaN(const T &num)
Definition: GnashNumeric.h:62
bool isInf(const T &num)
Definition: as_value.h:56
Definition: GnashKey.h:148
Definition: as_value.h:65

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().

§ ABSTRACT_TYPELATE

#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; \
} /* end of ABSTRACT_TYPELATE */
v
Definition: test.py:11
Definition: GnashKey.h:148
Definition: namedStrings.h:276

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().

§ ENSURE_NUMBER

#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; \
} \
} \
} /* end of ENSURE_NUMBER */
Definition: namedStrings.h:194
Definition: GnashKey.h:148
Definition: GnashKey.h:151

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().

§ ENSURE_OBJECT

#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().

§ ENSURE_STRING

#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; \
} \
} \
} /* end of ENSURE_STRING */
Definition: namedStrings.h:191
Definition: GnashKey.h:150
Definition: GnashKey.h:149

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().

§ JUMPIF

#define JUMPIF (   jtruth)
Value:
{ \
std::int32_t jumpOffset = mStream->read_S24(); \
if (jtruth) \
mStream->seekBy(jumpOffset); \
break; \
} /* end of JUMPIF */

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