mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Cleaning up all over. New Operator enumeration.
This commit is contained in:
parent
7389b14d79
commit
8ef1772c5d
@ -11,7 +11,6 @@
|
||||
BRANCH_FALSE, /* target label, condition */
|
||||
BRANCH_INITIALIZED, /* target label, condition */
|
||||
BRANCH_TRUE, /* target label, condition */
|
||||
CALL, /* result, target, args */
|
||||
CAST, /* dest, rvalue, toType */
|
||||
CLASS, /* dest, obj */
|
||||
COMPARE_EQ, /* dest, source1, source2 */
|
||||
@ -48,7 +47,7 @@
|
||||
MOVE, /* dest, source */
|
||||
MULTIPLY, /* dest, source1, source2 */
|
||||
NAME_XCR, /* dest, name, value */
|
||||
NEGATE, /* dest, source */
|
||||
NEGATE_DOUBLE, /* dest, source */
|
||||
NEW_ARRAY, /* dest */
|
||||
NEW_CLASS, /* dest, class */
|
||||
NEW_CLOSURE, /* dest, ICodeModule */
|
||||
@ -57,7 +56,7 @@
|
||||
NOP, /* do nothing and like it */
|
||||
NOT, /* dest, source */
|
||||
OR, /* dest, source1, source2 */
|
||||
POSATE, /* dest, source */
|
||||
POSATE_DOUBLE, /* dest, source */
|
||||
PROP_XCR, /* dest, source, name, value */
|
||||
REMAINDER, /* dest, source1, source2 */
|
||||
RETURN, /* return value */
|
||||
@ -179,22 +178,6 @@
|
||||
/* print() and printOperands() inherited from GenericBranch */
|
||||
};
|
||||
|
||||
class Call : public Instruction_3<TypedRegister, TypedRegister, ArgumentList*> {
|
||||
public:
|
||||
/* result, target, args */
|
||||
Call (TypedRegister aOp1, TypedRegister aOp2, ArgumentList* aOp3) :
|
||||
Instruction_3<TypedRegister, TypedRegister, ArgumentList*>
|
||||
(CALL, aOp1, aOp2, aOp3) {};
|
||||
virtual Formatter& print(Formatter& f) {
|
||||
f << opcodeNames[CALL] << "\t" << mOp1 << ", " << mOp2 << ", " << mOp3;
|
||||
return f;
|
||||
}
|
||||
virtual Formatter& printOperands(Formatter& f, const JSValues& registers) {
|
||||
f << getRegisterValue(registers, mOp1.first) << ", " << getRegisterValue(registers, mOp2.first);
|
||||
return f;
|
||||
}
|
||||
};
|
||||
|
||||
class Cast : public Instruction_3<TypedRegister, TypedRegister, TypedRegister> {
|
||||
public:
|
||||
/* dest, rvalue, toType */
|
||||
@ -370,18 +353,18 @@
|
||||
}
|
||||
};
|
||||
|
||||
class DirectCall : public Instruction_3<TypedRegister, JSFunction*, ArgumentList*> {
|
||||
class DirectCall : public Instruction_3<TypedRegister, TypedRegister, ArgumentList*> {
|
||||
public:
|
||||
/* result, target, args */
|
||||
DirectCall (TypedRegister aOp1, JSFunction* aOp2, ArgumentList* aOp3) :
|
||||
Instruction_3<TypedRegister, JSFunction*, ArgumentList*>
|
||||
DirectCall (TypedRegister aOp1, TypedRegister aOp2, ArgumentList* aOp3) :
|
||||
Instruction_3<TypedRegister, TypedRegister, ArgumentList*>
|
||||
(DIRECT_CALL, aOp1, aOp2, aOp3) {};
|
||||
virtual Formatter& print(Formatter& f) {
|
||||
f << opcodeNames[DIRECT_CALL] << "\t" << mOp1 << ", " << "JSFunction" << ", " << mOp3;
|
||||
f << opcodeNames[DIRECT_CALL] << "\t" << mOp1 << ", " << mOp2 << ", " << mOp3;
|
||||
return f;
|
||||
}
|
||||
virtual Formatter& printOperands(Formatter& f, const JSValues& registers) {
|
||||
f << getRegisterValue(registers, mOp1.first);
|
||||
f << getRegisterValue(registers, mOp1.first) << ", " << getRegisterValue(registers, mOp2.first);
|
||||
return f;
|
||||
}
|
||||
};
|
||||
@ -411,11 +394,11 @@
|
||||
}
|
||||
};
|
||||
|
||||
class GenericBinaryOP : public Instruction_4<TypedRegister, ExprNode::Kind, TypedRegister, TypedRegister> {
|
||||
class GenericBinaryOP : public Instruction_4<TypedRegister, JSTypes::Operator, TypedRegister, TypedRegister> {
|
||||
public:
|
||||
/* dest, op, source1, source2 */
|
||||
GenericBinaryOP (TypedRegister aOp1, ExprNode::Kind aOp2, TypedRegister aOp3, TypedRegister aOp4) :
|
||||
Instruction_4<TypedRegister, ExprNode::Kind, TypedRegister, TypedRegister>
|
||||
GenericBinaryOP (TypedRegister aOp1, JSTypes::Operator aOp2, TypedRegister aOp3, TypedRegister aOp4) :
|
||||
Instruction_4<TypedRegister, JSTypes::Operator, TypedRegister, TypedRegister>
|
||||
(GENERIC_BINARY_OP, aOp1, aOp2, aOp3, aOp4) {};
|
||||
virtual Formatter& print(Formatter& f) {
|
||||
f << opcodeNames[GENERIC_BINARY_OP] << "\t" << mOp1 << ", " << mOp2 << ", " << mOp3 << ", " << mOp4;
|
||||
@ -427,11 +410,11 @@
|
||||
}
|
||||
};
|
||||
|
||||
class GenericUnaryOP : public Instruction_3<TypedRegister, ExprNode::Kind, TypedRegister> {
|
||||
class GenericUnaryOP : public Instruction_3<TypedRegister, JSTypes::Operator, TypedRegister> {
|
||||
public:
|
||||
/* dest, op, source */
|
||||
GenericUnaryOP (TypedRegister aOp1, ExprNode::Kind aOp2, TypedRegister aOp3) :
|
||||
Instruction_3<TypedRegister, ExprNode::Kind, TypedRegister>
|
||||
GenericUnaryOP (TypedRegister aOp1, JSTypes::Operator aOp2, TypedRegister aOp3) :
|
||||
Instruction_3<TypedRegister, JSTypes::Operator, TypedRegister>
|
||||
(GENERIC_UNARY_OP, aOp1, aOp2, aOp3) {};
|
||||
virtual Formatter& print(Formatter& f) {
|
||||
f << opcodeNames[GENERIC_UNARY_OP] << "\t" << mOp1 << ", " << mOp2 << ", " << mOp3;
|
||||
@ -443,11 +426,11 @@
|
||||
}
|
||||
};
|
||||
|
||||
class GenericXcrementOP : public Instruction_3<TypedRegister, ExprNode::Kind, TypedRegister> {
|
||||
class GenericXcrementOP : public Instruction_3<TypedRegister, JSTypes::Operator, TypedRegister> {
|
||||
public:
|
||||
/* dest, op, source */
|
||||
GenericXcrementOP (TypedRegister aOp1, ExprNode::Kind aOp2, TypedRegister aOp3) :
|
||||
Instruction_3<TypedRegister, ExprNode::Kind, TypedRegister>
|
||||
GenericXcrementOP (TypedRegister aOp1, JSTypes::Operator aOp2, TypedRegister aOp3) :
|
||||
Instruction_3<TypedRegister, JSTypes::Operator, TypedRegister>
|
||||
(GENERIC_XCREMENT_OP, aOp1, aOp2, aOp3) {};
|
||||
virtual Formatter& print(Formatter& f) {
|
||||
f << opcodeNames[GENERIC_XCREMENT_OP] << "\t" << mOp1 << ", " << mOp2 << ", " << mOp3;
|
||||
@ -755,14 +738,14 @@
|
||||
}
|
||||
};
|
||||
|
||||
class Negate : public Instruction_2<TypedRegister, TypedRegister> {
|
||||
class NegateDouble : public Instruction_2<TypedRegister, TypedRegister> {
|
||||
public:
|
||||
/* dest, source */
|
||||
Negate (TypedRegister aOp1, TypedRegister aOp2) :
|
||||
NegateDouble (TypedRegister aOp1, TypedRegister aOp2) :
|
||||
Instruction_2<TypedRegister, TypedRegister>
|
||||
(NEGATE, aOp1, aOp2) {};
|
||||
(NEGATE_DOUBLE, aOp1, aOp2) {};
|
||||
virtual Formatter& print(Formatter& f) {
|
||||
f << opcodeNames[NEGATE] << "\t" << mOp1 << ", " << mOp2;
|
||||
f << opcodeNames[NEGATE_DOUBLE] << "\t" << mOp1 << ", " << mOp2;
|
||||
return f;
|
||||
}
|
||||
virtual Formatter& printOperands(Formatter& f, const JSValues& registers) {
|
||||
@ -891,14 +874,14 @@
|
||||
/* print() and printOperands() inherited from Arithmetic */
|
||||
};
|
||||
|
||||
class Posate : public Instruction_2<TypedRegister, TypedRegister> {
|
||||
class PosateDouble : public Instruction_2<TypedRegister, TypedRegister> {
|
||||
public:
|
||||
/* dest, source */
|
||||
Posate (TypedRegister aOp1, TypedRegister aOp2) :
|
||||
PosateDouble (TypedRegister aOp1, TypedRegister aOp2) :
|
||||
Instruction_2<TypedRegister, TypedRegister>
|
||||
(POSATE, aOp1, aOp2) {};
|
||||
(POSATE_DOUBLE, aOp1, aOp2) {};
|
||||
virtual Formatter& print(Formatter& f) {
|
||||
f << opcodeNames[POSATE] << "\t" << mOp1 << ", " << mOp2;
|
||||
f << opcodeNames[POSATE_DOUBLE] << "\t" << mOp1 << ", " << mOp2;
|
||||
return f;
|
||||
}
|
||||
virtual Formatter& printOperands(Formatter& f, const JSValues& registers) {
|
||||
@ -1303,7 +1286,6 @@
|
||||
"BRANCH_FALSE ",
|
||||
"BRANCH_INITIALIZED ",
|
||||
"BRANCH_TRUE ",
|
||||
"CALL ",
|
||||
"CAST ",
|
||||
"CLASS ",
|
||||
"COMPARE_EQ ",
|
||||
@ -1340,7 +1322,7 @@
|
||||
"MOVE ",
|
||||
"MULTIPLY ",
|
||||
"NAME_XCR ",
|
||||
"NEGATE ",
|
||||
"NEGATE_DOUBLE ",
|
||||
"NEW_ARRAY ",
|
||||
"NEW_CLASS ",
|
||||
"NEW_CLOSURE ",
|
||||
@ -1349,7 +1331,7 @@
|
||||
"NOP ",
|
||||
"NOT ",
|
||||
"OR ",
|
||||
"POSATE ",
|
||||
"POSATE_DOUBLE ",
|
||||
"PROP_XCR ",
|
||||
"REMAINDER ",
|
||||
"RETURN ",
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -481,7 +481,7 @@ TypedRegister ICodeGenerator::op(ICodeOp op, TypedRegister source1,
|
||||
return dest;
|
||||
}
|
||||
|
||||
TypedRegister ICodeGenerator::binaryOp(ICodeOp op, TypedRegister source1,
|
||||
TypedRegister ICodeGenerator::binaryOp(ICodeOp dblOp, JSTypes::Operator op, TypedRegister source1,
|
||||
TypedRegister source2)
|
||||
{
|
||||
ASSERT(source1.first != NotARegister);
|
||||
@ -489,30 +489,28 @@ TypedRegister ICodeGenerator::binaryOp(ICodeOp op, TypedRegister source1,
|
||||
TypedRegister dest(getTempRegister(), &Any_Type);
|
||||
|
||||
if ((source1.second == &Number_Type) && (source2.second == &Number_Type)) {
|
||||
Arithmetic *instr = new Arithmetic(op, dest, source1, source2);
|
||||
Arithmetic *instr = new Arithmetic(dblOp, dest, source1, source2);
|
||||
iCode->push_back(instr);
|
||||
}
|
||||
else {
|
||||
GenericBinaryOP *instr = new GenericBinaryOP(dest, mapICodeOpToExprNode(op), source1, source2);
|
||||
GenericBinaryOP *instr = new GenericBinaryOP(dest, op, source1, source2);
|
||||
iCode->push_back(instr);
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
TypedRegister ICodeGenerator::unaryOp(ICodeOp op, TypedRegister source)
|
||||
TypedRegister ICodeGenerator::unaryOp(JSTypes::Operator op, TypedRegister source)
|
||||
{
|
||||
TypedRegister dest(getTempRegister(), &Any_Type);
|
||||
GenericUnaryOP *instr = new GenericUnaryOP(dest, mapICodeOpToExprNode(op), source);
|
||||
GenericUnaryOP *instr = new GenericUnaryOP(dest, op, source);
|
||||
iCode->push_back(instr);
|
||||
return dest;
|
||||
}
|
||||
|
||||
TypedRegister ICodeGenerator::xcrementOp(ICodeOp op, TypedRegister source)
|
||||
TypedRegister ICodeGenerator::xcrementOp(JSTypes::Operator op, TypedRegister source)
|
||||
{
|
||||
TypedRegister dest(getTempRegister(), &Any_Type);
|
||||
GenericXcrementOP *instr = new GenericXcrementOP(dest,
|
||||
(op == ADD) ? ExprNode::preIncrement : ExprNode::preDecrement,
|
||||
source);
|
||||
GenericXcrementOP *instr = new GenericXcrementOP(dest, op, source);
|
||||
iCode->push_back(instr);
|
||||
return dest;
|
||||
}
|
||||
@ -520,7 +518,7 @@ TypedRegister ICodeGenerator::xcrementOp(ICodeOp op, TypedRegister source)
|
||||
TypedRegister ICodeGenerator::call(TypedRegister target, ArgumentList *args)
|
||||
{
|
||||
TypedRegister dest(getTempRegister(), &Any_Type);
|
||||
Call *instr = new Call(dest, target, args);
|
||||
DirectCall *instr = new DirectCall(dest, target, args);
|
||||
iCode->push_back(instr);
|
||||
return dest;
|
||||
}
|
||||
@ -532,7 +530,7 @@ TypedRegister ICodeGenerator::invokeCallOp(TypedRegister target, ArgumentList *a
|
||||
iCode->push_back(instr);
|
||||
return dest;
|
||||
}
|
||||
|
||||
/*
|
||||
TypedRegister ICodeGenerator::directCall(JSFunction *target, ArgumentList *args)
|
||||
{
|
||||
TypedRegister dest(getTempRegister(), &Any_Type);
|
||||
@ -540,7 +538,7 @@ TypedRegister ICodeGenerator::directCall(JSFunction *target, ArgumentList *args)
|
||||
iCode->push_back(instr);
|
||||
return dest;
|
||||
}
|
||||
|
||||
*/
|
||||
TypedRegister ICodeGenerator::bindThis(TypedRegister thisArg, TypedRegister target)
|
||||
{
|
||||
TypedRegister dest(getTempRegister(), &Function_Type);
|
||||
|
@ -51,6 +51,10 @@ namespace ICG {
|
||||
using namespace JSTypes;
|
||||
using namespace JSClasses;
|
||||
|
||||
// forward declarations of classes in this header
|
||||
class ICodeGenerator;
|
||||
class ICodeModule;
|
||||
|
||||
|
||||
struct VariableList { // Maps from variable (parameter) name to a TypedRegister.
|
||||
// But because we also want to map from a register number to
|
||||
@ -123,9 +127,8 @@ namespace ICG {
|
||||
|
||||
};
|
||||
|
||||
typedef enum { NoKind, Var, Property, Slot, Static, Constructor, Name, Method, ClosureVar } LValueKind;
|
||||
|
||||
class ICodeGenerator;
|
||||
typedef enum { NoKind, Var, Property, Slot, Static, Constructor, Name, Method, ClosureVar } LValueKind;
|
||||
|
||||
class Reference {
|
||||
public:
|
||||
@ -146,10 +149,6 @@ namespace ICG {
|
||||
TypedRegister getCallTarget(ICodeGenerator *icg);
|
||||
};
|
||||
|
||||
class ICodeModule;
|
||||
|
||||
typedef std::map<uint32, uint32, std::less<uint32> > InstructionMap;
|
||||
|
||||
typedef std::vector<const StringAtom *> LabelSet;
|
||||
class LabelEntry {
|
||||
public:
|
||||
@ -166,8 +165,9 @@ namespace ICG {
|
||||
};
|
||||
typedef std::vector<LabelEntry *> LabelStack;
|
||||
|
||||
Formatter& operator<<(Formatter &f, ICodeModule &i);
|
||||
|
||||
typedef std::map<uint32, uint32, std::less<uint32> > InstructionMap;
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
// An ICodeGenerator provides the interface between the parser and the
|
||||
@ -246,9 +246,6 @@ namespace ICG {
|
||||
|
||||
void startStatement(uint32 pos) { (*mInstructionMap)[iCode->size()] = pos; }
|
||||
|
||||
ICodeOp mapExprNodeToICodeOp(ExprNode::Kind kind);
|
||||
ExprNode::Kind mapICodeOpToExprNode(ICodeOp op);
|
||||
|
||||
bool isTopLevel() { return (mFlags & kIsTopLevel) != 0; }
|
||||
bool isWithinWith() { return (mFlags & kIsWithinWith) != 0; }
|
||||
bool isStaticMethod() { return (mFlags & kIsStaticMethod) != 0; }
|
||||
@ -258,11 +255,10 @@ namespace ICG {
|
||||
bool getVariableByName(const StringAtom &name, Reference &ref);
|
||||
bool scanForVariable(const StringAtom &name, Reference &ref);
|
||||
bool resolveIdentifier(const StringAtom &name, Reference &ref, bool lvalue);
|
||||
// TypedRegister handleIdentifier(IdentifierExprNode *p, ExprNode::Kind use, ICodeOp xcrementOp, TypedRegister ret, ArgumentList *args, bool lvalue);
|
||||
// TypedRegister handleDot(BinaryExprNode *b, ExprNode::Kind use, ICodeOp xcrementOp, TypedRegister ret, ArgumentList *args, bool lvalue);
|
||||
ICodeModule *genFunction(FunctionDefinition &function, bool isStatic, bool isConstructor, JSClass *superClass);
|
||||
|
||||
Reference genReference(ExprNode *p);
|
||||
Operator getOperator(uint32 parameterCount, String &name);
|
||||
|
||||
ICodeModule *readFunction(XMLNode *element, JSClass *thisClass);
|
||||
|
||||
@ -336,12 +332,12 @@ namespace ICG {
|
||||
|
||||
TypedRegister op(ICodeOp op, TypedRegister source);
|
||||
TypedRegister op(ICodeOp op, TypedRegister source1, TypedRegister source2);
|
||||
TypedRegister binaryOp(ICodeOp op, TypedRegister source1, TypedRegister source2);
|
||||
TypedRegister unaryOp(ICodeOp op, TypedRegister source);
|
||||
TypedRegister binaryOp(ICodeOp dblOp, JSTypes::Operator op, TypedRegister source1, TypedRegister source2);
|
||||
TypedRegister unaryOp(JSTypes::Operator op, TypedRegister source);
|
||||
TypedRegister invokeCallOp(TypedRegister target, ArgumentList *args);
|
||||
TypedRegister xcrementOp(ICodeOp op, TypedRegister source);
|
||||
TypedRegister xcrementOp(JSTypes::Operator op, TypedRegister source);
|
||||
TypedRegister call(TypedRegister target, ArgumentList *args);
|
||||
TypedRegister directCall(JSFunction *target, ArgumentList *args);
|
||||
// TypedRegister directCall(JSFunction *target, ArgumentList *args);
|
||||
TypedRegister bindThis(TypedRegister thisArg, TypedRegister target);
|
||||
TypedRegister getMethod(TypedRegister thisArg, uint32 slotIndex);
|
||||
TypedRegister getClosure(uint32 count);
|
||||
@ -395,10 +391,6 @@ namespace ICG {
|
||||
|
||||
};
|
||||
|
||||
Formatter& operator<<(Formatter &f, ICodeGenerator &i);
|
||||
Formatter& operator<<(Formatter &f, ICodeModule &i);
|
||||
Formatter& operator<<(Formatter &f, std::string &s);
|
||||
|
||||
class ICodeModule {
|
||||
public:
|
||||
ICodeModule(InstructionStream *iCode, VariableList *variables,
|
||||
@ -456,6 +448,10 @@ namespace ICG {
|
||||
|
||||
};
|
||||
|
||||
Formatter& operator<<(Formatter &f, ICodeGenerator &i);
|
||||
Formatter& operator<<(Formatter &f, ICodeModule &i);
|
||||
Formatter& operator<<(Formatter &f, std::string &s);
|
||||
|
||||
|
||||
|
||||
} /* namespace IGC */
|
||||
|
@ -45,7 +45,7 @@
|
||||
namespace JavaScript {
|
||||
namespace ICodeASM {
|
||||
|
||||
static uint icodemap_size = 82;
|
||||
static uint icodemap_size = 81;
|
||||
|
||||
static struct {
|
||||
char *name;
|
||||
@ -59,7 +59,6 @@ namespace ICodeASM {
|
||||
{"BRANCH_FALSE", {otLabel, otRegister}},
|
||||
{"BRANCH_INITIALIZED", {otLabel, otRegister}},
|
||||
{"BRANCH_TRUE", {otLabel, otRegister}},
|
||||
{"CALL", {otRegister, otRegister, otArgumentList}},
|
||||
{"CAST", {otRegister, otRegister, otRegister}},
|
||||
{"CLASS", {otRegister, otRegister}},
|
||||
{"COMPARE_EQ", {otRegister, otRegister, otRegister}},
|
||||
@ -71,12 +70,12 @@ namespace ICodeASM {
|
||||
{"COMPARE_NE", {otRegister, otRegister, otRegister}},
|
||||
{"DEBUGGER", {otNone}},
|
||||
{"DELETE_PROP", {otRegister, otRegister, otStringAtom}},
|
||||
{"DIRECT_CALL", {otRegister, otJSFunction, otArgumentList}},
|
||||
{"DIRECT_CALL", {otRegister, otRegister, otArgumentList}},
|
||||
{"DIVIDE", {otRegister, otRegister, otRegister}},
|
||||
{"ELEM_XCR", {otRegister, otRegister, otRegister, otDouble}},
|
||||
{"GENERIC_BINARY_OP", {otRegister, otExprNodeKind, otRegister, otRegister}},
|
||||
{"GENERIC_UNARY_OP", {otRegister, otExprNodeKind, otRegister}},
|
||||
{"GENERIC_XCREMENT_OP", {otRegister, otExprNodeKind, otRegister}},
|
||||
{"GENERIC_BINARY_OP", {otRegister, otJSTypesOperator, otRegister, otRegister}},
|
||||
{"GENERIC_UNARY_OP", {otRegister, otJSTypesOperator, otRegister}},
|
||||
{"GENERIC_XCREMENT_OP", {otRegister, otJSTypesOperator, otRegister}},
|
||||
{"GET_CLOSURE", {otRegister, otUInt32}},
|
||||
{"GET_ELEMENT", {otRegister, otRegister, otRegister}},
|
||||
{"GET_METHOD", {otRegister, otRegister, otUInt32}},
|
||||
@ -96,7 +95,7 @@ namespace ICodeASM {
|
||||
{"MOVE", {otRegister, otRegister}},
|
||||
{"MULTIPLY", {otRegister, otRegister, otRegister}},
|
||||
{"NAME_XCR", {otRegister, otStringAtom, otDouble}},
|
||||
{"NEGATE", {otRegister, otRegister}},
|
||||
{"NEGATE_DOUBLE", {otRegister, otRegister}},
|
||||
{"NEW_ARRAY", {otRegister}},
|
||||
{"NEW_CLASS", {otRegister, otJSClass}},
|
||||
{"NEW_CLOSURE", {otRegister, otICodeModule}},
|
||||
@ -105,7 +104,7 @@ namespace ICodeASM {
|
||||
{"NOP", {otNone}},
|
||||
{"NOT", {otRegister, otRegister}},
|
||||
{"OR", {otRegister, otRegister, otRegister}},
|
||||
{"POSATE", {otRegister, otRegister}},
|
||||
{"POSATE_DOUBLE", {otRegister, otRegister}},
|
||||
{"PROP_XCR", {otRegister, otRegister, otStringAtom, otDouble}},
|
||||
{"REMAINDER", {otRegister, otRegister, otRegister}},
|
||||
{"RETURN", {otRegister}},
|
||||
@ -168,225 +167,222 @@ namespace ICodeASM {
|
||||
i = new BranchTrue (reinterpret_cast<Label*>(node->operand[0].data), TypedRegister(static_cast<Register>(node->operand[1].data), 0));
|
||||
break;
|
||||
case 8:
|
||||
i = new Call (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), reinterpret_cast<ArgumentList*>(node->operand[2].data));
|
||||
break;
|
||||
case 9:
|
||||
i = new Cast (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 10:
|
||||
case 9:
|
||||
i = new Class (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0));
|
||||
break;
|
||||
case 11:
|
||||
case 10:
|
||||
i = new CompareEQ (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 12:
|
||||
case 11:
|
||||
i = new CompareGE (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 13:
|
||||
case 12:
|
||||
i = new CompareGT (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 14:
|
||||
case 13:
|
||||
i = new CompareIN (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 15:
|
||||
case 14:
|
||||
i = new CompareLE (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 16:
|
||||
case 15:
|
||||
i = new CompareLT (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 17:
|
||||
case 16:
|
||||
i = new CompareNE (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 18:
|
||||
case 17:
|
||||
i = new Debugger ();
|
||||
break;
|
||||
case 19:
|
||||
case 18:
|
||||
i = new DeleteProp (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), reinterpret_cast<const StringAtom*>(node->operand[2].data));
|
||||
break;
|
||||
case 20:
|
||||
i = new DirectCall (TypedRegister(static_cast<Register>(node->operand[0].data), 0), reinterpret_cast<JSFunction*>(node->operand[1].data), reinterpret_cast<ArgumentList*>(node->operand[2].data));
|
||||
case 19:
|
||||
i = new DirectCall (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), reinterpret_cast<ArgumentList*>(node->operand[2].data));
|
||||
break;
|
||||
case 21:
|
||||
case 20:
|
||||
i = new Divide (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 22:
|
||||
case 21:
|
||||
i = new ElemXcr (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0), static_cast<double>(node->operand[3].data));
|
||||
break;
|
||||
case 22:
|
||||
i = new GenericBinaryOP (TypedRegister(static_cast<Register>(node->operand[0].data), 0), static_cast<JSTypes::Operator>(node->operand[1].data), TypedRegister(static_cast<Register>(node->operand[2].data), 0), TypedRegister(static_cast<Register>(node->operand[3].data), 0));
|
||||
break;
|
||||
case 23:
|
||||
i = new GenericBinaryOP (TypedRegister(static_cast<Register>(node->operand[0].data), 0), static_cast<ExprNode::Kind>(node->operand[1].data), TypedRegister(static_cast<Register>(node->operand[2].data), 0), TypedRegister(static_cast<Register>(node->operand[3].data), 0));
|
||||
i = new GenericUnaryOP (TypedRegister(static_cast<Register>(node->operand[0].data), 0), static_cast<JSTypes::Operator>(node->operand[1].data), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 24:
|
||||
i = new GenericUnaryOP (TypedRegister(static_cast<Register>(node->operand[0].data), 0), static_cast<ExprNode::Kind>(node->operand[1].data), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
i = new GenericXcrementOP (TypedRegister(static_cast<Register>(node->operand[0].data), 0), static_cast<JSTypes::Operator>(node->operand[1].data), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 25:
|
||||
i = new GenericXcrementOP (TypedRegister(static_cast<Register>(node->operand[0].data), 0), static_cast<ExprNode::Kind>(node->operand[1].data), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 26:
|
||||
i = new GetClosure (TypedRegister(static_cast<Register>(node->operand[0].data), 0), static_cast<uint32>(node->operand[1].data));
|
||||
break;
|
||||
case 27:
|
||||
case 26:
|
||||
i = new GetElement (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 28:
|
||||
case 27:
|
||||
i = new GetMethod (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), static_cast<uint32>(node->operand[2].data));
|
||||
break;
|
||||
case 29:
|
||||
case 28:
|
||||
i = new GetProp (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), reinterpret_cast<const StringAtom*>(node->operand[2].data));
|
||||
break;
|
||||
case 30:
|
||||
case 29:
|
||||
i = new GetSlot (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), static_cast<uint32>(node->operand[2].data));
|
||||
break;
|
||||
case 31:
|
||||
case 30:
|
||||
i = new GetStatic (TypedRegister(static_cast<Register>(node->operand[0].data), 0), reinterpret_cast<JSClass*>(node->operand[1].data), static_cast<uint32>(node->operand[2].data));
|
||||
break;
|
||||
case 32:
|
||||
case 31:
|
||||
i = new Instanceof (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 33:
|
||||
case 32:
|
||||
i = new InvokeCall (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), reinterpret_cast<ArgumentList*>(node->operand[2].data));
|
||||
break;
|
||||
case 34:
|
||||
case 33:
|
||||
i = new Jsr (reinterpret_cast<Label*>(node->operand[0].data));
|
||||
break;
|
||||
case 35:
|
||||
case 34:
|
||||
i = new LoadFalse (TypedRegister(static_cast<Register>(node->operand[0].data), 0));
|
||||
break;
|
||||
case 36:
|
||||
case 35:
|
||||
i = new LoadImmediate (TypedRegister(static_cast<Register>(node->operand[0].data), 0), static_cast<double>(node->operand[1].data));
|
||||
break;
|
||||
case 37:
|
||||
case 36:
|
||||
i = new LoadName (TypedRegister(static_cast<Register>(node->operand[0].data), 0), reinterpret_cast<const StringAtom*>(node->operand[1].data));
|
||||
break;
|
||||
case 38:
|
||||
case 37:
|
||||
i = new LoadNull (TypedRegister(static_cast<Register>(node->operand[0].data), 0));
|
||||
break;
|
||||
case 39:
|
||||
case 38:
|
||||
i = new LoadString (TypedRegister(static_cast<Register>(node->operand[0].data), 0), reinterpret_cast<JSString*>(node->operand[1].data));
|
||||
break;
|
||||
case 40:
|
||||
case 39:
|
||||
i = new LoadTrue (TypedRegister(static_cast<Register>(node->operand[0].data), 0));
|
||||
break;
|
||||
case 41:
|
||||
case 40:
|
||||
i = new LoadType (TypedRegister(static_cast<Register>(node->operand[0].data), 0), reinterpret_cast<JSType*>(node->operand[1].data));
|
||||
break;
|
||||
case 42:
|
||||
case 41:
|
||||
i = new Move (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0));
|
||||
break;
|
||||
case 43:
|
||||
case 42:
|
||||
i = new Multiply (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 44:
|
||||
case 43:
|
||||
i = new NameXcr (TypedRegister(static_cast<Register>(node->operand[0].data), 0), reinterpret_cast<const StringAtom*>(node->operand[1].data), static_cast<double>(node->operand[2].data));
|
||||
break;
|
||||
case 45:
|
||||
i = new Negate (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0));
|
||||
case 44:
|
||||
i = new NegateDouble (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0));
|
||||
break;
|
||||
case 46:
|
||||
case 45:
|
||||
i = new NewArray (TypedRegister(static_cast<Register>(node->operand[0].data), 0));
|
||||
break;
|
||||
case 47:
|
||||
case 46:
|
||||
i = new NewClass (TypedRegister(static_cast<Register>(node->operand[0].data), 0), reinterpret_cast<JSClass*>(node->operand[1].data));
|
||||
break;
|
||||
case 48:
|
||||
case 47:
|
||||
i = new NewClosure (TypedRegister(static_cast<Register>(node->operand[0].data), 0), reinterpret_cast<ICodeModule*>(node->operand[1].data));
|
||||
break;
|
||||
case 49:
|
||||
case 48:
|
||||
i = new NewFunction (TypedRegister(static_cast<Register>(node->operand[0].data), 0), reinterpret_cast<ICodeModule*>(node->operand[1].data));
|
||||
break;
|
||||
case 50:
|
||||
case 49:
|
||||
i = new NewObject (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0));
|
||||
break;
|
||||
case 51:
|
||||
case 50:
|
||||
i = new Nop ();
|
||||
break;
|
||||
case 52:
|
||||
case 51:
|
||||
i = new Not (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0));
|
||||
break;
|
||||
case 53:
|
||||
case 52:
|
||||
i = new Or (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 54:
|
||||
i = new Posate (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0));
|
||||
case 53:
|
||||
i = new PosateDouble (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0));
|
||||
break;
|
||||
case 55:
|
||||
case 54:
|
||||
i = new PropXcr (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), reinterpret_cast<const StringAtom*>(node->operand[2].data), static_cast<double>(node->operand[3].data));
|
||||
break;
|
||||
case 56:
|
||||
case 55:
|
||||
i = new Remainder (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 57:
|
||||
case 56:
|
||||
i = new Return (TypedRegister(static_cast<Register>(node->operand[0].data), 0));
|
||||
break;
|
||||
case 58:
|
||||
case 57:
|
||||
i = new ReturnVoid ();
|
||||
break;
|
||||
case 59:
|
||||
case 58:
|
||||
i = new Rts ();
|
||||
break;
|
||||
case 60:
|
||||
case 59:
|
||||
i = new SaveName (reinterpret_cast<const StringAtom*>(node->operand[0].data), TypedRegister(static_cast<Register>(node->operand[1].data), 0));
|
||||
break;
|
||||
case 61:
|
||||
case 60:
|
||||
i = new SetElement (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 62:
|
||||
case 61:
|
||||
i = new SetProp (TypedRegister(static_cast<Register>(node->operand[0].data), 0), reinterpret_cast<const StringAtom*>(node->operand[1].data), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 63:
|
||||
case 62:
|
||||
i = new SetSlot (TypedRegister(static_cast<Register>(node->operand[0].data), 0), static_cast<uint32>(node->operand[1].data), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 64:
|
||||
case 63:
|
||||
i = new SetStatic (reinterpret_cast<JSClass*>(node->operand[0].data), static_cast<uint32>(node->operand[1].data), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 65:
|
||||
case 64:
|
||||
i = new Shiftleft (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 66:
|
||||
case 65:
|
||||
i = new Shiftright (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 67:
|
||||
case 66:
|
||||
i = new SlotXcr (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), static_cast<uint32>(node->operand[2].data), static_cast<double>(node->operand[3].data));
|
||||
break;
|
||||
case 68:
|
||||
case 67:
|
||||
i = new StaticXcr (TypedRegister(static_cast<Register>(node->operand[0].data), 0), reinterpret_cast<JSClass*>(node->operand[1].data), static_cast<uint32>(node->operand[2].data), static_cast<double>(node->operand[3].data));
|
||||
break;
|
||||
case 69:
|
||||
case 68:
|
||||
i = new StrictEQ (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 70:
|
||||
case 69:
|
||||
i = new StrictNE (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 71:
|
||||
case 70:
|
||||
i = new Subtract (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 72:
|
||||
case 71:
|
||||
i = new Super (TypedRegister(static_cast<Register>(node->operand[0].data), 0));
|
||||
break;
|
||||
case 73:
|
||||
case 72:
|
||||
i = new Test (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0));
|
||||
break;
|
||||
case 74:
|
||||
case 73:
|
||||
i = new Throw (TypedRegister(static_cast<Register>(node->operand[0].data), 0));
|
||||
break;
|
||||
case 75:
|
||||
case 74:
|
||||
i = new Tryin (reinterpret_cast<Label*>(node->operand[0].data), reinterpret_cast<Label*>(node->operand[1].data));
|
||||
break;
|
||||
case 76:
|
||||
case 75:
|
||||
i = new Tryout ();
|
||||
break;
|
||||
case 77:
|
||||
case 76:
|
||||
i = new Ushiftright (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
case 78:
|
||||
case 77:
|
||||
i = new VarXcr (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), static_cast<double>(node->operand[2].data));
|
||||
break;
|
||||
case 79:
|
||||
case 78:
|
||||
i = new Within (TypedRegister(static_cast<Register>(node->operand[0].data), 0));
|
||||
break;
|
||||
case 80:
|
||||
case 79:
|
||||
i = new Without ();
|
||||
break;
|
||||
case 81:
|
||||
case 80:
|
||||
i = new Xor (TypedRegister(static_cast<Register>(node->operand[0].data), 0), TypedRegister(static_cast<Register>(node->operand[1].data), 0), TypedRegister(static_cast<Register>(node->operand[2].data), 0));
|
||||
break;
|
||||
|
||||
|
@ -456,36 +456,36 @@ void Context::initContext()
|
||||
|
||||
}
|
||||
|
||||
static JSFunction *getDefaultFunction(ExprNode::Kind op)
|
||||
static JSFunction *getDefaultFunction(JSTypes::Operator op)
|
||||
{
|
||||
switch (op) {
|
||||
case ExprNode::add: return new JSBinaryOperator(add_Default);
|
||||
case ExprNode::subtract: return new JSBinaryOperator(subtract_Default);
|
||||
case ExprNode::multiply: return new JSBinaryOperator(multiply_Default);
|
||||
case ExprNode::divide: return new JSBinaryOperator(divide_Default);
|
||||
case ExprNode::modulo: return new JSBinaryOperator(remainder_Default);
|
||||
case ExprNode::leftShift: return new JSBinaryOperator(shiftLeft_Default);
|
||||
case ExprNode::rightShift: return new JSBinaryOperator(shiftRight_Default);
|
||||
case ExprNode::logicalRightShift: return new JSBinaryOperator(UshiftRight_Default);
|
||||
case ExprNode::bitwiseOr: return new JSBinaryOperator(or_Default);
|
||||
case ExprNode::bitwiseXor: return new JSBinaryOperator(xor_Default);
|
||||
case ExprNode::bitwiseAnd: return new JSBinaryOperator(and_Default);
|
||||
case ExprNode::lessThan: return new JSBinaryOperator(less_Default);
|
||||
case ExprNode::lessThanOrEqual: return new JSBinaryOperator(lessOrEqual_Default);
|
||||
case ExprNode::equal: return new JSBinaryOperator(equal_Default);
|
||||
case ExprNode::identical: return new JSBinaryOperator(identical_Default);
|
||||
case ExprNode::preDecrement: return new JSUnaryOperator(predecrement_Default);
|
||||
case ExprNode::preIncrement: return new JSUnaryOperator(preincrement_Default);
|
||||
case ExprNode::plus: return new JSUnaryOperator(plus_Default);
|
||||
case ExprNode::minus: return new JSUnaryOperator(minus_Default);
|
||||
case ExprNode::complement: return new JSUnaryOperator(complement_Default);
|
||||
case JSTypes::Plus: return new JSBinaryOperator(add_Default);
|
||||
case JSTypes::Minus: return new JSBinaryOperator(subtract_Default);
|
||||
case JSTypes::Multiply: return new JSBinaryOperator(multiply_Default);
|
||||
case JSTypes::Divide: return new JSBinaryOperator(divide_Default);
|
||||
case JSTypes::Remainder: return new JSBinaryOperator(remainder_Default);
|
||||
case JSTypes::ShiftLeft: return new JSBinaryOperator(shiftLeft_Default);
|
||||
case JSTypes::ShiftRight: return new JSBinaryOperator(shiftRight_Default);
|
||||
case JSTypes::UShiftRight: return new JSBinaryOperator(UshiftRight_Default);
|
||||
case JSTypes::BitOr: return new JSBinaryOperator(or_Default);
|
||||
case JSTypes::BitXor: return new JSBinaryOperator(xor_Default);
|
||||
case JSTypes::BitAnd: return new JSBinaryOperator(and_Default);
|
||||
case JSTypes::Less: return new JSBinaryOperator(less_Default);
|
||||
case JSTypes::LessEqual: return new JSBinaryOperator(lessOrEqual_Default);
|
||||
case JSTypes::Equal: return new JSBinaryOperator(equal_Default);
|
||||
case JSTypes::SpittingImage: return new JSBinaryOperator(identical_Default);
|
||||
case JSTypes::Decrement: return new JSUnaryOperator(predecrement_Default);
|
||||
case JSTypes::Increment: return new JSUnaryOperator(preincrement_Default);
|
||||
case JSTypes::Posate: return new JSUnaryOperator(plus_Default);
|
||||
case JSTypes::Negate: return new JSUnaryOperator(minus_Default);
|
||||
case JSTypes::Complement: return new JSUnaryOperator(complement_Default);
|
||||
default:
|
||||
NOT_REACHED("bad op");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
const JSValue Context::findUnaryOverride(JSValue &operand1, ExprNode::Kind op)
|
||||
const JSValue Context::findUnaryOverride(JSValue &operand1, JSTypes::Operator op)
|
||||
{
|
||||
JSClass *class1 = operand1.isObject() ? dynamic_cast<JSClass*>(operand1.object->getType()) : NULL;
|
||||
if (class1) {
|
||||
@ -496,7 +496,7 @@ const JSValue Context::findUnaryOverride(JSValue &operand1, ExprNode::Kind op)
|
||||
return JSValue(getDefaultFunction(op));
|
||||
}
|
||||
|
||||
const JSValue Context::findBinaryOverride(JSValue &operand1, JSValue &operand2, ExprNode::Kind op)
|
||||
const JSValue Context::findBinaryOverride(JSValue &operand1, JSValue &operand2, JSTypes::Operator op)
|
||||
{
|
||||
JSClass *class1 = operand1.isObject() ? dynamic_cast<JSClass*>(operand1.object->getType()) : NULL;
|
||||
JSClass *class2 = operand2.isObject() ? dynamic_cast<JSClass*>(operand2.object->getType()) : NULL;
|
||||
@ -630,9 +630,9 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
||||
break;
|
||||
|
||||
case INVOKE_CALL:
|
||||
case CALL:
|
||||
case DIRECT_CALL:
|
||||
{
|
||||
Call* call = static_cast<Call*>(instruction);
|
||||
DirectCall* call = static_cast<DirectCall*>(instruction);
|
||||
JSValue v = (*registers)[op2(call).first];
|
||||
JSFunction *target = NULL;
|
||||
if (v.isFunction())
|
||||
@ -789,7 +789,7 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
||||
(*registers)[dst(gc).first] = cl->getActivation();
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
case DIRECT_CALL:
|
||||
{
|
||||
DirectCall* call = static_cast<DirectCall*>(instruction);
|
||||
@ -818,7 +818,7 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
case RETURN_VOID:
|
||||
{
|
||||
Linkage *linkage = mLinkage;
|
||||
@ -1536,15 +1536,15 @@ using JSString throughout.
|
||||
(*registers)[dst(tst).first] = (*registers)[src1(tst).first].toBoolean();
|
||||
}
|
||||
break;
|
||||
case NEGATE:
|
||||
case NEGATE_DOUBLE:
|
||||
{
|
||||
Negate* neg = static_cast<Negate*>(instruction);
|
||||
NegateDouble* neg = static_cast<NegateDouble*>(instruction);
|
||||
(*registers)[dst(neg).first] = -(*registers)[src1(neg).first].toNumber().f64;
|
||||
}
|
||||
break;
|
||||
case POSATE:
|
||||
case POSATE_DOUBLE:
|
||||
{
|
||||
Posate* pos = static_cast<Posate*>(instruction);
|
||||
PosateDouble* pos = static_cast<PosateDouble*>(instruction);
|
||||
(*registers)[dst(pos).first] = (*registers)[src1(pos).first].toNumber();
|
||||
}
|
||||
break;
|
||||
@ -1727,6 +1727,16 @@ JSType *Context::getParameterType(FunctionDefinition &function, int index)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint32 Context::getParameterCount(FunctionDefinition &function)
|
||||
{
|
||||
uint32 count = 0;
|
||||
VariableBinding *v = function.parameters;
|
||||
while (v) {
|
||||
count++;
|
||||
v = v->next;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
Context::Frame* Context::getFrames()
|
||||
|
@ -21,9 +21,9 @@
|
||||
#define interpreter_h
|
||||
|
||||
#include "utilities.h"
|
||||
#include "icodegenerator.h"
|
||||
#include "jstypes.h"
|
||||
#include "vmtypes.h"
|
||||
#include "icodegenerator.h"
|
||||
#include "gc_allocator.h"
|
||||
|
||||
namespace JavaScript {
|
||||
@ -83,12 +83,13 @@ namespace Interpreter {
|
||||
|
||||
ICodeModule* loadClass(const char *fileName);
|
||||
|
||||
const JSValue findBinaryOverride(JSValue &operand1, JSValue &operand2, ExprNode::Kind op);
|
||||
const JSValue findUnaryOverride(JSValue &operand1, ExprNode::Kind op);
|
||||
const JSValue findBinaryOverride(JSValue &operand1, JSValue &operand2, JSTypes::Operator op);
|
||||
const JSValue findUnaryOverride(JSValue &operand1, JSTypes::Operator op);
|
||||
|
||||
JSType *findType(const StringAtom& typeName);
|
||||
JSType *extractType(ExprNode *t);
|
||||
JSType *getParameterType(FunctionDefinition &function, int index);
|
||||
uint32 getParameterCount(FunctionDefinition &function);
|
||||
|
||||
private:
|
||||
void broadcast(Event event);
|
||||
|
@ -105,7 +105,7 @@ namespace JSClasses {
|
||||
bool mHasSetters;
|
||||
JSFunctions mGetters; // allocated at 'complete()' time
|
||||
JSFunctions mSetters;
|
||||
JSOperatorList *mOperators[ExprNode::kindsEnd];
|
||||
JSOperatorList *mOperators[JSTypes::OperatorCount];
|
||||
public:
|
||||
JSClass(JSScope* scope, const String& name, JSClass* superClass = 0)
|
||||
: JSType(name, superClass),
|
||||
@ -124,7 +124,7 @@ namespace JSClasses {
|
||||
if (si->second.isVirtual())
|
||||
mSlots[si->first] = si->second;
|
||||
}
|
||||
for (uint32 i = 0; i < ExprNode::kindsEnd; i++)
|
||||
for (uint32 i = 0; i < JSTypes::OperatorCount; i++)
|
||||
mOperators[i] = NULL;
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ namespace JSClasses {
|
||||
}
|
||||
}
|
||||
|
||||
void defineOperator(ExprNode::Kind op, JSType *operand1, JSType *operand2, JSFunction *f)
|
||||
void defineOperator(JSTypes::Operator op, JSType *operand1, JSType *operand2, JSFunction *f)
|
||||
{
|
||||
if (!mOperators[op])
|
||||
mOperators[op] = new JSOperatorList();
|
||||
@ -335,7 +335,7 @@ namespace JSClasses {
|
||||
mOperators[op]->push_back(new JSOperator(operand1, operand2, f));
|
||||
}
|
||||
|
||||
void addApplicableOperators(JSOperatorList &list, ExprNode::Kind op, const JSType *operand1, const JSType *operand2)
|
||||
void addApplicableOperators(JSOperatorList &list, JSTypes::Operator op, const JSType *operand1, const JSType *operand2)
|
||||
{
|
||||
if (mOperators[op]) {
|
||||
for (JSOperatorList::iterator i = mOperators[op]->begin(),
|
||||
@ -347,7 +347,7 @@ namespace JSClasses {
|
||||
}
|
||||
}
|
||||
|
||||
JSOperator *findUnaryOperator(ExprNode::Kind op)
|
||||
JSOperator *findUnaryOperator(JSTypes::Operator op)
|
||||
{
|
||||
if (mOperators[op])
|
||||
return *mOperators[op]->begin();
|
||||
|
@ -191,6 +191,39 @@ namespace JSTypes {
|
||||
|
||||
Formatter& operator<<(Formatter& f, const JSValue& value);
|
||||
|
||||
typedef enum {
|
||||
None,
|
||||
Posate,
|
||||
Negate,
|
||||
Complement,
|
||||
Increment,
|
||||
Decrement,
|
||||
Const,
|
||||
Call,
|
||||
New,
|
||||
NewArgs,
|
||||
Index,
|
||||
IndexEqual,
|
||||
DeleteIndex,
|
||||
Plus,
|
||||
Minus,
|
||||
Multiply,
|
||||
Divide,
|
||||
Remainder,
|
||||
ShiftLeft,
|
||||
ShiftRight,
|
||||
UShiftRight,
|
||||
Less,
|
||||
LessEqual,
|
||||
In,
|
||||
Equal,
|
||||
SpittingImage,
|
||||
BitAnd,
|
||||
BitXor,
|
||||
BitOr,
|
||||
OperatorCount
|
||||
} Operator;
|
||||
|
||||
|
||||
#if defined(XP_MAC)
|
||||
// copied from default template parameters in map.
|
||||
|
@ -1116,79 +1116,7 @@ namespace JavaScript
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ExprNode::Kind
|
||||
Parser::validateOperatorName(const Token &name)
|
||||
{
|
||||
Lexer operatorLexer(getWorld(), copyTokenChars(name),
|
||||
getReader().sourceLocation); // XXX line number ???
|
||||
|
||||
const Token &t = operatorLexer.get(false); // XXX preferRegExp ???
|
||||
|
||||
// XXX switch to a table lookup instead
|
||||
switch (t.getKind()) {
|
||||
default:
|
||||
syntaxError("Illegal operator name");
|
||||
|
||||
case Token::complement:
|
||||
return ExprNode::complement;
|
||||
case Token::increment:
|
||||
return ExprNode::postIncrement;
|
||||
case Token::decrement:
|
||||
return ExprNode::postDecrement;
|
||||
case Token::Const:
|
||||
return ExprNode::none; // XXX
|
||||
|
||||
case Token::plus:
|
||||
return ExprNode::add;
|
||||
case Token::minus:
|
||||
return ExprNode::subtract;
|
||||
case Token::times:
|
||||
return ExprNode::multiply;
|
||||
case Token::divide:
|
||||
return ExprNode::divide;
|
||||
case Token::modulo:
|
||||
return ExprNode::modulo;
|
||||
case Token::leftShift:
|
||||
return ExprNode::leftShift;
|
||||
case Token::rightShift:
|
||||
return ExprNode::rightShift;
|
||||
case Token::logicalRightShift:
|
||||
return ExprNode::logicalRightShift;
|
||||
case Token::lessThan:
|
||||
return ExprNode::lessThan;
|
||||
case Token::lessThanOrEqual:
|
||||
return ExprNode::lessThanOrEqual;
|
||||
case Token::equal:
|
||||
return ExprNode::equal;
|
||||
case Token::bitwiseAnd:
|
||||
return ExprNode::bitwiseAnd;
|
||||
case Token::bitwiseXor:
|
||||
return ExprNode::bitwiseXor;
|
||||
case Token::bitwiseOr:
|
||||
return ExprNode::bitwiseOr;
|
||||
case Token::identical:
|
||||
return ExprNode::identical;
|
||||
case Token::In:
|
||||
return ExprNode::In;
|
||||
|
||||
case Token::openParenthesis:
|
||||
return ExprNode::call;
|
||||
|
||||
case Token::New:
|
||||
return ExprNode::New;
|
||||
|
||||
case Token::openBracket:
|
||||
return ExprNode::index;
|
||||
|
||||
case Token::Delete:
|
||||
return ExprNode::Delete;
|
||||
}
|
||||
|
||||
return ExprNode::none;
|
||||
|
||||
}
|
||||
|
||||
// Parse and return a statement that takes zero or more initial attributes,
|
||||
// which have already been parsed. If noIn is false, allow the in operator.
|
||||
//
|
||||
@ -1242,21 +1170,6 @@ namespace JavaScript
|
||||
{
|
||||
FunctionStmtNode *f =
|
||||
new(arena) FunctionStmtNode(pos, sKind, attributes);
|
||||
/*
|
||||
if (attributes &&
|
||||
attributes->contains(Token::Operator)) {
|
||||
// expecting a string literal matching one
|
||||
// of the legal operator names
|
||||
const Token &t2 = lexer.get(false);
|
||||
if (!t2.hasKind(Token::string))
|
||||
syntaxError("Operator name (as string "
|
||||
"literal) expected");
|
||||
f->function.prefix = FunctionName::Operator;
|
||||
f->function.op = validateOperatorName(t2);
|
||||
f->function.name = NULL;
|
||||
}
|
||||
else
|
||||
*/
|
||||
parseFunctionName(f->function);
|
||||
parseFunctionSignature(f->function);
|
||||
f->function.body = parseBody(&semicolonState);
|
||||
|
@ -279,7 +279,6 @@ namespace JavaScript {
|
||||
};
|
||||
|
||||
Prefix prefix; // The name's prefix, if any
|
||||
ExprNode::Kind op; // The operator, if appropriate
|
||||
ExprNode *name; // The name; nil if omitted
|
||||
|
||||
FunctionName(): prefix(normal), name(0) {}
|
||||
|
@ -92,7 +92,6 @@ Formatter& operator<< (Formatter& f, TypedRegister& r)
|
||||
|
||||
Formatter& operator<< (Formatter &f, InstructionStream &is)
|
||||
{
|
||||
|
||||
for (InstructionIterator i = is.begin();
|
||||
i != is.end(); i++) {
|
||||
/*
|
||||
@ -121,6 +120,71 @@ Formatter& operator<< (Formatter &f, InstructionStream &is)
|
||||
}
|
||||
|
||||
|
||||
Formatter& operator<< (Formatter& f, JSTypes::Operator& op)
|
||||
{
|
||||
switch (op) {
|
||||
case JSTypes::None:
|
||||
f << "None"; break;
|
||||
case JSTypes::Posate:
|
||||
f << "Posate"; break;
|
||||
case JSTypes::Negate:
|
||||
f << "Negate"; break;
|
||||
case JSTypes::Complement:
|
||||
f << "Complement"; break;
|
||||
case JSTypes::Increment:
|
||||
f << "Increment"; break;
|
||||
case JSTypes::Decrement:
|
||||
f << "Decrement"; break;
|
||||
case JSTypes::Const:
|
||||
f << "Const"; break;
|
||||
case JSTypes::Call:
|
||||
f << "Call"; break;
|
||||
case JSTypes::New:
|
||||
f << "New"; break;
|
||||
case JSTypes::NewArgs:
|
||||
f << "NewArgs"; break;
|
||||
case JSTypes::Index:
|
||||
f << "Index"; break;
|
||||
case JSTypes::IndexEqual:
|
||||
f << "IndexEqual"; break;
|
||||
case JSTypes::DeleteIndex:
|
||||
f << "DeleteIndex"; break;
|
||||
case JSTypes::Plus:
|
||||
f << "Plus"; break;
|
||||
case JSTypes::Minus:
|
||||
f << "Minus"; break;
|
||||
case JSTypes::Multiply:
|
||||
f << "Multiply"; break;
|
||||
case JSTypes::Divide:
|
||||
f << "Divide"; break;
|
||||
case JSTypes::Remainder:
|
||||
f << "Remainder"; break;
|
||||
case JSTypes::ShiftLeft:
|
||||
f << "ShiftLeft"; break;
|
||||
case JSTypes::ShiftRight:
|
||||
f << "ShiftRight"; break;
|
||||
case JSTypes::UShiftRight:
|
||||
f << "UShiftRight"; break;
|
||||
case JSTypes::Less:
|
||||
f << "Less"; break;
|
||||
case JSTypes::LessEqual:
|
||||
f << "LessEqual"; break;
|
||||
case JSTypes::In:
|
||||
f << "In"; break;
|
||||
case JSTypes::Equal:
|
||||
f << "Equal"; break;
|
||||
case JSTypes::SpittingImage:
|
||||
f << "SpittingImage"; break;
|
||||
case JSTypes::BitAnd:
|
||||
f << "BitAnd"; break;
|
||||
case JSTypes::BitXor:
|
||||
f << "BitXor"; break;
|
||||
case JSTypes::BitOr:
|
||||
f << "BitOr"; break;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
} /* namespace VM */
|
||||
} /* namespace JavaScript */
|
||||
|
||||
|
@ -110,6 +110,7 @@ namespace VM {
|
||||
Formatter& operator<< (Formatter& f, const ArgList& al);
|
||||
Formatter& operator<< (Formatter& f, InstructionStream& is);
|
||||
Formatter& operator<< (Formatter& f, TypedRegister& r);
|
||||
Formatter& operator<< (Formatter& f, Operator& op);
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
|
@ -136,8 +136,8 @@ sub get_map {
|
||||
for $p (@params) {
|
||||
if ($p eq "ArgumentList*") {
|
||||
push (@ot, "otArgumentList");
|
||||
} elsif ($p eq "ExprNode::Kind") {
|
||||
push (@ot, "otExprNodeKind");
|
||||
} elsif ($p eq "JSTypes::Operator") {
|
||||
push (@ot, "otJSTypesOperator");
|
||||
} elsif ($p eq "ICodeModule*") {
|
||||
push (@ot, "otICodeModule");
|
||||
} elsif ($p eq "JSClass*") {
|
||||
|
@ -131,7 +131,19 @@ $ops{"GENERIC_BINARY_OP"} =
|
||||
{
|
||||
super => "Instruction_4",
|
||||
rem => "dest, op, source1, source2",
|
||||
params => [ ("TypedRegister", "ExprNode::Kind", "TypedRegister", "TypedRegister") ]
|
||||
params => [ ("TypedRegister", "JSTypes::Operator", "TypedRegister", "TypedRegister") ]
|
||||
};
|
||||
$ops{"GENERIC_UNARY_OP"} =
|
||||
{
|
||||
super => "Instruction_3",
|
||||
rem => "dest, op, source",
|
||||
params => [ ("TypedRegister", "JSTypes::Operator", "TypedRegister") ]
|
||||
};
|
||||
$ops{"GENERIC_XCREMENT_OP"} =
|
||||
{
|
||||
super => "Instruction_3",
|
||||
rem => "dest, op, source",
|
||||
params => [ ("TypedRegister", "JSTypes::Operator", "TypedRegister") ]
|
||||
};
|
||||
$ops{"MOVE"} =
|
||||
{
|
||||
@ -343,8 +355,8 @@ $ops{"INSTANCEOF"} = $binary_op;
|
||||
$ops{"BITNOT"} = $unary_op;
|
||||
$ops{"NOT"} = $unary_op;
|
||||
$ops{"TEST"} = $unary_op;
|
||||
$ops{"NEGATE"} = $unary_op;
|
||||
$ops{"POSATE"} = $unary_op;
|
||||
$ops{"NEGATE_DOUBLE"} = $unary_op;
|
||||
$ops{"POSATE_DOUBLE"} = $unary_op;
|
||||
$ops{"BRANCH"} =
|
||||
{
|
||||
super => "GenericBranch",
|
||||
@ -365,17 +377,17 @@ $ops{"RETURN_VOID"} =
|
||||
super => "Instruction",
|
||||
rem => "Return without a value"
|
||||
};
|
||||
$ops{"CALL"} =
|
||||
$ops{"DIRECT_CALL"} =
|
||||
{
|
||||
super => "Instruction_3",
|
||||
rem => "result, target, args",
|
||||
params => [ ("TypedRegister", "TypedRegister", "ArgumentList*") ]
|
||||
};
|
||||
$ops{"DIRECT_CALL"} =
|
||||
$ops{"INVOKE_CALL"} =
|
||||
{
|
||||
super => "Instruction_3",
|
||||
rem => "result, target, args",
|
||||
params => [ ("TypedRegister", "JSFunction*", "ArgumentList*") ]
|
||||
params => [ ("TypedRegister", "TypedRegister", "ArgumentList*") ]
|
||||
};
|
||||
$ops{"BIND_THIS"} =
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user