Revision: 10663
Author: [email protected]
Date: Thu Feb 9 05:40:41 2012
Log: Extend AST with basic module constructs (yet unused).
[email protected]
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/9373023
http://code.google.com/p/v8/source/detail?r=10663
Modified:
/branches/bleeding_edge/src/ast.cc
/branches/bleeding_edge/src/ast.h
/branches/bleeding_edge/src/full-codegen.cc
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/prettyprinter.cc
/branches/bleeding_edge/src/rewriter.cc
=======================================
--- /branches/bleeding_edge/src/ast.cc Thu Feb 9 05:39:26 2012
+++ /branches/bleeding_edge/src/ast.cc Thu Feb 9 05:40:41 2012
@@ -995,6 +995,11 @@
}
INCREASE_NODE_COUNT(VariableDeclaration)
+INCREASE_NODE_COUNT(ModuleDeclaration)
+INCREASE_NODE_COUNT(ModuleLiteral)
+INCREASE_NODE_COUNT(ModuleVariable)
+INCREASE_NODE_COUNT(ModulePath)
+INCREASE_NODE_COUNT(ModuleUrl)
INCREASE_NODE_COUNT(Block)
INCREASE_NODE_COUNT(ExpressionStatement)
INCREASE_NODE_COUNT(EmptyStatement)
=======================================
--- /branches/bleeding_edge/src/ast.h Thu Feb 9 05:39:26 2012
+++ /branches/bleeding_edge/src/ast.h Thu Feb 9 05:40:41 2012
@@ -61,6 +61,13 @@
#define DECLARATION_NODE_LIST(V) \
V(VariableDeclaration) \
+ V(ModuleDeclaration) \
+
+#define MODULE_NODE_LIST(V) \
+ V(ModuleLiteral) \
+ V(ModuleVariable) \
+ V(ModulePath) \
+ V(ModuleUrl)
#define STATEMENT_NODE_LIST(V) \
V(Block) \
@@ -103,6 +110,7 @@
#define AST_NODE_LIST(V) \
DECLARATION_NODE_LIST(V) \
+ MODULE_NODE_LIST(V) \
STATEMENT_NODE_LIST(V) \
EXPRESSION_NODE_LIST(V)
@@ -111,6 +119,7 @@
template<class> class AstNodeFactory;
class AstVisitor;
class Declaration;
+class Module;
class BreakableStatement;
class Expression;
class IterationStatement;
@@ -300,10 +309,6 @@
// Evaluated for control flow (and side effects).
kTest
};
-
- explicit Expression(Isolate* isolate)
- : id_(GetNextId(isolate)),
- test_id_(GetNextId(isolate)) {}
virtual int position() const {
UNREACHABLE();
@@ -354,6 +359,11 @@
unsigned id() const { return id_; }
unsigned test_id() const { return test_id_; }
+
+ protected:
+ explicit Expression(Isolate* isolate)
+ : id_(GetNextId(isolate)),
+ test_id_(GetNextId(isolate)) {}
private:
int id_;
@@ -495,6 +505,108 @@
};
+class ModuleDeclaration: public Declaration {
+ public:
+ DECLARE_NODE_TYPE(ModuleDeclaration)
+
+ Module* module() const { return module_; }
+
+ protected:
+ template<class> friend class AstNodeFactory;
+
+ ModuleDeclaration(VariableProxy* proxy,
+ Module* module,
+ Scope* scope)
+ : Declaration(proxy, LET, scope),
+ module_(module) {
+ }
+
+ private:
+ Module* module_;
+};
+
+
+class Module: public AstNode {
+ // TODO(rossberg): stuff to come...
+ protected:
+ Module() {}
+};
+
+
+class ModuleLiteral: public Module {
+ public:
+ DECLARE_NODE_TYPE(ModuleLiteral)
+
+ Block* body() const { return body_; }
+
+ protected:
+ template<class> friend class AstNodeFactory;
+
+ ModuleLiteral(Block* body)
+ : body_(body) {
+ }
+
+ private:
+ Block* body_;
+};
+
+
+class ModuleVariable: public Module {
+ public:
+ DECLARE_NODE_TYPE(ModuleVariable)
+
+ Variable* var() const { return var_; }
+
+ protected:
+ template<class> friend class AstNodeFactory;
+
+ ModuleVariable(Variable* var)
+ : var_(var) {
+ }
+
+ private:
+ Variable* var_;
+};
+
+
+class ModulePath: public Module {
+ public:
+ DECLARE_NODE_TYPE(ModulePath)
+
+ Module* module() const { return module_; }
+ Handle<String> name() const { return name_; }
+
+ protected:
+ template<class> friend class AstNodeFactory;
+
+ ModulePath(Module* module, Handle<String> name)
+ : module_(module),
+ name_(name) {
+ }
+
+ private:
+ Module* module_;
+ Handle<String> name_;
+};
+
+
+class ModuleUrl: public Module {
+ public:
+ DECLARE_NODE_TYPE(ModuleUrl)
+
+ Handle<String> url() const { return url_; }
+
+ protected:
+ template<class> friend class AstNodeFactory;
+
+ ModuleUrl(Handle<String> url) : url_(url) {
+ }
+
+ private:
+ Handle<String> url_;
+};
+
+
class IterationStatement: public BreakableStatement {
public:
// Type testing & conversion.
@@ -2399,6 +2511,34 @@
new(zone_) VariableDeclaration(proxy, mode, fun, scope);
VISIT_AND_RETURN(VariableDeclaration, decl)
}
+
+ ModuleDeclaration* NewModuleDeclaration(VariableProxy* proxy,
+ Module* module,
+ Scope* scope) {
+ ModuleDeclaration* decl =
+ new(zone_) ModuleDeclaration(proxy, module, scope);
+ VISIT_AND_RETURN(ModuleDeclaration, decl)
+ }
+
+ ModuleLiteral* NewModuleLiteral(Block* body) {
+ ModuleLiteral* module = new(zone_) ModuleLiteral(body);
+ VISIT_AND_RETURN(ModuleLiteral, module)
+ }
+
+ ModuleVariable* NewModuleVariable(Variable* var) {
+ ModuleVariable* module = new(zone_) ModuleVariable(var);
+ VISIT_AND_RETURN(ModuleLiteral, module)
+ }
+
+ ModulePath* NewModulePath(Module* origin, Handle<String> name) {
+ ModulePath* module = new(zone_) ModulePath(origin, name);
+ VISIT_AND_RETURN(ModuleLiteral, module)
+ }
+
+ ModuleUrl* NewModuleUrl(Handle<String> url) {
+ ModuleUrl* module = new(zone_) ModuleUrl(url);
+ VISIT_AND_RETURN(ModuleLiteral, module)
+ }
Block* NewBlock(ZoneStringList* labels,
int capacity,
=======================================
--- /branches/bleeding_edge/src/full-codegen.cc Thu Feb 9 05:39:26 2012
+++ /branches/bleeding_edge/src/full-codegen.cc Thu Feb 9 05:40:41 2012
@@ -55,6 +55,23 @@
VariableDeclaration* decl) {
}
+void BreakableStatementChecker::VisitModuleDeclaration(
+ ModuleDeclaration* decl) {
+}
+
+
+void BreakableStatementChecker::VisitModuleLiteral(ModuleLiteral* module) {
+}
+
+void BreakableStatementChecker::VisitModuleVariable(ModuleVariable*
module) {
+}
+
+void BreakableStatementChecker::VisitModulePath(ModulePath* module) {
+}
+
+void BreakableStatementChecker::VisitModuleUrl(ModuleUrl* module) {
+}
+
void BreakableStatementChecker::VisitBlock(Block* stmt) {
}
@@ -525,11 +542,6 @@
context->false_label(),
context->fall_through());
}
-
-
-void FullCodeGenerator::VisitVariableDeclaration(VariableDeclaration*
decl) {
- EmitDeclaration(decl->proxy(), decl->mode(), decl->fun());
-}
void FullCodeGenerator::VisitDeclarations(
@@ -578,6 +590,36 @@
global_count_ = save_global_count;
}
+
+
+void FullCodeGenerator::VisitVariableDeclaration(VariableDeclaration*
decl) {
+ EmitDeclaration(decl->proxy(), decl->mode(), decl->fun());
+}
+
+
+void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* decl) {
+ // TODO(rossberg)
+}
+
+
+void FullCodeGenerator::VisitModuleLiteral(ModuleLiteral* module) {
+ // TODO(rossberg)
+}
+
+
+void FullCodeGenerator::VisitModuleVariable(ModuleVariable* module) {
+ // TODO(rossberg)
+}
+
+
+void FullCodeGenerator::VisitModulePath(ModulePath* module) {
+ // TODO(rossberg)
+}
+
+
+void FullCodeGenerator::VisitModuleUrl(ModuleUrl* decl) {
+ // TODO(rossberg)
+}
int FullCodeGenerator::DeclareGlobalsFlags() {
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Thu Feb 9 05:39:26 2012
+++ /branches/bleeding_edge/src/hydrogen.cc Thu Feb 9 05:40:41 2012
@@ -6580,6 +6580,31 @@
return Bailout("unsupported lookup slot in declaration");
}
}
+
+
+void HGraphBuilder::VisitModuleDeclaration(ModuleDeclaration* decl) {
+ // TODO(rossberg)
+}
+
+
+void HGraphBuilder::VisitModuleLiteral(ModuleLiteral* module) {
+ // TODO(rossberg)
+}
+
+
+void HGraphBuilder::VisitModuleVariable(ModuleVariable* module) {
+ // TODO(rossberg)
+}
+
+
+void HGraphBuilder::VisitModulePath(ModulePath* module) {
+ // TODO(rossberg)
+}
+
+
+void HGraphBuilder::VisitModuleUrl(ModuleUrl* module) {
+ // TODO(rossberg)
+}
// Generators for inline runtime functions.
=======================================
--- /branches/bleeding_edge/src/prettyprinter.cc Thu Feb 9 05:39:26 2012
+++ /branches/bleeding_edge/src/prettyprinter.cc Thu Feb 9 05:40:41 2012
@@ -67,6 +67,38 @@
}
Print(";");
}
+
+
+void PrettyPrinter::VisitModuleDeclaration(ModuleDeclaration* node) {
+ Print("module ");
+ PrintLiteral(node->proxy()->name(), false);
+ Print(" = ");
+ Visit(node->module());
+ Print(";");
+}
+
+
+void PrettyPrinter::VisitModuleLiteral(ModuleLiteral* node) {
+ VisitBlock(node->body());
+}
+
+
+void PrettyPrinter::VisitModuleVariable(ModuleVariable* node) {
+ PrintLiteral(node->var()->name(), false);
+}
+
+
+void PrettyPrinter::VisitModulePath(ModulePath* node) {
+ Visit(node->module());
+ Print(".");
+ PrintLiteral(node->name(), false);
+}
+
+
+void PrettyPrinter::VisitModuleUrl(ModuleUrl* node) {
+ Print("at ");
+ PrintLiteral(node->url(), true);
+}
void PrettyPrinter::VisitExpressionStatement(ExpressionStatement* node) {
@@ -726,6 +758,35 @@
Print("\n");
}
}
+
+
+void AstPrinter::VisitModuleDeclaration(ModuleDeclaration* node) {
+ IndentedScope indent(this, "MODULE");
+ PrintLiteralIndented("NAME", node->proxy()->name(), true);
+ Visit(node->module());
+}
+
+
+void AstPrinter::VisitModuleLiteral(ModuleLiteral* node) {
+ VisitBlock(node->body());
+}
+
+
+void AstPrinter::VisitModuleVariable(ModuleVariable* node) {
+ PrintLiteralIndented("VARIABLE", node->var()->name(), false);
+}
+
+
+void AstPrinter::VisitModulePath(ModulePath* node) {
+ IndentedScope indent(this, "PATH");
+ PrintIndentedVisit("MODULE", node->module());
+ PrintLiteralIndented("NAME", node->name(), false);
+}
+
+
+void AstPrinter::VisitModuleUrl(ModuleUrl* node) {
+ PrintLiteralIndented("URL", node->url(), true);
+}
void AstPrinter::VisitExpressionStatement(ExpressionStatement* node) {
=======================================
--- /branches/bleeding_edge/src/rewriter.cc Thu Feb 9 05:39:26 2012
+++ /branches/bleeding_edge/src/rewriter.cc Thu Feb 9 05:40:41 2012
@@ -210,6 +210,11 @@
// Do nothing:
void Processor::VisitVariableDeclaration(VariableDeclaration* node) {}
+void Processor::VisitModuleDeclaration(ModuleDeclaration* node) {}
+void Processor::VisitModuleLiteral(ModuleLiteral* node) {}
+void Processor::VisitModuleVariable(ModuleVariable* node) {}
+void Processor::VisitModulePath(ModulePath* node) {}
+void Processor::VisitModuleUrl(ModuleUrl* node) {}
void Processor::VisitEmptyStatement(EmptyStatement* node) {}
void Processor::VisitReturnStatement(ReturnStatement* node) {}
void Processor::VisitDebuggerStatement(DebuggerStatement* node) {}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev