This commit is contained in:
rogerl%netscape.com 2000-06-24 01:02:34 +00:00
Родитель 432c8b3cdc
Коммит e497a7809f
4 изменённых файлов: 24 добавлений и 12 удалений

Просмотреть файл

@ -64,7 +64,7 @@ Formatter& operator<<(Formatter &f, ICodeModule &i)
// ICodeGenerator
//
ICodeGenerator::ICodeGenerator(World *world, JSScope *global)
ICodeGenerator::ICodeGenerator(World *world, JSScope *global, JSClass *aClass)
: topRegister(0),
registerBase(0),
maxRegister(0),
@ -74,7 +74,8 @@ ICodeGenerator::ICodeGenerator(World *world, JSScope *global)
mWorld(world),
mGlobal(global),
mInstructionMap(new InstructionMap()),
mWithinWith(false)
mWithinWith(false),
mClass(aClass)
{
iCode = new InstructionStream();
@ -1354,7 +1355,7 @@ TypedRegister ICodeGenerator::genStmt(StmtNode *p, LabelSet *currentLabelSet)
// to handle recursive types, such as linked list nodes.
mGlobal->defineVariable(nameExpr->name, JSValue(thisClass));
if (classStmt->body) {
ICodeGenerator fcg(mWorld, thisClass->getScope());
ICodeGenerator fcg(mWorld, thisClass->getScope(), thisClass);
StmtNode* s = classStmt->body->statements;
while (s) {
switch (s->getKind()) {
@ -1398,8 +1399,8 @@ TypedRegister ICodeGenerator::genStmt(StmtNode *p, LabelSet *currentLabelSet)
case StmtNode::Function:
{
FunctionStmtNode *f = static_cast<FunctionStmtNode *>(p);
ICodeGenerator icg(mWorld, mGlobal);
icg.allocateParameter(mWorld->identifiers[widenCString("this")]); // always parameter #0
ICodeGenerator icg(mWorld, mGlobal, mClass);
icg.allocateParameter(mWorld->identifiers[widenCString("this")], (mClass) ? mClass : &Any_Type); // always parameter #0
VariableBinding *v = f->function.parameters;
while (v) {
if (v->name && (v->name->getKind() == ExprNode::identifier))

Просмотреть файл

@ -40,6 +40,7 @@
#include "utilities.h"
#include "parser.h"
#include "vmtypes.h"
#include "jsclasses.h"
namespace JavaScript {
@ -47,6 +48,7 @@ namespace ICG {
using namespace VM;
using namespace JSTypes;
using namespace JSClasses;
typedef std::map<String, TypedRegister, std::less<String> > VariableList;
typedef std::map<uint32, uint32, std::less<uint32> > InstructionMap;
@ -129,6 +131,7 @@ namespace ICG {
InstructionMap *mInstructionMap;
bool mWithinWith; // state from genStmt that indicates generating code beneath a with statement
JSClass *mClass; // enclosing class when generating code for methods
void markMaxRegister() \
{ if (topRegister > maxRegister) maxRegister = topRegister; }
@ -179,7 +182,7 @@ namespace ICG {
JSType *findType(const StringAtom& typeName);
public:
ICodeGenerator(World *world, JSScope *global);
ICodeGenerator(World *world, JSScope *global, JSClass *aClass = NULL);
~ICodeGenerator()
{
@ -218,6 +221,8 @@ namespace ICG {
{ parameterCount++; return grabRegister(name, &Any_Type); }
TypedRegister allocateParameter(const StringAtom& name, const StringAtom& typeName)
{ parameterCount++; return grabRegister(name, findType(typeName)); }
TypedRegister allocateParameter(const StringAtom& name, JSType *type)
{ parameterCount++; return grabRegister(name, type); }
Formatter& print(Formatter& f);

Просмотреть файл

@ -64,7 +64,7 @@ Formatter& operator<<(Formatter &f, ICodeModule &i)
// ICodeGenerator
//
ICodeGenerator::ICodeGenerator(World *world, JSScope *global)
ICodeGenerator::ICodeGenerator(World *world, JSScope *global, JSClass *aClass)
: topRegister(0),
registerBase(0),
maxRegister(0),
@ -74,7 +74,8 @@ ICodeGenerator::ICodeGenerator(World *world, JSScope *global)
mWorld(world),
mGlobal(global),
mInstructionMap(new InstructionMap()),
mWithinWith(false)
mWithinWith(false),
mClass(aClass)
{
iCode = new InstructionStream();
@ -1354,7 +1355,7 @@ TypedRegister ICodeGenerator::genStmt(StmtNode *p, LabelSet *currentLabelSet)
// to handle recursive types, such as linked list nodes.
mGlobal->defineVariable(nameExpr->name, JSValue(thisClass));
if (classStmt->body) {
ICodeGenerator fcg(mWorld, thisClass->getScope());
ICodeGenerator fcg(mWorld, thisClass->getScope(), thisClass);
StmtNode* s = classStmt->body->statements;
while (s) {
switch (s->getKind()) {
@ -1398,8 +1399,8 @@ TypedRegister ICodeGenerator::genStmt(StmtNode *p, LabelSet *currentLabelSet)
case StmtNode::Function:
{
FunctionStmtNode *f = static_cast<FunctionStmtNode *>(p);
ICodeGenerator icg(mWorld, mGlobal);
icg.allocateParameter(mWorld->identifiers[widenCString("this")]); // always parameter #0
ICodeGenerator icg(mWorld, mGlobal, mClass);
icg.allocateParameter(mWorld->identifiers[widenCString("this")], (mClass) ? mClass : &Any_Type); // always parameter #0
VariableBinding *v = f->function.parameters;
while (v) {
if (v->name && (v->name->getKind() == ExprNode::identifier))

Просмотреть файл

@ -40,6 +40,7 @@
#include "utilities.h"
#include "parser.h"
#include "vmtypes.h"
#include "jsclasses.h"
namespace JavaScript {
@ -47,6 +48,7 @@ namespace ICG {
using namespace VM;
using namespace JSTypes;
using namespace JSClasses;
typedef std::map<String, TypedRegister, std::less<String> > VariableList;
typedef std::map<uint32, uint32, std::less<uint32> > InstructionMap;
@ -129,6 +131,7 @@ namespace ICG {
InstructionMap *mInstructionMap;
bool mWithinWith; // state from genStmt that indicates generating code beneath a with statement
JSClass *mClass; // enclosing class when generating code for methods
void markMaxRegister() \
{ if (topRegister > maxRegister) maxRegister = topRegister; }
@ -179,7 +182,7 @@ namespace ICG {
JSType *findType(const StringAtom& typeName);
public:
ICodeGenerator(World *world, JSScope *global);
ICodeGenerator(World *world, JSScope *global, JSClass *aClass = NULL);
~ICodeGenerator()
{
@ -218,6 +221,8 @@ namespace ICG {
{ parameterCount++; return grabRegister(name, &Any_Type); }
TypedRegister allocateParameter(const StringAtom& name, const StringAtom& typeName)
{ parameterCount++; return grabRegister(name, findType(typeName)); }
TypedRegister allocateParameter(const StringAtom& name, JSType *type)
{ parameterCount++; return grabRegister(name, type); }
Formatter& print(Formatter& f);