2000-04-18 04:17:34 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express oqr
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is the JavaScript 2 Prototype.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the
|
|
|
|
* terms of the GNU Public License (the "GPL"), in which case the
|
|
|
|
* provisions of the GPL are applicable instead of those above.
|
|
|
|
* If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of the GPL and not to allow others to use your
|
|
|
|
* version of this file under the NPL, indicate your decision by
|
|
|
|
* deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this
|
|
|
|
* file under either the NPL or the GPL.
|
|
|
|
*/
|
2000-03-29 23:19:23 +04:00
|
|
|
|
|
|
|
#ifndef icodegenerator_h
|
|
|
|
#define icodegenerator_h
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <stack>
|
|
|
|
|
2000-04-18 04:17:34 +04:00
|
|
|
#include "utilities.h"
|
|
|
|
#include "parser.h"
|
|
|
|
#include "vmtypes.h"
|
2000-06-24 05:02:34 +04:00
|
|
|
#include "jsclasses.h"
|
2001-01-20 03:44:51 +03:00
|
|
|
#include "xmlparser.h"
|
2000-04-07 06:41:21 +04:00
|
|
|
|
2000-04-06 00:28:17 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
namespace JavaScript {
|
|
|
|
namespace ICG {
|
|
|
|
|
|
|
|
using namespace VM;
|
2000-06-21 02:45:45 +04:00
|
|
|
using namespace JSTypes;
|
2000-06-24 05:02:34 +04:00
|
|
|
using namespace JSClasses;
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-09-12 02:10:44 +04:00
|
|
|
|
2000-10-28 03:55:31 +04:00
|
|
|
struct VariableList { // Maps from variable (parameter) name to a TypedRegister.
|
|
|
|
// But because we also want to map from a register number to
|
|
|
|
// it's type, we keep the TypedRegsters in a separate array and
|
|
|
|
// just store the index in the name map.
|
2000-09-12 02:10:44 +04:00
|
|
|
|
|
|
|
typedef std::map<String, uint32, std::less<String> > VariableMap;
|
2000-10-28 03:55:31 +04:00
|
|
|
typedef VariableMap::value_type MapValue;
|
2000-09-12 02:10:44 +04:00
|
|
|
|
2000-10-28 03:55:31 +04:00
|
|
|
VariableMap variableMap;
|
|
|
|
std::vector<TypedRegister> registerList;
|
2000-09-12 02:10:44 +04:00
|
|
|
|
|
|
|
TypedRegister findVariable(const StringAtom& name)
|
|
|
|
{
|
|
|
|
VariableMap::iterator i = variableMap.find(name);
|
2000-10-28 03:55:31 +04:00
|
|
|
return (i == variableMap.end())
|
|
|
|
? TypedRegister(NotARegister, &None_Type)
|
|
|
|
: registerList[i->second];
|
2000-09-12 02:10:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void add(const StringAtom& name, TypedRegister r)
|
|
|
|
{
|
2000-10-28 03:55:31 +04:00
|
|
|
variableMap.insert(MapValue(name, r.first));
|
|
|
|
registerList.resize(r.first + 1);
|
|
|
|
registerList[r.first] = r;
|
2000-09-12 02:10:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
TypedRegister getRegister(uint32 i)
|
|
|
|
{
|
2000-10-28 03:55:31 +04:00
|
|
|
ASSERT(i < registerList.size());
|
|
|
|
return registerList[i];
|
2000-09-12 02:10:44 +04:00
|
|
|
}
|
|
|
|
|
2000-10-28 03:55:31 +04:00
|
|
|
|
2000-09-12 02:10:44 +04:00
|
|
|
};
|
|
|
|
|
2000-10-28 03:55:31 +04:00
|
|
|
struct ParameterList : public VariableList {
|
|
|
|
typedef enum {
|
|
|
|
NoRestParameter,
|
|
|
|
HasRestParameterBeforeBar,
|
|
|
|
HasRestParameterAfterBar,
|
|
|
|
HasUnnamedRestParameter
|
|
|
|
} RestParameterStatus;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<bool> mOptionalParameters; // whether or not a parameter has an optional value
|
|
|
|
// ordered by lexical ordering === register number.
|
|
|
|
RestParameterStatus mRestParameter;
|
|
|
|
uint32 mPositionalCount; // number of positional parameters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParameterList() : mRestParameter(NoRestParameter), mPositionalCount(0) { }
|
|
|
|
|
|
|
|
void add(const StringAtom& name, TypedRegister r, bool isOptional)
|
|
|
|
{
|
|
|
|
VariableList::add(name, r);
|
|
|
|
mOptionalParameters.resize(r.first + 1);
|
|
|
|
mOptionalParameters[r.first] = isOptional;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 size() { return registerList.size(); } // the variableMap may be larger since it contains aliases
|
|
|
|
|
|
|
|
bool isOptional(uint32 i) { ASSERT(i < mOptionalParameters.size()); return mOptionalParameters[i]; }
|
|
|
|
|
|
|
|
void setRestParameter(RestParameterStatus rs) { mRestParameter = rs; }
|
|
|
|
void setPositionalCount(uint32 x) { mPositionalCount = x; }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-06-24 02:27:17 +04:00
|
|
|
typedef std::map<uint32, uint32, std::less<uint32> > InstructionMap;
|
2000-05-03 01:36:28 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
class ICodeModule {
|
|
|
|
public:
|
2000-05-05 02:42:49 +04:00
|
|
|
ICodeModule(InstructionStream *iCode, VariableList *variables,
|
2000-10-28 03:55:31 +04:00
|
|
|
ParameterList *parameters,
|
|
|
|
uint32 maxRegister,
|
2000-09-02 05:01:04 +04:00
|
|
|
InstructionMap *instructionMap,
|
2000-12-30 04:13:06 +03:00
|
|
|
JSType *resultType, uint32 exceptionRegister) :
|
2000-10-28 03:55:31 +04:00
|
|
|
its_iCode(iCode), itsVariables(variables), itsParameters(parameters),
|
|
|
|
itsMaxRegister(maxRegister),
|
2000-09-02 05:01:04 +04:00
|
|
|
mID(++sMaxID), mInstructionMap(instructionMap),
|
|
|
|
mParameterInit(NULL),
|
|
|
|
mEntryPoint(0),
|
2000-12-30 04:13:06 +03:00
|
|
|
mResultType(resultType),
|
|
|
|
mExceptionRegister(exceptionRegister)
|
2000-09-02 05:01:04 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-05-09 22:59:12 +04:00
|
|
|
~ICodeModule()
|
|
|
|
{
|
|
|
|
delete its_iCode;
|
|
|
|
delete itsVariables;
|
2000-05-27 02:33:05 +04:00
|
|
|
delete mInstructionMap;
|
2000-09-02 05:01:04 +04:00
|
|
|
if (mParameterInit) delete mParameterInit;
|
2000-05-09 22:59:12 +04:00
|
|
|
}
|
2000-05-05 02:42:49 +04:00
|
|
|
|
|
|
|
Formatter& print(Formatter& f);
|
2000-06-24 02:27:17 +04:00
|
|
|
void setFileName (String aFileName) { mFileName = aFileName; }
|
|
|
|
String getFileName () { return mFileName; }
|
2000-04-07 06:41:21 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
InstructionStream *its_iCode;
|
2000-05-03 01:36:28 +04:00
|
|
|
VariableList *itsVariables;
|
2000-10-28 03:55:31 +04:00
|
|
|
ParameterList *itsParameters;
|
2000-05-05 02:42:49 +04:00
|
|
|
uint32 itsMaxRegister;
|
|
|
|
uint32 mID;
|
2000-05-27 02:33:05 +04:00
|
|
|
InstructionMap *mInstructionMap;
|
2000-06-24 02:27:17 +04:00
|
|
|
String mFileName;
|
2000-09-02 05:01:04 +04:00
|
|
|
uint32 *mParameterInit;
|
|
|
|
uint32 mEntryPoint;
|
2000-10-10 02:21:26 +04:00
|
|
|
JSType *mResultType;
|
2000-12-30 04:13:06 +03:00
|
|
|
uint32 mExceptionRegister;
|
2000-05-27 02:33:05 +04:00
|
|
|
|
2000-05-05 02:42:49 +04:00
|
|
|
static uint32 sMaxID;
|
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
};
|
2000-05-05 02:42:49 +04:00
|
|
|
|
2000-05-24 06:11:39 +04:00
|
|
|
typedef std::vector<const StringAtom *> LabelSet;
|
|
|
|
class LabelEntry {
|
|
|
|
public:
|
|
|
|
LabelEntry(LabelSet *labelSet, Label *breakLabel)
|
|
|
|
: labelSet(labelSet), breakLabel(breakLabel), continueLabel(NULL) { }
|
|
|
|
LabelEntry(LabelSet *labelSet, Label *breakLabel, Label *continueLabel)
|
|
|
|
: labelSet(labelSet), breakLabel(breakLabel), continueLabel(continueLabel) { }
|
|
|
|
|
|
|
|
bool containsLabel(const StringAtom *label);
|
|
|
|
|
|
|
|
LabelSet *labelSet;
|
|
|
|
Label *breakLabel;
|
|
|
|
Label *continueLabel;
|
|
|
|
};
|
|
|
|
typedef std::vector<LabelEntry *> LabelStack;
|
|
|
|
|
2000-05-05 02:42:49 +04:00
|
|
|
Formatter& operator<<(Formatter &f, ICodeModule &i);
|
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
/****************************************************************/
|
|
|
|
|
|
|
|
// An ICodeGenerator provides the interface between the parser and the
|
|
|
|
// interpreter. The parser constructs one of these for each
|
|
|
|
// function/script, adds statements and expressions to it and then
|
|
|
|
// converts it into an ICodeModule, ready for execution.
|
2000-03-29 23:19:23 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
class ICodeGenerator {
|
2000-06-29 05:21:41 +04:00
|
|
|
public:
|
|
|
|
typedef enum { kNoFlags = 0, kIsTopLevel = 0x01, kIsStaticMethod = 0x02, kIsWithinWith = 0x04 } ICodeGeneratorFlags;
|
2000-04-19 01:51:45 +04:00
|
|
|
private:
|
|
|
|
InstructionStream *iCode;
|
2000-05-09 22:59:12 +04:00
|
|
|
bool iCodeOwner;
|
2000-04-19 01:51:45 +04:00
|
|
|
LabelList labels;
|
2000-05-03 01:36:28 +04:00
|
|
|
|
2000-10-21 04:30:23 +04:00
|
|
|
Register mTopRegister; // highest (currently) allocated register
|
2000-07-06 22:26:26 +04:00
|
|
|
TypedRegister mExceptionRegister; // reserved to carry the exception object.
|
|
|
|
VariableList *variableList; // name|register pair for each variable
|
2000-10-28 03:55:31 +04:00
|
|
|
ParameterList *parameterList; // name|register pair for each parameter
|
|
|
|
// (with #0 reserved for 'this' regardless of scope)
|
2000-10-21 04:30:23 +04:00
|
|
|
|
|
|
|
Context *mContext; // the world and global object
|
2000-07-06 22:26:26 +04:00
|
|
|
LabelStack mLabelStack; // stack of LabelEntry objects, one per nested looping construct
|
|
|
|
// maps source position to instruction index
|
2000-06-24 02:27:17 +04:00
|
|
|
InstructionMap *mInstructionMap;
|
2000-05-27 02:33:05 +04:00
|
|
|
|
2000-07-06 22:26:26 +04:00
|
|
|
JSClass *mClass; // enclosing class when generating code for methods
|
|
|
|
ICodeGeneratorFlags mFlags; // assorted flags
|
2000-09-02 05:01:04 +04:00
|
|
|
LabelList *pLabels; // label for each parameter initialization entry point
|
2000-07-06 22:26:26 +04:00
|
|
|
|
2000-10-19 03:37:44 +04:00
|
|
|
const StringAtom &mInitName;
|
2000-12-09 02:55:39 +03:00
|
|
|
ICodeGenerator *mContainingFunction;// outer function for nested functions
|
2000-10-19 03:37:44 +04:00
|
|
|
|
2000-07-06 22:26:26 +04:00
|
|
|
std::vector<bool> mPermanentRegister;
|
|
|
|
|
|
|
|
Register getTempRegister()
|
|
|
|
{
|
|
|
|
while (mTopRegister < mPermanentRegister.size())
|
|
|
|
if (!mPermanentRegister[mTopRegister])
|
|
|
|
return mTopRegister++;
|
|
|
|
else
|
|
|
|
++mTopRegister;
|
|
|
|
mPermanentRegister.resize(mTopRegister + 1);
|
|
|
|
mPermanentRegister[mTopRegister] = false;
|
|
|
|
return mTopRegister++;
|
|
|
|
}
|
|
|
|
|
2000-10-28 03:55:31 +04:00
|
|
|
void resetTopRegister() { mTopRegister = 0; }
|
2000-07-06 22:26:26 +04:00
|
|
|
void resetStatement() { resetTopRegister(); }
|
|
|
|
|
2000-10-28 04:01:58 +04:00
|
|
|
TypedRegister allocateRegister(JSType *type);
|
2000-07-06 22:26:26 +04:00
|
|
|
|
|
|
|
JSType *findType(const StringAtom& typeName);
|
|
|
|
|
|
|
|
|
2000-09-02 05:01:04 +04:00
|
|
|
void addParameterLabel(Label *label) { if (pLabels == NULL) pLabels = new LabelList(); pLabels->push_back(label); }
|
2000-05-27 02:33:05 +04:00
|
|
|
|
2000-05-03 01:36:28 +04:00
|
|
|
|
2000-09-02 05:01:04 +04:00
|
|
|
Label *setLabel(Label *label);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-07-06 22:26:26 +04:00
|
|
|
void jsr(Label *label) { iCode->push_back(new Jsr(label)); }
|
|
|
|
void rts() { iCode->push_back(new Rts()); }
|
2000-04-19 01:51:45 +04:00
|
|
|
void branch(Label *label);
|
2000-06-21 02:45:45 +04:00
|
|
|
GenericBranch *branchTrue(Label *label, TypedRegister condition);
|
|
|
|
GenericBranch *branchFalse(Label *label, TypedRegister condition);
|
2000-09-07 23:22:13 +04:00
|
|
|
GenericBranch *branchInitialized(Label *label, TypedRegister condition);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-04-27 05:27:09 +04:00
|
|
|
void beginTry(Label *catchLabel, Label *finallyLabel)
|
2000-07-06 22:26:26 +04:00
|
|
|
{ iCode->push_back(new Tryin(catchLabel, finallyLabel)); }
|
|
|
|
void endTry() { iCode->push_back(new Tryout()); }
|
|
|
|
|
|
|
|
void beginWith(TypedRegister obj) { iCode->push_back(new Within(obj)); }
|
|
|
|
void endWith() { iCode->push_back(new Without()); }
|
2000-05-03 01:36:28 +04:00
|
|
|
|
2000-04-22 02:52:52 +04:00
|
|
|
|
2000-07-06 22:26:26 +04:00
|
|
|
void startStatement(uint32 pos) { (*mInstructionMap)[iCode->size()] = pos; }
|
2000-05-27 02:33:05 +04:00
|
|
|
|
2000-05-18 04:03:23 +04:00
|
|
|
ICodeOp mapExprNodeToICodeOp(ExprNode::Kind kind);
|
2001-01-11 03:03:05 +03:00
|
|
|
ExprNode::Kind mapICodeOpToExprNode(ICodeOp op);
|
2000-06-29 05:21:41 +04:00
|
|
|
|
|
|
|
bool isTopLevel() { return (mFlags & kIsTopLevel) != 0; }
|
|
|
|
bool isWithinWith() { return (mFlags & kIsWithinWith) != 0; }
|
|
|
|
bool isStaticMethod() { return (mFlags & kIsStaticMethod) != 0; }
|
|
|
|
|
|
|
|
void setFlag(uint32 flag, bool v) { mFlags = (ICodeGeneratorFlags)((v) ? mFlags | flag : mFlags & ~flag); }
|
|
|
|
|
2000-12-09 02:55:39 +03:00
|
|
|
typedef enum { NoKind, Var, Property, Slot, Static, Constructor, Name, Method } LValueKind;
|
2000-07-06 22:26:26 +04:00
|
|
|
|
2000-12-16 04:14:36 +03:00
|
|
|
LValueKind getVariableByName(const StringAtom &name, TypedRegister &v);
|
|
|
|
LValueKind scanForVariable(const StringAtom &name, TypedRegister &v, uint32 &slotIndex, TypedRegister &base);
|
2000-12-09 02:55:39 +03:00
|
|
|
LValueKind resolveIdentifier(const StringAtom &name, TypedRegister &v, uint32 &slotIndex, TypedRegister &base, bool lvalue);
|
2000-10-10 02:21:26 +04:00
|
|
|
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);
|
2000-12-09 02:55:39 +03:00
|
|
|
ICodeModule *genFunction(FunctionDefinition &function, bool isStatic, bool isConstructor, JSClass *superClass);
|
2001-01-20 03:44:51 +03:00
|
|
|
|
|
|
|
|
|
|
|
ICodeModule *readFunction(XMLNode *element, String &name, JSClass *thisClass);
|
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
public:
|
2000-06-29 05:21:41 +04:00
|
|
|
|
2000-12-09 02:55:39 +03:00
|
|
|
ICodeGenerator(Context *cx, ICodeGenerator *containingFunction = NULL, JSClass *aClass = NULL, ICodeGeneratorFlags flags = kIsTopLevel);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-05-09 22:59:12 +04:00
|
|
|
~ICodeGenerator()
|
|
|
|
{
|
2000-05-27 02:33:05 +04:00
|
|
|
if (iCodeOwner) {
|
2000-05-09 22:59:12 +04:00
|
|
|
delete iCode;
|
2000-05-27 02:33:05 +04:00
|
|
|
delete mInstructionMap;
|
2000-09-02 05:01:04 +04:00
|
|
|
if (pLabels) delete pLabels;
|
2000-05-27 02:33:05 +04:00
|
|
|
}
|
2000-05-09 22:59:12 +04:00
|
|
|
}
|
2000-05-24 06:11:39 +04:00
|
|
|
|
2000-10-10 02:21:26 +04:00
|
|
|
ICodeModule *complete(JSType *resultType);
|
2001-01-20 02:56:37 +03:00
|
|
|
ICodeModule *readICode(const char *fileName);
|
2000-10-10 02:21:26 +04:00
|
|
|
|
|
|
|
JSType *extractType(ExprNode *t);
|
2001-01-11 03:03:05 +03:00
|
|
|
JSType *getParameterType(FunctionDefinition &function, int index);
|
|
|
|
|
2000-06-21 02:45:45 +04:00
|
|
|
TypedRegister genExpr(ExprNode *p,
|
2000-07-06 22:26:26 +04:00
|
|
|
bool needBoolValueInBranch = false,
|
|
|
|
Label *trueBranch = NULL,
|
|
|
|
Label *falseBranch = NULL);
|
2000-06-21 02:45:45 +04:00
|
|
|
TypedRegister genStmt(StmtNode *p, LabelSet *currentLabelSet = NULL);
|
2000-05-24 06:11:39 +04:00
|
|
|
|
2000-06-21 02:45:45 +04:00
|
|
|
void returnStmt(TypedRegister r);
|
2000-06-24 01:20:03 +04:00
|
|
|
void returnStmt();
|
2000-07-06 22:26:26 +04:00
|
|
|
void throwStmt(TypedRegister r) { iCode->push_back(new Throw(r)); }
|
|
|
|
void debuggerStmt() { iCode->push_back(new Debugger()); }
|
2000-05-03 01:36:28 +04:00
|
|
|
|
2000-10-28 03:55:31 +04:00
|
|
|
TypedRegister allocateVariable(const StringAtom& name)
|
|
|
|
{
|
|
|
|
return allocateVariable(name, &Any_Type);
|
|
|
|
}
|
|
|
|
|
|
|
|
TypedRegister allocateVariable(const StringAtom& name, const StringAtom& typeName)
|
|
|
|
{
|
|
|
|
return allocateVariable(name, findType(typeName));
|
|
|
|
}
|
|
|
|
|
|
|
|
TypedRegister allocateVariable(const StringAtom& name, JSType *type)
|
|
|
|
{
|
2000-10-28 04:01:58 +04:00
|
|
|
TypedRegister r = allocateRegister(type);
|
2000-10-28 03:55:31 +04:00
|
|
|
variableList->add(name, r);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2000-12-30 04:13:06 +03:00
|
|
|
TypedRegister allocateVariable(const StringAtom& name, TypedRegister r)
|
|
|
|
{
|
|
|
|
variableList->add(name, r);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2000-10-28 03:55:31 +04:00
|
|
|
TypedRegister allocateParameter(const StringAtom& name, bool isOptional)
|
|
|
|
{
|
|
|
|
return allocateParameter(name, isOptional, &Any_Type);
|
|
|
|
}
|
|
|
|
|
|
|
|
TypedRegister allocateParameter(const StringAtom& name, bool isOptional, const StringAtom& typeName)
|
|
|
|
{
|
|
|
|
return allocateParameter(name, isOptional, findType(typeName));
|
|
|
|
}
|
2000-05-06 01:38:16 +04:00
|
|
|
|
2000-10-28 03:55:31 +04:00
|
|
|
TypedRegister allocateParameter(const StringAtom& name, bool isOptional, JSType *type)
|
|
|
|
{
|
2000-10-28 04:01:58 +04:00
|
|
|
TypedRegister r = allocateRegister(type);
|
2000-10-28 03:55:31 +04:00
|
|
|
parameterList->add(name, r, isOptional);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
|
|
|
|
Formatter& print(Formatter& f);
|
|
|
|
|
2000-06-21 02:45:45 +04:00
|
|
|
TypedRegister op(ICodeOp op, TypedRegister source);
|
|
|
|
TypedRegister op(ICodeOp op, TypedRegister source1, TypedRegister source2);
|
2000-07-13 04:14:54 +04:00
|
|
|
TypedRegister binaryOp(ICodeOp op, TypedRegister source1, TypedRegister source2);
|
2000-11-17 02:48:42 +03:00
|
|
|
TypedRegister call(TypedRegister target, ArgumentList *args);
|
2000-09-02 05:01:04 +04:00
|
|
|
TypedRegister directCall(JSFunction *target, ArgumentList *args);
|
2000-11-17 02:48:42 +03:00
|
|
|
TypedRegister bindThis(TypedRegister thisArg, TypedRegister target);
|
2000-07-19 00:53:03 +04:00
|
|
|
TypedRegister getMethod(TypedRegister thisArg, uint32 slotIndex);
|
2000-12-09 02:55:39 +03:00
|
|
|
TypedRegister getClosure(uint32 count);
|
|
|
|
TypedRegister newClosure(ICodeModule *icm);
|
2000-06-21 02:45:45 +04:00
|
|
|
|
|
|
|
void move(TypedRegister destination, TypedRegister source);
|
|
|
|
TypedRegister logicalNot(TypedRegister source);
|
|
|
|
TypedRegister test(TypedRegister source);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-06-21 02:45:45 +04:00
|
|
|
TypedRegister loadBoolean(bool value);
|
|
|
|
TypedRegister loadImmediate(double value);
|
2000-07-08 05:08:29 +04:00
|
|
|
TypedRegister loadString(const String &value);
|
2000-06-22 02:32:21 +04:00
|
|
|
TypedRegister loadString(const StringAtom &name);
|
2000-04-20 02:45:57 +04:00
|
|
|
|
2000-07-26 02:58:04 +04:00
|
|
|
TypedRegister newObject(TypedRegister constructor);
|
2000-06-21 02:45:45 +04:00
|
|
|
TypedRegister newArray();
|
2000-09-12 02:10:44 +04:00
|
|
|
TypedRegister newFunction(ICodeModule *icm);
|
2000-07-08 05:08:29 +04:00
|
|
|
TypedRegister newClass(JSClass *clazz);
|
2000-07-11 03:18:07 +04:00
|
|
|
|
|
|
|
TypedRegister cast(TypedRegister arg, JSType *toType);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-07-08 05:08:29 +04:00
|
|
|
TypedRegister super();
|
2000-07-14 05:00:53 +04:00
|
|
|
TypedRegister loadName(const StringAtom &name, JSType *t = &Any_Type);
|
2000-06-21 02:45:45 +04:00
|
|
|
void saveName(const StringAtom &name, TypedRegister value);
|
2000-06-28 22:41:30 +04:00
|
|
|
TypedRegister nameXcr(const StringAtom &name, ICodeOp op);
|
2000-06-15 03:26:15 +04:00
|
|
|
|
2000-06-29 22:14:14 +04:00
|
|
|
TypedRegister deleteProperty(TypedRegister base, const StringAtom &name);
|
2000-06-21 02:45:45 +04:00
|
|
|
TypedRegister getProperty(TypedRegister base, const StringAtom &name);
|
|
|
|
void setProperty(TypedRegister base, const StringAtom &name, TypedRegister value);
|
2000-06-28 22:41:30 +04:00
|
|
|
TypedRegister propertyXcr(TypedRegister base, const StringAtom &name, ICodeOp op);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-07-19 00:53:03 +04:00
|
|
|
TypedRegister getStatic(JSClass *base, const String &name);
|
2000-06-27 06:39:32 +04:00
|
|
|
void setStatic(JSClass *base, const StringAtom &name, TypedRegister value);
|
2000-06-28 22:41:30 +04:00
|
|
|
TypedRegister staticXcr(JSClass *base, const StringAtom &name, ICodeOp op);
|
2000-06-27 06:39:32 +04:00
|
|
|
|
2000-06-21 02:45:45 +04:00
|
|
|
TypedRegister getElement(TypedRegister base, TypedRegister index);
|
|
|
|
void setElement(TypedRegister base, TypedRegister index, TypedRegister value);
|
2000-06-28 22:41:30 +04:00
|
|
|
TypedRegister elementXcr(TypedRegister base, TypedRegister index, ICodeOp op);
|
2000-06-15 03:26:15 +04:00
|
|
|
|
2000-06-24 03:43:24 +04:00
|
|
|
TypedRegister getSlot(TypedRegister base, uint32 slot);
|
|
|
|
void setSlot(TypedRegister base, uint32 slot, TypedRegister value);
|
2000-06-28 22:41:30 +04:00
|
|
|
TypedRegister slotXcr(TypedRegister base, uint32 slot, ICodeOp op);
|
2000-06-24 03:43:24 +04:00
|
|
|
|
2000-06-28 22:41:30 +04:00
|
|
|
TypedRegister varXcr(TypedRegister var, ICodeOp op);
|
2000-06-15 03:26:15 +04:00
|
|
|
|
2000-07-06 22:26:26 +04:00
|
|
|
InstructionStream *getICode() { return iCode; }
|
2000-04-19 01:51:45 +04:00
|
|
|
|
|
|
|
Label *getLabel();
|
2000-04-22 02:52:52 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
Formatter& operator<<(Formatter &f, ICodeGenerator &i);
|
2000-06-28 22:41:30 +04:00
|
|
|
Formatter& operator<<(Formatter &f, ICodeModule &i);
|
2000-10-19 03:37:44 +04:00
|
|
|
Formatter& operator<<(Formatter &f, std::string &s);
|
2000-04-19 01:51:45 +04:00
|
|
|
/*
|
|
|
|
std::ostream &operator<<(std::ostream &s, ICodeGenerator &i);
|
|
|
|
std::ostream &operator<<(std::ostream &s, StringAtom &str);
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2000-04-22 02:52:52 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
} /* namespace IGC */
|
2000-04-18 11:14:49 +04:00
|
|
|
} /* namespace JavaScript */
|
2000-04-01 06:53:16 +04:00
|
|
|
|
2000-04-18 04:17:34 +04:00
|
|
|
#endif /* icodegenerator_h */
|