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-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;
|
|
|
|
|
|
|
|
class ICodeGenerator; // forward declaration
|
|
|
|
|
|
|
|
enum StateKind {
|
|
|
|
While_state,
|
|
|
|
If_state,
|
|
|
|
Do_state,
|
|
|
|
Switch_state,
|
2000-04-22 02:52:52 +04:00
|
|
|
For_state,
|
|
|
|
Try_state
|
2000-04-19 01:51:45 +04:00
|
|
|
};
|
2000-05-03 01:36:28 +04:00
|
|
|
|
|
|
|
typedef std::vector<const StringAtom *> StatementLabels;
|
2000-04-19 01:51:45 +04:00
|
|
|
|
|
|
|
class ICodeState {
|
|
|
|
public :
|
|
|
|
ICodeState(StateKind kind, ICodeGenerator *icg); // inline below
|
|
|
|
virtual ~ICodeState() { }
|
2000-03-29 23:19:23 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
virtual Label *getBreakLabel(ICodeGenerator *) \
|
|
|
|
{ ASSERT(false); return NULL; }
|
|
|
|
virtual Label *getContinueLabel(ICodeGenerator *) \
|
|
|
|
{ ASSERT(false); return NULL;}
|
2000-04-08 05:04:55 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
StateKind stateKind;
|
2000-04-21 04:37:51 +04:00
|
|
|
uint32 statementLabelBase;
|
2000-04-19 01:51:45 +04:00
|
|
|
Label *breakLabel;
|
|
|
|
Label *continueLabel;
|
2000-05-03 01:36:28 +04:00
|
|
|
StatementLabels *labelSet;
|
2000-04-19 01:51:45 +04:00
|
|
|
};
|
2000-05-03 01:36:28 +04:00
|
|
|
|
|
|
|
typedef std::map<String, Register, std::less<String> > VariableList;
|
2000-03-29 23:19:23 +04:00
|
|
|
|
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,
|
|
|
|
uint32 maxRegister, uint32 maxParameter) :
|
|
|
|
its_iCode(iCode), itsVariables(variables),
|
|
|
|
itsParameterCount(maxParameter), itsMaxRegister(maxRegister),
|
|
|
|
mID(++sMaxID) { }
|
|
|
|
|
|
|
|
Formatter& print(Formatter& f);
|
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-05-05 02:42:49 +04:00
|
|
|
uint32 itsParameterCount;
|
|
|
|
uint32 itsMaxRegister;
|
|
|
|
uint32 mID;
|
|
|
|
static uint32 sMaxID;
|
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
};
|
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 {
|
|
|
|
private:
|
|
|
|
InstructionStream *iCode;
|
|
|
|
LabelList labels;
|
|
|
|
std::vector<ICodeState *> stitcher;
|
2000-05-03 01:36:28 +04:00
|
|
|
StatementLabels *labelSet;
|
|
|
|
|
|
|
|
Register topRegister; // highest (currently) alloacated register
|
|
|
|
Register registerBase; // start of registers available for expression temps
|
|
|
|
uint32 maxRegister; // highest (ever) allocated register
|
|
|
|
uint32 parameterCount; // number of parameters declared for the function
|
|
|
|
// these must come before any variables declared.
|
|
|
|
Register exceptionRegister; // reserved to carry the exception object, only has a value
|
|
|
|
// for functions that contain try/catch statements.
|
|
|
|
Register switchRegister; // register containing switch control value for most
|
|
|
|
// recently in progress switch statement.
|
|
|
|
VariableList *variableList; // name|register pair for each variable
|
|
|
|
|
|
|
|
|
2000-04-01 05:30:32 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
void markMaxRegister() \
|
|
|
|
{ if (topRegister > maxRegister) maxRegister = topRegister; }
|
|
|
|
|
|
|
|
Register getRegister() \
|
|
|
|
{ return topRegister++; }
|
2000-05-03 01:36:28 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
void resetTopRegister() \
|
2000-05-03 01:36:28 +04:00
|
|
|
{ markMaxRegister(); topRegister = registerBase; }
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-04-21 04:37:51 +04:00
|
|
|
void addStitcher(ICodeState *ics) \
|
2000-05-03 01:36:28 +04:00
|
|
|
{ stitcher.push_back(ics); }
|
2000-04-21 04:37:51 +04:00
|
|
|
|
2000-04-27 05:27:09 +04:00
|
|
|
ICodeOp getBranchOp() \
|
2000-04-21 04:37:51 +04:00
|
|
|
{ return (iCode->empty()) ? NOP : iCode->back()->getBranchOp(); }
|
2000-04-20 02:45:57 +04:00
|
|
|
|
2000-05-03 01:36:28 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
void setLabel(Label *label);
|
|
|
|
void setLabel(InstructionStream *stream, Label *label);
|
|
|
|
|
2000-04-27 05:27:09 +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);
|
|
|
|
void branchConditional(Label *label, Register condition);
|
2000-04-21 04:37:51 +04:00
|
|
|
void branchNotConditional(Label *label, Register condition);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-04-27 05:27:09 +04:00
|
|
|
void beginTry(Label *catchLabel, Label *finallyLabel)
|
|
|
|
{ iCode->push_back(new Try(catchLabel, finallyLabel)); }
|
|
|
|
void endTry()
|
|
|
|
{ iCode->push_back(new Endtry()); }
|
2000-05-03 01:36:28 +04:00
|
|
|
|
|
|
|
void resetStatement()
|
|
|
|
{ if (labelSet) { delete labelSet; labelSet = NULL; } resetTopRegister(); }
|
2000-04-22 02:52:52 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
public:
|
2000-05-03 01:36:28 +04:00
|
|
|
ICodeGenerator(World *world = NULL,
|
|
|
|
bool hasTryStatement = false,
|
|
|
|
uint32 switchStatementNesting = 0);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
|
|
|
virtual ~ICodeGenerator() { if (iCode) delete iCode; }
|
|
|
|
|
|
|
|
void mergeStream(InstructionStream *sideStream);
|
|
|
|
|
|
|
|
ICodeModule *complete();
|
2000-04-19 06:09:06 +04:00
|
|
|
|
2000-05-05 02:08:38 +04:00
|
|
|
Register allocateVariable(const StringAtom& name)
|
2000-05-03 01:36:28 +04:00
|
|
|
{ Register result = getRegister(); (*variableList)[name] = result;
|
|
|
|
registerBase = topRegister; return result; }
|
|
|
|
|
2000-05-05 02:08:38 +04:00
|
|
|
Register allocateParameter(const StringAtom& name)
|
2000-05-03 01:36:28 +04:00
|
|
|
{ parameterCount++; return allocateVariable(name); }
|
2000-04-19 01:51:45 +04:00
|
|
|
|
|
|
|
Formatter& print(Formatter& f);
|
|
|
|
|
|
|
|
Register op(ICodeOp op, Register source);
|
|
|
|
Register op(ICodeOp op, Register source1, Register source2);
|
|
|
|
Register call(Register target, RegisterList args);
|
2000-04-19 06:09:06 +04:00
|
|
|
|
|
|
|
void move(Register destination, Register source);
|
2000-04-25 06:55:08 +04:00
|
|
|
void complement(Register destination, Register source);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
|
|
|
Register compare(ICodeOp op, Register source1, Register source2);
|
|
|
|
|
|
|
|
Register loadImmediate(double value);
|
2000-04-20 02:45:57 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
Register newObject();
|
|
|
|
Register newArray();
|
|
|
|
|
2000-05-05 02:08:38 +04:00
|
|
|
Register loadName(const StringAtom &name);
|
|
|
|
void saveName(const StringAtom &name, Register value);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-05-05 02:08:38 +04:00
|
|
|
Register getProperty(Register base, const StringAtom &name);
|
|
|
|
void setProperty(Register base, const StringAtom &name, Register value);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
|
|
|
Register getElement(Register base, Register index);
|
|
|
|
void setElement(Register base, Register index, Register value);
|
|
|
|
|
2000-05-03 01:36:28 +04:00
|
|
|
Register getRegisterBase() { return topRegister; }
|
|
|
|
InstructionStream *get_iCode() { return iCode; }
|
|
|
|
StatementLabels *getStatementLabels() { return labelSet; labelSet = NULL; }
|
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
|
|
|
|
Label *getLabel();
|
|
|
|
|
|
|
|
|
|
|
|
// Rather than have the ICG client maniplate labels and branches, it
|
|
|
|
// uses the following calls to describe the high level looping
|
|
|
|
// constructs being generated. The functions listed below are
|
|
|
|
// expected to be called in the order listed for each construct,
|
|
|
|
// (internal error otherwise).
|
|
|
|
// The ICG will enforce correct nesting and closing.
|
|
|
|
|
|
|
|
// expression statements
|
2000-05-03 01:36:28 +04:00
|
|
|
void beginStatement(uint32 /*pos*/) { }
|
|
|
|
void endStatement() { resetStatement(); }
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-04-21 04:04:14 +04:00
|
|
|
void returnStatement() { iCode->push_back(new ReturnVoid()); }
|
2000-04-19 01:51:45 +04:00
|
|
|
void returnStatement(Register result) \
|
2000-05-03 01:36:28 +04:00
|
|
|
{ iCode->push_back(new Return(result)); resetStatement(); }
|
2000-04-19 01:51:45 +04:00
|
|
|
|
|
|
|
void beginWhileStatement(uint32 pos);
|
|
|
|
void endWhileExpression(Register condition);
|
|
|
|
void endWhileStatement();
|
|
|
|
|
|
|
|
void beginDoStatement(uint32 pos);
|
|
|
|
void endDoStatement();
|
|
|
|
void endDoExpression(Register condition);
|
|
|
|
|
|
|
|
void beginIfStatement(uint32 pos, Register condition);
|
|
|
|
void beginElseStatement(bool hasElse); // required, regardless of
|
|
|
|
// existence of else clause
|
|
|
|
void endIfStatement();
|
|
|
|
|
|
|
|
// for ( ... in ...) statements get turned into generic for
|
|
|
|
// statements by the parser (ok?)
|
|
|
|
void beginForStatement(uint32 pos); // for initialization is
|
|
|
|
// emitted prior to this call
|
|
|
|
void forCondition(Register condition); // required
|
|
|
|
void forIncrement(); // required
|
|
|
|
void endForStatement();
|
|
|
|
|
|
|
|
void beginSwitchStatement(uint32 pos, Register expression);
|
2000-04-18 04:17:34 +04:00
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
void endCaseCondition(Register expression);
|
2000-04-18 04:17:34 +04:00
|
|
|
|
2000-04-21 04:37:51 +04:00
|
|
|
void beginCaseStatement(uint32 pos);
|
2000-04-19 01:51:45 +04:00
|
|
|
void endCaseStatement();
|
|
|
|
|
|
|
|
// optionally
|
2000-04-21 04:37:51 +04:00
|
|
|
void beginDefaultStatement(uint32 pos);
|
2000-04-19 01:51:45 +04:00
|
|
|
void endDefaultStatement();
|
|
|
|
|
|
|
|
void endSwitchStatement();
|
|
|
|
|
2000-04-24 22:41:05 +04:00
|
|
|
void beginLabelStatement(uint32 /* pos */, const StringAtom &label)
|
2000-05-03 01:36:28 +04:00
|
|
|
{ labelSet->push_back(&label); }
|
|
|
|
void endLabelStatement() { labelSet->pop_back(); }
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-04-21 04:37:51 +04:00
|
|
|
void continueStatement(uint32 pos);
|
|
|
|
void breakStatement(uint32 pos);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-04-21 04:37:51 +04:00
|
|
|
void continueStatement(uint32 pos, const StringAtom &label);
|
|
|
|
void breakStatement(uint32 pos, const StringAtom &label);
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-04-24 22:41:05 +04:00
|
|
|
void throwStatement(uint32 /* pos */, Register expression)
|
2000-04-22 02:52:52 +04:00
|
|
|
{ iCode->push_back(new Throw(expression)); }
|
|
|
|
|
|
|
|
void beginTryStatement(uint32 pos, bool hasCatch, bool hasFinally);
|
|
|
|
void endTryBlock();
|
|
|
|
void endTryStatement();
|
2000-04-21 04:37:51 +04:00
|
|
|
|
|
|
|
void beginCatchStatement(uint32 pos);
|
2000-04-27 05:27:09 +04:00
|
|
|
void endCatchExpression(Register exceptionId);
|
2000-04-19 01:51:45 +04:00
|
|
|
void endCatchStatement();
|
|
|
|
|
2000-04-22 02:52:52 +04:00
|
|
|
void beginFinallyStatement(uint32 pos);
|
|
|
|
void endFinallyStatement();
|
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
Formatter& operator<<(Formatter &f, ICodeGenerator &i);
|
|
|
|
/*
|
|
|
|
std::ostream &operator<<(std::ostream &s, ICodeGenerator &i);
|
|
|
|
std::ostream &operator<<(std::ostream &s, StringAtom &str);
|
|
|
|
*/
|
|
|
|
|
|
|
|
class WhileCodeState : public ICodeState {
|
|
|
|
public:
|
2000-04-22 02:52:52 +04:00
|
|
|
WhileCodeState(ICodeGenerator *icg); // inline below
|
2000-04-19 01:51:45 +04:00
|
|
|
InstructionStream *swapStream(InstructionStream *iCode) \
|
|
|
|
{ InstructionStream *t = whileExpressionStream; \
|
|
|
|
whileExpressionStream = iCode; return t; }
|
|
|
|
|
|
|
|
virtual Label *getBreakLabel(ICodeGenerator *icg) \
|
|
|
|
{ if (breakLabel == NULL) breakLabel = icg->getLabel(); \
|
|
|
|
return breakLabel; }
|
|
|
|
virtual Label *getContinueLabel(ICodeGenerator *) \
|
|
|
|
{ return whileCondition; }
|
|
|
|
|
|
|
|
Label *whileCondition;
|
|
|
|
Label *whileBody;
|
|
|
|
InstructionStream *whileExpressionStream;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ForCodeState : public ICodeState {
|
|
|
|
public:
|
2000-04-22 02:52:52 +04:00
|
|
|
ForCodeState(ICodeGenerator *icg); // inline below
|
2000-04-19 01:51:45 +04:00
|
|
|
InstructionStream *swapStream(InstructionStream *iCode) \
|
|
|
|
{ InstructionStream *t = forConditionStream; \
|
|
|
|
forConditionStream = iCode; return t; }
|
|
|
|
InstructionStream *swapStream2(InstructionStream *iCode) \
|
|
|
|
{ InstructionStream *t = forIncrementStream; \
|
|
|
|
forIncrementStream = iCode; return t; }
|
|
|
|
|
|
|
|
virtual Label *getBreakLabel(ICodeGenerator *icg) \
|
|
|
|
{ if (breakLabel == NULL) breakLabel = icg->getLabel(); \
|
|
|
|
return breakLabel; }
|
|
|
|
virtual Label *getContinueLabel(ICodeGenerator *) \
|
|
|
|
{ ASSERT(continueLabel); return continueLabel; }
|
|
|
|
|
|
|
|
Label *forCondition;
|
|
|
|
Label *forBody;
|
|
|
|
InstructionStream *forConditionStream;
|
|
|
|
InstructionStream *forIncrementStream;
|
|
|
|
};
|
|
|
|
|
|
|
|
class IfCodeState : public ICodeState {
|
|
|
|
public:
|
2000-04-22 02:52:52 +04:00
|
|
|
IfCodeState(ICodeGenerator *icg)
|
|
|
|
: ICodeState(If_state, icg), elseLabel(icg->getLabel()), beyondElse(NULL) { }
|
2000-04-19 01:51:45 +04:00
|
|
|
Label *elseLabel;
|
|
|
|
Label *beyondElse;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DoCodeState : public ICodeState {
|
|
|
|
public:
|
2000-04-22 02:52:52 +04:00
|
|
|
DoCodeState(ICodeGenerator *icg)
|
|
|
|
: ICodeState(Do_state, icg), doBody(icg->getLabel()),
|
|
|
|
doCondition(icg->getLabel()) { }
|
2000-04-19 01:51:45 +04:00
|
|
|
|
|
|
|
virtual Label *getBreakLabel(ICodeGenerator *icg) \
|
|
|
|
{ if (breakLabel == NULL) breakLabel = icg->getLabel();
|
|
|
|
return breakLabel; }
|
|
|
|
virtual Label *getContinueLabel(ICodeGenerator *) \
|
|
|
|
{ return doCondition; }
|
|
|
|
|
|
|
|
Label *doBody;
|
|
|
|
Label *doCondition;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SwitchCodeState : public ICodeState {
|
|
|
|
public:
|
|
|
|
SwitchCodeState(Register control, ICodeGenerator *icg); // inline below
|
|
|
|
InstructionStream *swapStream(InstructionStream *iCode) \
|
|
|
|
{ InstructionStream *t = caseStatementsStream; \
|
|
|
|
caseStatementsStream = iCode; return t; }
|
|
|
|
|
|
|
|
virtual Label *getBreakLabel(ICodeGenerator *icg) \
|
|
|
|
{ if (breakLabel == NULL) breakLabel = icg->getLabel();
|
|
|
|
return breakLabel; }
|
|
|
|
|
2000-05-03 01:36:28 +04:00
|
|
|
Register controlValue;
|
2000-04-19 01:51:45 +04:00
|
|
|
Label *defaultLabel;
|
|
|
|
InstructionStream *caseStatementsStream;
|
|
|
|
};
|
|
|
|
|
2000-04-22 02:52:52 +04:00
|
|
|
class TryCodeState : public ICodeState {
|
|
|
|
public:
|
2000-04-27 05:27:09 +04:00
|
|
|
TryCodeState(Label *catchLabel, Label *finallyLabel, ICodeGenerator *icg);
|
2000-04-22 02:52:52 +04:00
|
|
|
Label *catchHandler;
|
|
|
|
Label *finallyHandler;
|
2000-04-27 05:27:09 +04:00
|
|
|
Label *finallyInvoker;
|
2000-04-22 02:52:52 +04:00
|
|
|
Label *beyondCatch;
|
|
|
|
};
|
|
|
|
|
2000-04-19 01:51:45 +04:00
|
|
|
inline ICodeState::ICodeState(StateKind kind, ICodeGenerator *icg)
|
2000-05-03 01:36:28 +04:00
|
|
|
: stateKind(kind),
|
|
|
|
breakLabel(NULL), continueLabel(NULL),
|
|
|
|
labelSet(icg->getStatementLabels()) { }
|
2000-04-19 01:51:45 +04:00
|
|
|
|
|
|
|
inline SwitchCodeState::SwitchCodeState(Register control,
|
|
|
|
ICodeGenerator *icg)
|
2000-05-03 01:36:28 +04:00
|
|
|
: ICodeState(Switch_state, icg), controlValue(control),
|
2000-04-19 01:51:45 +04:00
|
|
|
defaultLabel(NULL), caseStatementsStream(icg->get_iCode()) {}
|
|
|
|
|
2000-04-22 02:52:52 +04:00
|
|
|
inline WhileCodeState::WhileCodeState(ICodeGenerator *icg)
|
|
|
|
: ICodeState(While_state, icg), whileCondition(icg->getLabel()),
|
|
|
|
whileBody(icg->getLabel()), whileExpressionStream(icg->get_iCode()) {}
|
2000-04-19 01:51:45 +04:00
|
|
|
|
2000-04-22 02:52:52 +04:00
|
|
|
inline ForCodeState::ForCodeState(ICodeGenerator *icg)
|
|
|
|
: ICodeState(For_state, icg), forCondition(icg->getLabel()),
|
|
|
|
forBody(icg->getLabel()), forConditionStream(icg->get_iCode()),
|
2000-04-19 01:51:45 +04:00
|
|
|
forIncrementStream(icg->get_iCode()) {}
|
|
|
|
|
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 */
|