Nicolas Petton 12 лет назад
Родитель
Сommit
9b4eda8ba9

+ 25 - 0
js/Compiler-Exceptions.deploy.js

@@ -8,6 +8,31 @@ smalltalk.addClass('ParseError', smalltalk.CompilerError, [], 'Compiler-Exceptio
 smalltalk.addClass('SemanticError', smalltalk.CompilerError, [], 'Compiler-Exceptions');
 smalltalk.addClass('SemanticError', smalltalk.CompilerError, [], 'Compiler-Exceptions');
 
 
 
 
+smalltalk.addClass('InvalidAssignmentError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
+smalltalk.addMethod(
+"_variableName",
+smalltalk.method({
+selector: "variableName",
+fn: function () {
+var self=this;
+return self['@variableName'];
+return self;}
+}),
+smalltalk.InvalidAssignmentError);
+
+smalltalk.addMethod(
+"_variableName_",
+smalltalk.method({
+selector: "variableName:",
+fn: function (aString) {
+var self=this;
+(self['@variableName']=aString);
+return self;}
+}),
+smalltalk.InvalidAssignmentError);
+
+
+
 smalltalk.addClass('ShadowingVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
 smalltalk.addClass('ShadowingVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_variableName",
 "_variableName",

+ 36 - 0
js/Compiler-Exceptions.js

@@ -9,6 +9,42 @@ smalltalk.addClass('SemanticError', smalltalk.CompilerError, [], 'Compiler-Excep
 smalltalk.SemanticError.comment="I represent an abstract semantic error thrown by the SemanticAnalyzer.\x0aSemantic errors can be unknown variable errors, etc.\x0aSee my subclasses for concrete errors.\x0a\x0aThe IDE should catch instances of Semantic error to deal with them when compiling"
 smalltalk.SemanticError.comment="I represent an abstract semantic error thrown by the SemanticAnalyzer.\x0aSemantic errors can be unknown variable errors, etc.\x0aSee my subclasses for concrete errors.\x0a\x0aThe IDE should catch instances of Semantic error to deal with them when compiling"
 
 
 
 
+smalltalk.addClass('InvalidAssignmentError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
+smalltalk.InvalidAssignmentError.comment="I get signaled when a pseudo variable gets assigned."
+smalltalk.addMethod(
+"_variableName",
+smalltalk.method({
+selector: "variableName",
+category: 'accessing',
+fn: function () {
+var self=this;
+return self['@variableName'];
+return self;},
+args: [],
+source: "variableName\x0a\x09^ variableName",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.InvalidAssignmentError);
+
+smalltalk.addMethod(
+"_variableName_",
+smalltalk.method({
+selector: "variableName:",
+category: 'accessing',
+fn: function (aString) {
+var self=this;
+(self['@variableName']=aString);
+return self;},
+args: ["aString"],
+source: "variableName: aString\x0a\x09variableName := aString",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.InvalidAssignmentError);
+
+
+
 smalltalk.addClass('ShadowingVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
 smalltalk.addClass('ShadowingVariableError', smalltalk.SemanticError, ['variableName'], 'Compiler-Exceptions');
 smalltalk.ShadowingVariableError.comment="I get signaled when a variable in a block or method scope shadows a variable of the same name in an outer scope."
 smalltalk.ShadowingVariableError.comment="I get signaled when a variable in a block or method scope shadows a variable of the same name in an outer scope."
 smalltalk.addMethod(
 smalltalk.addMethod(

+ 325 - 3
js/Compiler-IR.deploy.js

@@ -169,8 +169,8 @@ fn: function (aNode) {
 var self=this;
 var self=this;
 ((($receiver = smalltalk.send(aNode, "_isBlockSequenceNode", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_resolve_", [each]);})]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_resolve_", [each]);})]);})]));
 ((($receiver = smalltalk.send(aNode, "_isBlockSequenceNode", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_resolve_", [each]);})]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_resolve_", [each]);})]);})]));
 ((($receiver = smalltalk.send(aNode, "_shouldBeAliased", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){var alias=nil;
 ((($receiver = smalltalk.send(aNode, "_shouldBeAliased", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){var alias=nil;
-(alias=smalltalk.send(self, "_nextAlias", []));smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_method", []), "_internalVariables", []), "_add_", [alias]);(function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [smalltalk.send(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []), "_name_", [alias])]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_resolving_", [aNode, false]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_assignment", []));return smalltalk.send(aNode, "_alias_", [alias]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){var alias=nil;
-(alias=smalltalk.send(self, "_nextAlias", []));smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_method", []), "_internalVariables", []), "_add_", [alias]);(function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [smalltalk.send(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []), "_name_", [alias])]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_resolving_", [aNode, false]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_assignment", []));return smalltalk.send(aNode, "_alias_", [alias]);})]));
+(alias=smalltalk.send(self, "_nextAlias", []));smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_method", []), "_internalVariables", []), "_add_", [alias]);(function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [(function($rec){smalltalk.send($rec, "_name_", [alias]);smalltalk.send($rec, "_node_", [aNode]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []))]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_resolving_", [aNode, false]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_assignment", []));return smalltalk.send(aNode, "_alias_", [alias]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){var alias=nil;
+(alias=smalltalk.send(self, "_nextAlias", []));smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_method", []), "_internalVariables", []), "_add_", [alias]);(function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [(function($rec){smalltalk.send($rec, "_name_", [alias]);smalltalk.send($rec, "_node_", [aNode]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []))]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_resolving_", [aNode, false]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_assignment", []));return smalltalk.send(aNode, "_alias_", [alias]);})]));
 return self;}
 return self;}
 }),
 }),
 smalltalk.IRASTResolver);
 smalltalk.IRASTResolver);
@@ -204,7 +204,7 @@ smalltalk.method({
 selector: "visitAliased:",
 selector: "visitAliased:",
 fn: function (aNode) {
 fn: function (aNode) {
 var self=this;
 var self=this;
-return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [smalltalk.send(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []), "_name_", [smalltalk.send(aNode, "_alias", [])])]);
+return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [(function($rec){smalltalk.send($rec, "_name_", [smalltalk.send(aNode, "_alias", [])]);smalltalk.send($rec, "_node_", [aNode]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []))]);
 return self;}
 return self;}
 }),
 }),
 smalltalk.IRASTResolver);
 smalltalk.IRASTResolver);
@@ -471,6 +471,17 @@ smalltalk.IRBuilder);
 
 
 
 
 smalltalk.addClass('IRInstruction', smalltalk.Object, ['builder', 'instructions'], 'Compiler-IR');
 smalltalk.addClass('IRInstruction', smalltalk.Object, ['builder', 'instructions'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRInstruction_", [self]);
+return self;}
+}),
+smalltalk.IRInstruction);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_append_",
 "_append_",
 smalltalk.method({
 smalltalk.method({
@@ -600,6 +611,17 @@ smalltalk.IRInstruction.klass);
 
 
 
 
 smalltalk.addClass('IRAssignment', smalltalk.IRInstruction, ['left', 'right'], 'Compiler-IR');
 smalltalk.addClass('IRAssignment', smalltalk.IRInstruction, ['left', 'right'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRAssignment_", [self]);
+return self;}
+}),
+smalltalk.IRAssignment);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -614,6 +636,17 @@ smalltalk.IRAssignment);
 
 
 
 
 smalltalk.addClass('IRClosure', smalltalk.IRInstruction, ['arguments'], 'Compiler-IR');
 smalltalk.addClass('IRClosure', smalltalk.IRInstruction, ['arguments'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRClosure_", [self]);
+return self;}
+}),
+smalltalk.IRClosure);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_arguments",
 "_arguments",
 smalltalk.method({
 smalltalk.method({
@@ -650,6 +683,17 @@ smalltalk.IRClosure);
 
 
 
 
 smalltalk.addClass('IRMethod', smalltalk.IRInstruction, ['source', 'selector', 'classReferences', 'messageSends', 'arguments', 'internalVariables', 'source'], 'Compiler-IR');
 smalltalk.addClass('IRMethod', smalltalk.IRInstruction, ['source', 'selector', 'classReferences', 'messageSends', 'arguments', 'internalVariables', 'source'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRMethod_", [self]);
+return self;}
+}),
+smalltalk.IRMethod);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_arguments",
 "_arguments",
 smalltalk.method({
 smalltalk.method({
@@ -785,6 +829,17 @@ smalltalk.IRMethod);
 
 
 
 
 smalltalk.addClass('IRNonLocalReturn', smalltalk.IRInstruction, [], 'Compiler-IR');
 smalltalk.addClass('IRNonLocalReturn', smalltalk.IRInstruction, [], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRNonLocalReturn_", [self]);
+return self;}
+}),
+smalltalk.IRNonLocalReturn);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -799,6 +854,17 @@ smalltalk.IRNonLocalReturn);
 
 
 
 
 smalltalk.addClass('IRNonLocalReturnHandling', smalltalk.IRInstruction, [], 'Compiler-IR');
 smalltalk.addClass('IRNonLocalReturnHandling', smalltalk.IRInstruction, [], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRNonLocalReturnHandling_", [self]);
+return self;}
+}),
+smalltalk.IRNonLocalReturnHandling);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -813,6 +879,17 @@ smalltalk.IRNonLocalReturnHandling);
 
 
 
 
 smalltalk.addClass('IRReturn', smalltalk.IRInstruction, [], 'Compiler-IR');
 smalltalk.addClass('IRReturn', smalltalk.IRInstruction, [], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRReturn_", [self]);
+return self;}
+}),
+smalltalk.IRReturn);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -827,6 +904,17 @@ smalltalk.IRReturn);
 
 
 
 
 smalltalk.addClass('IRSend', smalltalk.IRInstruction, ['selector', 'superSend'], 'Compiler-IR');
 smalltalk.addClass('IRSend', smalltalk.IRInstruction, ['selector', 'superSend'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRSend_", [self]);
+return self;}
+}),
+smalltalk.IRSend);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -889,6 +977,17 @@ smalltalk.IRSend);
 
 
 
 
 smalltalk.addClass('IRSequence', smalltalk.IRInstruction, [], 'Compiler-IR');
 smalltalk.addClass('IRSequence', smalltalk.IRInstruction, [], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRSequence_", [self]);
+return self;}
+}),
+smalltalk.IRSequence);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_appendInstruction_",
 "_appendInstruction_",
 smalltalk.method({
 smalltalk.method({
@@ -914,6 +1013,17 @@ smalltalk.IRSequence);
 
 
 
 
 smalltalk.addClass('IRStatement', smalltalk.IRInstruction, ['pc'], 'Compiler-IR');
 smalltalk.addClass('IRStatement', smalltalk.IRInstruction, ['pc'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRStatement_", [self]);
+return self;}
+}),
+smalltalk.IRStatement);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -939,6 +1049,17 @@ smalltalk.IRStatement);
 
 
 
 
 smalltalk.addClass('IRTempDeclaration', smalltalk.IRInstruction, ['name'], 'Compiler-IR');
 smalltalk.addClass('IRTempDeclaration', smalltalk.IRInstruction, ['name'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRTempDeclaration_", [self]);
+return self;}
+}),
+smalltalk.IRTempDeclaration);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -975,6 +1096,17 @@ smalltalk.IRTempDeclaration);
 
 
 
 
 smalltalk.addClass('IRValue', smalltalk.IRInstruction, ['value'], 'Compiler-IR');
 smalltalk.addClass('IRValue', smalltalk.IRInstruction, ['value'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRValue_", [self]);
+return self;}
+}),
+smalltalk.IRValue);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -1011,6 +1143,17 @@ smalltalk.IRValue);
 
 
 
 
 smalltalk.addClass('IRVariable', smalltalk.IRInstruction, ['variable'], 'Compiler-IR');
 smalltalk.addClass('IRVariable', smalltalk.IRInstruction, ['variable'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRVariable_", [self]);
+return self;}
+}),
+smalltalk.IRVariable);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -1047,6 +1190,17 @@ smalltalk.IRVariable);
 
 
 
 
 smalltalk.addClass('IRVerbatim', smalltalk.IRInstruction, ['source'], 'Compiler-IR');
 smalltalk.addClass('IRVerbatim', smalltalk.IRInstruction, ['source'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRVerbatim_", [self]);
+return self;}
+}),
+smalltalk.IRVerbatim);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -1082,6 +1236,174 @@ smalltalk.IRVerbatim);
 
 
 
 
 
 
+smalltalk.addClass('IRVisitor', smalltalk.Object, [], 'Compiler-IR');
+smalltalk.addMethod(
+"_visit_",
+smalltalk.method({
+selector: "visit:",
+fn: function (anIRInstruction) {
+var self=this;
+smalltalk.send(anIRInstruction, "_accept_", [self]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRAssignment_",
+smalltalk.method({
+selector: "visitIRAssignment:",
+fn: function (anIRAssignment) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRAssignment]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRClosure_",
+smalltalk.method({
+selector: "visitIRClosure:",
+fn: function (anIRClosure) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRClosure]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRInstruction_",
+smalltalk.method({
+selector: "visitIRInstruction:",
+fn: function (anIRInstruction) {
+var self=this;
+smalltalk.send(smalltalk.send(anIRInstruction, "_instructions", []), "_do_", [(function(each){return smalltalk.send(self, "_visit_", [each]);})]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRMethod_",
+smalltalk.method({
+selector: "visitIRMethod:",
+fn: function (anIRMethod) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRMethod]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRNonLocalReturn_",
+smalltalk.method({
+selector: "visitIRNonLocalReturn:",
+fn: function (anIRNonLocalReturn) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRNonLocalReturn]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRNonLocalReturnHandling_",
+smalltalk.method({
+selector: "visitIRNonLocalReturnHandling:",
+fn: function (anIRNonLocalReturnHandling) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRNonLocalReturnHandling]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRReturn_",
+smalltalk.method({
+selector: "visitIRReturn:",
+fn: function (anIRReturn) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRReturn]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRSend_",
+smalltalk.method({
+selector: "visitIRSend:",
+fn: function (anIRSend) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRSend]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRSequence_",
+smalltalk.method({
+selector: "visitIRSequence:",
+fn: function (anIRSequence) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRSequence]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRStatement_",
+smalltalk.method({
+selector: "visitIRStatement:",
+fn: function (anIRStatement) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRStatement]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRTempDeclaration_",
+smalltalk.method({
+selector: "visitIRTempDeclaration:",
+fn: function (anIRTempDeclaration) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRTempDeclaration]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRValue_",
+smalltalk.method({
+selector: "visitIRValue:",
+fn: function (anIRValue) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRValue]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRVariable_",
+smalltalk.method({
+selector: "visitIRVariable:",
+fn: function (anIRVariable) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRVariable]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRVerbatim_",
+smalltalk.method({
+selector: "visitIRVerbatim:",
+fn: function (anIRVerbatim) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRVerbatim]);
+return self;}
+}),
+smalltalk.IRVisitor);
+
+
+
 smalltalk.addClass('JSStream', smalltalk.Object, ['stream'], 'Compiler-IR');
 smalltalk.addClass('JSStream', smalltalk.Object, ['stream'], 'Compiler-IR');
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_contents",
 "_contents",

+ 476 - 9
js/Compiler-IR.js

@@ -242,12 +242,12 @@ fn: function (aNode) {
 var self=this;
 var self=this;
 ((($receiver = smalltalk.send(aNode, "_isBlockSequenceNode", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_resolve_", [each]);})]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_resolve_", [each]);})]);})]));
 ((($receiver = smalltalk.send(aNode, "_isBlockSequenceNode", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_resolve_", [each]);})]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(self, "_resolve_", [each]);})]);})]));
 ((($receiver = smalltalk.send(aNode, "_shouldBeAliased", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){var alias=nil;
 ((($receiver = smalltalk.send(aNode, "_shouldBeAliased", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){var alias=nil;
-(alias=smalltalk.send(self, "_nextAlias", []));smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_method", []), "_internalVariables", []), "_add_", [alias]);(function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [smalltalk.send(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []), "_name_", [alias])]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_resolving_", [aNode, false]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_assignment", []));return smalltalk.send(aNode, "_alias_", [alias]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){var alias=nil;
-(alias=smalltalk.send(self, "_nextAlias", []));smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_method", []), "_internalVariables", []), "_add_", [alias]);(function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [smalltalk.send(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []), "_name_", [alias])]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_resolving_", [aNode, false]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_assignment", []));return smalltalk.send(aNode, "_alias_", [alias]);})]));
+(alias=smalltalk.send(self, "_nextAlias", []));smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_method", []), "_internalVariables", []), "_add_", [alias]);(function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [(function($rec){smalltalk.send($rec, "_name_", [alias]);smalltalk.send($rec, "_node_", [aNode]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []))]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_resolving_", [aNode, false]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_assignment", []));return smalltalk.send(aNode, "_alias_", [alias]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){var alias=nil;
+(alias=smalltalk.send(self, "_nextAlias", []));smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self, "_builder", []), "_method", []), "_internalVariables", []), "_add_", [alias]);(function($rec){smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [(function($rec){smalltalk.send($rec, "_name_", [alias]);smalltalk.send($rec, "_node_", [aNode]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []))]);})]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self, "_visit_resolving_", [aNode, false]);})]);})(smalltalk.send(smalltalk.send(self, "_builder", []), "_assignment", []));return smalltalk.send(aNode, "_alias_", [alias]);})]));
 return self;},
 return self;},
 args: ["aNode"],
 args: ["aNode"],
-source: "resolve: aNode\x0a\x09aNode isBlockSequenceNode ifFalse: [\x0a\x09\x09aNode nodes do: [ :each | self resolve: each ]].\x0a\x09aNode shouldBeAliased ifTrue: [\x0a\x09\x09| alias |\x0a\x09\x09alias := self nextAlias.\x0a\x09\x09self builder method internalVariables add: alias.\x0a\x09\x09self builder assignment\x0a\x09\x09\x09with: [ self builder variable: (AliasVar new name: alias) ];\x0a\x09\x09\x09with: [ self visit: aNode resolving: false ].\x0a\x09\x09\x09aNode alias: alias ]",
-messageSends: ["ifFalse:", "isBlockSequenceNode", "do:", "nodes", "resolve:", "ifTrue:", "shouldBeAliased", "nextAlias", "add:", "internalVariables", "method", "builder", "with:", "variable:", "name:", "new", "visit:resolving:", "assignment", "alias:"],
+source: "resolve: aNode\x0a\x09aNode isBlockSequenceNode ifFalse: [\x0a\x09\x09aNode nodes do: [ :each | self resolve: each ]].\x0a\x09aNode shouldBeAliased ifTrue: [\x0a\x09\x09| alias |\x0a\x09\x09alias := self nextAlias.\x0a\x09\x09self builder method internalVariables add: alias.\x0a\x09\x09self builder assignment\x0a\x09\x09\x09with: [ self builder variable: (AliasVar new \x0a\x09\x09\x09\x09name: alias;\x0a\x09\x09\x09\x09node: aNode;\x0a\x09\x09\x09\x09yourself) ];\x0a\x09\x09\x09with: [ self visit: aNode resolving: false ].\x0a\x09\x09\x09aNode alias: alias ]",
+messageSends: ["ifFalse:", "isBlockSequenceNode", "do:", "nodes", "resolve:", "ifTrue:", "shouldBeAliased", "nextAlias", "add:", "internalVariables", "method", "builder", "with:", "variable:", "name:", "node:", "yourself", "new", "visit:resolving:", "assignment", "alias:"],
 referencedClasses: ["AliasVar"]
 referencedClasses: ["AliasVar"]
 }),
 }),
 smalltalk.IRASTResolver);
 smalltalk.IRASTResolver);
@@ -292,11 +292,11 @@ selector: "visitAliased:",
 category: 'visiting',
 category: 'visiting',
 fn: function (aNode) {
 fn: function (aNode) {
 var self=this;
 var self=this;
-return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [smalltalk.send(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []), "_name_", [smalltalk.send(aNode, "_alias", [])])]);
+return smalltalk.send(smalltalk.send(self, "_builder", []), "_variable_", [(function($rec){smalltalk.send($rec, "_name_", [smalltalk.send(aNode, "_alias", [])]);smalltalk.send($rec, "_node_", [aNode]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.AliasVar || AliasVar), "_new", []))]);
 return self;},
 return self;},
 args: ["aNode"],
 args: ["aNode"],
-source: "visitAliased: aNode\x0a\x09^ self builder variable: (AliasVar new name: aNode alias)",
-messageSends: ["variable:", "builder", "name:", "new", "alias"],
+source: "visitAliased: aNode\x0a\x09^ self builder variable: (AliasVar new \x0a\x09\x09name: aNode alias;\x0a\x09\x09node: aNode;\x0a\x09\x09yourself)",
+messageSends: ["variable:", "builder", "name:", "alias", "node:", "yourself", "new"],
 referencedClasses: ["AliasVar"]
 referencedClasses: ["AliasVar"]
 }),
 }),
 smalltalk.IRASTResolver);
 smalltalk.IRASTResolver);
@@ -680,6 +680,22 @@ smalltalk.IRBuilder);
 
 
 smalltalk.addClass('IRInstruction', smalltalk.Object, ['builder', 'instructions'], 'Compiler-IR');
 smalltalk.addClass('IRInstruction', smalltalk.Object, ['builder', 'instructions'], 'Compiler-IR');
 smalltalk.IRInstruction.comment="I am the abstract root class of the IR (intermediate representation) instructions class hierarchy.\x0aThe IR graph is used to emit JavaScript code using a JSStream. "
 smalltalk.IRInstruction.comment="I am the abstract root class of the IR (intermediate representation) instructions class hierarchy.\x0aThe IR graph is used to emit JavaScript code using a JSStream. "
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRInstruction_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRInstruction: self",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRInstruction);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_append_",
 "_append_",
 smalltalk.method({
 smalltalk.method({
@@ -864,6 +880,22 @@ smalltalk.IRInstruction.klass);
 
 
 
 
 smalltalk.addClass('IRAssignment', smalltalk.IRInstruction, ['left', 'right'], 'Compiler-IR');
 smalltalk.addClass('IRAssignment', smalltalk.IRInstruction, ['left', 'right'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRAssignment_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRAssignment: self",
+messageSends: ["visitIRAssignment:"],
+referencedClasses: []
+}),
+smalltalk.IRAssignment);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -883,6 +915,22 @@ smalltalk.IRAssignment);
 
 
 
 
 smalltalk.addClass('IRClosure', smalltalk.IRInstruction, ['arguments'], 'Compiler-IR');
 smalltalk.addClass('IRClosure', smalltalk.IRInstruction, ['arguments'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRClosure_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRClosure: self",
+messageSends: ["visitIRClosure:"],
+referencedClasses: []
+}),
+smalltalk.IRClosure);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_arguments",
 "_arguments",
 smalltalk.method({
 smalltalk.method({
@@ -935,6 +983,22 @@ smalltalk.IRClosure);
 
 
 smalltalk.addClass('IRMethod', smalltalk.IRInstruction, ['source', 'selector', 'classReferences', 'messageSends', 'arguments', 'internalVariables', 'source'], 'Compiler-IR');
 smalltalk.addClass('IRMethod', smalltalk.IRInstruction, ['source', 'selector', 'classReferences', 'messageSends', 'arguments', 'internalVariables', 'source'], 'Compiler-IR');
 smalltalk.IRMethod.comment="I am a method instruction"
 smalltalk.IRMethod.comment="I am a method instruction"
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'emiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRMethod_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRMethod: self",
+messageSends: ["visitIRMethod:"],
+referencedClasses: []
+}),
+smalltalk.IRMethod);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_arguments",
 "_arguments",
 smalltalk.method({
 smalltalk.method({
@@ -1131,6 +1195,22 @@ smalltalk.IRMethod);
 
 
 smalltalk.addClass('IRNonLocalReturn', smalltalk.IRInstruction, [], 'Compiler-IR');
 smalltalk.addClass('IRNonLocalReturn', smalltalk.IRInstruction, [], 'Compiler-IR');
 smalltalk.IRNonLocalReturn.comment="I am a non local return instruction.\x0aNon local returns are handled using a try/catch JS statement.\x0a\x0aSee IRNonLocalReturnHandling class"
 smalltalk.IRNonLocalReturn.comment="I am a non local return instruction.\x0aNon local returns are handled using a try/catch JS statement.\x0a\x0aSee IRNonLocalReturnHandling class"
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRNonLocalReturn_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRNonLocalReturn: self",
+messageSends: ["visitIRNonLocalReturn:"],
+referencedClasses: []
+}),
+smalltalk.IRNonLocalReturn);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -1151,6 +1231,22 @@ smalltalk.IRNonLocalReturn);
 
 
 smalltalk.addClass('IRNonLocalReturnHandling', smalltalk.IRInstruction, [], 'Compiler-IR');
 smalltalk.addClass('IRNonLocalReturnHandling', smalltalk.IRInstruction, [], 'Compiler-IR');
 smalltalk.IRNonLocalReturnHandling.comment="I represent a non local return handling instruction.\x0aNon local returns are handled with a try/catch statement"
 smalltalk.IRNonLocalReturnHandling.comment="I represent a non local return handling instruction.\x0aNon local returns are handled with a try/catch statement"
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRNonLocalReturnHandling_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRNonLocalReturnHandling: self",
+messageSends: ["visitIRNonLocalReturnHandling:"],
+referencedClasses: []
+}),
+smalltalk.IRNonLocalReturnHandling);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -1171,6 +1267,22 @@ smalltalk.IRNonLocalReturnHandling);
 
 
 smalltalk.addClass('IRReturn', smalltalk.IRInstruction, [], 'Compiler-IR');
 smalltalk.addClass('IRReturn', smalltalk.IRInstruction, [], 'Compiler-IR');
 smalltalk.IRReturn.comment="I am a local return instruction."
 smalltalk.IRReturn.comment="I am a local return instruction."
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRReturn_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRReturn: self",
+messageSends: ["visitIRReturn:"],
+referencedClasses: []
+}),
+smalltalk.IRReturn);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -1191,6 +1303,22 @@ smalltalk.IRReturn);
 
 
 smalltalk.addClass('IRSend', smalltalk.IRInstruction, ['selector', 'superSend'], 'Compiler-IR');
 smalltalk.addClass('IRSend', smalltalk.IRInstruction, ['selector', 'superSend'], 'Compiler-IR');
 smalltalk.IRSend.comment="I am a message send instruction. "
 smalltalk.IRSend.comment="I am a message send instruction. "
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRSend_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRSend: self",
+messageSends: ["visitIRSend:"],
+referencedClasses: []
+}),
+smalltalk.IRSend);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -1278,6 +1406,22 @@ smalltalk.IRSend);
 
 
 
 
 smalltalk.addClass('IRSequence', smalltalk.IRInstruction, [], 'Compiler-IR');
 smalltalk.addClass('IRSequence', smalltalk.IRInstruction, [], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRSequence_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRSequence: self",
+messageSends: ["visitIRSequence:"],
+referencedClasses: []
+}),
+smalltalk.IRSequence);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_appendInstruction_",
 "_appendInstruction_",
 smalltalk.method({
 smalltalk.method({
@@ -1314,6 +1458,22 @@ smalltalk.IRSequence);
 
 
 smalltalk.addClass('IRStatement', smalltalk.IRInstruction, ['pc'], 'Compiler-IR');
 smalltalk.addClass('IRStatement', smalltalk.IRInstruction, ['pc'], 'Compiler-IR');
 smalltalk.IRStatement.comment="I am a statement instruction. \x0aStatements can be used to control the PC count, among other things."
 smalltalk.IRStatement.comment="I am a statement instruction. \x0aStatements can be used to control the PC count, among other things."
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRStatement_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRStatement: self",
+messageSends: ["visitIRStatement:"],
+referencedClasses: []
+}),
+smalltalk.IRStatement);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -1350,6 +1510,22 @@ smalltalk.IRStatement);
 
 
 smalltalk.addClass('IRTempDeclaration', smalltalk.IRInstruction, ['name'], 'Compiler-IR');
 smalltalk.addClass('IRTempDeclaration', smalltalk.IRInstruction, ['name'], 'Compiler-IR');
 smalltalk.IRTempDeclaration.comment="I am a temporary variable declaration instruction"
 smalltalk.IRTempDeclaration.comment="I am a temporary variable declaration instruction"
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRTempDeclaration_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRTempDeclaration: self",
+messageSends: ["visitIRTempDeclaration:"],
+referencedClasses: []
+}),
+smalltalk.IRTempDeclaration);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -1402,6 +1578,22 @@ smalltalk.IRTempDeclaration);
 
 
 smalltalk.addClass('IRValue', smalltalk.IRInstruction, ['value'], 'Compiler-IR');
 smalltalk.addClass('IRValue', smalltalk.IRInstruction, ['value'], 'Compiler-IR');
 smalltalk.IRValue.comment="I am the simplest possible instruction. I represent a value."
 smalltalk.IRValue.comment="I am the simplest possible instruction. I represent a value."
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'emiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRValue_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRValue: self",
+messageSends: ["visitIRValue:"],
+referencedClasses: []
+}),
+smalltalk.IRValue);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -1438,7 +1630,7 @@ smalltalk.addMethod(
 "_value_",
 "_value_",
 smalltalk.method({
 smalltalk.method({
 selector: "value:",
 selector: "value:",
-category: 'accessing',
+category: 'visiting',
 fn: function (aString) {
 fn: function (aString) {
 var self=this;
 var self=this;
 (self['@value']=aString);
 (self['@value']=aString);
@@ -1454,11 +1646,27 @@ smalltalk.IRValue);
 
 
 smalltalk.addClass('IRVariable', smalltalk.IRInstruction, ['variable'], 'Compiler-IR');
 smalltalk.addClass('IRVariable', smalltalk.IRInstruction, ['variable'], 'Compiler-IR');
 smalltalk.IRVariable.comment="I am a variable instruction."
 smalltalk.IRVariable.comment="I am a variable instruction."
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'emiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRVariable_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRVariable: self",
+messageSends: ["visitIRVariable:"],
+referencedClasses: []
+}),
+smalltalk.IRVariable);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
 selector: "emitOn:",
 selector: "emitOn:",
-category: 'emiting',
+category: 'visiting',
 fn: function (aStream) {
 fn: function (aStream) {
 var self=this;
 var self=this;
 smalltalk.send(aStream, "_nextPutAll_", [smalltalk.send(smalltalk.send(self, "_variable", []), "_alias", [])]);
 smalltalk.send(aStream, "_nextPutAll_", [smalltalk.send(smalltalk.send(self, "_variable", []), "_alias", [])]);
@@ -1505,6 +1713,22 @@ smalltalk.IRVariable);
 
 
 
 
 smalltalk.addClass('IRVerbatim', smalltalk.IRInstruction, ['source'], 'Compiler-IR');
 smalltalk.addClass('IRVerbatim', smalltalk.IRInstruction, ['source'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor) {
+var self=this;
+smalltalk.send(aVisitor, "_visitIRVerbatim_", [self]);
+return self;},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09aVisitor visitIRVerbatim: self",
+messageSends: ["visitIRVerbatim:"],
+referencedClasses: []
+}),
+smalltalk.IRVerbatim);
+
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_emitOn_",
 "_emitOn_",
 smalltalk.method({
 smalltalk.method({
@@ -1555,6 +1779,249 @@ smalltalk.IRVerbatim);
 
 
 
 
 
 
+smalltalk.addClass('IRVisitor', smalltalk.Object, [], 'Compiler-IR');
+smalltalk.addMethod(
+"_visit_",
+smalltalk.method({
+selector: "visit:",
+category: 'visiting',
+fn: function (anIRInstruction) {
+var self=this;
+smalltalk.send(anIRInstruction, "_accept_", [self]);
+return self;},
+args: ["anIRInstruction"],
+source: "visit: anIRInstruction\x0a\x09anIRInstruction accept: self",
+messageSends: ["accept:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRAssignment_",
+smalltalk.method({
+selector: "visitIRAssignment:",
+category: 'visiting',
+fn: function (anIRAssignment) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRAssignment]);
+return self;},
+args: ["anIRAssignment"],
+source: "visitIRAssignment: anIRAssignment\x0a\x09self visitIRInstruction: anIRAssignment",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRClosure_",
+smalltalk.method({
+selector: "visitIRClosure:",
+category: 'visiting',
+fn: function (anIRClosure) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRClosure]);
+return self;},
+args: ["anIRClosure"],
+source: "visitIRClosure: anIRClosure\x0a\x09self visitIRInstruction: anIRClosure",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRInstruction_",
+smalltalk.method({
+selector: "visitIRInstruction:",
+category: 'visiting',
+fn: function (anIRInstruction) {
+var self=this;
+smalltalk.send(smalltalk.send(anIRInstruction, "_instructions", []), "_do_", [(function(each){return smalltalk.send(self, "_visit_", [each]);})]);
+return self;},
+args: ["anIRInstruction"],
+source: "visitIRInstruction: anIRInstruction\x0a\x09anIRInstruction instructions do: [ :each | self visit: each ]",
+messageSends: ["do:", "instructions", "visit:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRMethod_",
+smalltalk.method({
+selector: "visitIRMethod:",
+category: 'visiting',
+fn: function (anIRMethod) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRMethod]);
+return self;},
+args: ["anIRMethod"],
+source: "visitIRMethod: anIRMethod\x0a\x09self visitIRInstruction: anIRMethod",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRNonLocalReturn_",
+smalltalk.method({
+selector: "visitIRNonLocalReturn:",
+category: 'visiting',
+fn: function (anIRNonLocalReturn) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRNonLocalReturn]);
+return self;},
+args: ["anIRNonLocalReturn"],
+source: "visitIRNonLocalReturn: anIRNonLocalReturn\x0a\x09self visitIRInstruction: anIRNonLocalReturn",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRNonLocalReturnHandling_",
+smalltalk.method({
+selector: "visitIRNonLocalReturnHandling:",
+category: 'visiting',
+fn: function (anIRNonLocalReturnHandling) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRNonLocalReturnHandling]);
+return self;},
+args: ["anIRNonLocalReturnHandling"],
+source: "visitIRNonLocalReturnHandling: anIRNonLocalReturnHandling\x0a\x09self visitIRInstruction: anIRNonLocalReturnHandling",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRReturn_",
+smalltalk.method({
+selector: "visitIRReturn:",
+category: 'visiting',
+fn: function (anIRReturn) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRReturn]);
+return self;},
+args: ["anIRReturn"],
+source: "visitIRReturn: anIRReturn\x0a\x09self visitIRInstruction: anIRReturn",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRSend_",
+smalltalk.method({
+selector: "visitIRSend:",
+category: 'visiting',
+fn: function (anIRSend) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRSend]);
+return self;},
+args: ["anIRSend"],
+source: "visitIRSend: anIRSend\x0a\x09self visitIRInstruction: anIRSend",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRSequence_",
+smalltalk.method({
+selector: "visitIRSequence:",
+category: 'visiting',
+fn: function (anIRSequence) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRSequence]);
+return self;},
+args: ["anIRSequence"],
+source: "visitIRSequence: anIRSequence\x0a\x09self visitIRInstruction: anIRSequence",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRStatement_",
+smalltalk.method({
+selector: "visitIRStatement:",
+category: 'visiting',
+fn: function (anIRStatement) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRStatement]);
+return self;},
+args: ["anIRStatement"],
+source: "visitIRStatement: anIRStatement\x0a\x09self visitIRInstruction: anIRStatement",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRTempDeclaration_",
+smalltalk.method({
+selector: "visitIRTempDeclaration:",
+category: 'visiting',
+fn: function (anIRTempDeclaration) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRTempDeclaration]);
+return self;},
+args: ["anIRTempDeclaration"],
+source: "visitIRTempDeclaration: anIRTempDeclaration\x0a\x09self visitIRInstruction: anIRTempDeclaration",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRValue_",
+smalltalk.method({
+selector: "visitIRValue:",
+category: 'visiting',
+fn: function (anIRValue) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRValue]);
+return self;},
+args: ["anIRValue"],
+source: "visitIRValue: anIRValue\x0a\x09self visitIRInstruction: anIRValue",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRVariable_",
+smalltalk.method({
+selector: "visitIRVariable:",
+category: 'visiting',
+fn: function (anIRVariable) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRVariable]);
+return self;},
+args: ["anIRVariable"],
+source: "visitIRVariable: anIRVariable\x0a\x09self visitIRInstruction: anIRVariable",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+smalltalk.addMethod(
+"_visitIRVerbatim_",
+smalltalk.method({
+selector: "visitIRVerbatim:",
+category: 'visiting',
+fn: function (anIRVerbatim) {
+var self=this;
+smalltalk.send(self, "_visitIRInstruction_", [anIRVerbatim]);
+return self;},
+args: ["anIRVerbatim"],
+source: "visitIRVerbatim: anIRVerbatim\x0a\x09self visitIRInstruction: anIRVerbatim",
+messageSends: ["visitIRInstruction:"],
+referencedClasses: []
+}),
+smalltalk.IRVisitor);
+
+
+
 smalltalk.addClass('JSStream', smalltalk.Object, ['stream'], 'Compiler-IR');
 smalltalk.addClass('JSStream', smalltalk.Object, ['stream'], 'Compiler-IR');
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_contents",
 "_contents",

+ 23 - 26
js/Compiler-Semantic.deploy.js

@@ -1,29 +1,4 @@
 smalltalk.addPackage('Compiler-Semantic', {});
 smalltalk.addPackage('Compiler-Semantic', {});
-smalltalk.addClass('InvalidAssignmentError', smalltalk.SemanticError, ['variableName'], 'Compiler-Semantic');
-smalltalk.addMethod(
-"_variableName",
-smalltalk.method({
-selector: "variableName",
-fn: function () {
-var self=this;
-return self['@variableName'];
-return self;}
-}),
-smalltalk.InvalidAssignmentError);
-
-smalltalk.addMethod(
-"_variableName_",
-smalltalk.method({
-selector: "variableName:",
-fn: function (aString) {
-var self=this;
-(self['@variableName']=aString);
-return self;}
-}),
-smalltalk.InvalidAssignmentError);
-
-
-
 smalltalk.addClass('LexicalScope', smalltalk.Object, ['node', 'temps', 'args', 'outerScope'], 'Compiler-Semantic');
 smalltalk.addClass('LexicalScope', smalltalk.Object, ['node', 'temps', 'args', 'outerScope'], 'Compiler-Semantic');
 smalltalk.addMethod(
 smalltalk.addMethod(
 "_addArg_",
 "_addArg_",
@@ -413,7 +388,29 @@ return self;}
 smalltalk.ScopeVar.klass);
 smalltalk.ScopeVar.klass);
 
 
 
 
-smalltalk.addClass('AliasVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
+smalltalk.addClass('AliasVar', smalltalk.ScopeVar, ['node'], 'Compiler-Semantic');
+smalltalk.addMethod(
+"_node",
+smalltalk.method({
+selector: "node",
+fn: function () {
+var self=this;
+return self['@node'];
+return self;}
+}),
+smalltalk.AliasVar);
+
+smalltalk.addMethod(
+"_node_",
+smalltalk.method({
+selector: "node:",
+fn: function (aNode) {
+var self=this;
+(self['@node']=aNode);
+return self;}
+}),
+smalltalk.AliasVar);
+
 
 
 
 
 smalltalk.addClass('ArgVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
 smalltalk.addClass('ArgVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');

+ 33 - 37
js/Compiler-Semantic.js

@@ -1,40 +1,4 @@
 smalltalk.addPackage('Compiler-Semantic', {});
 smalltalk.addPackage('Compiler-Semantic', {});
-smalltalk.addClass('InvalidAssignmentError', smalltalk.SemanticError, ['variableName'], 'Compiler-Semantic');
-smalltalk.InvalidAssignmentError.comment="I get signaled when a pseudo variable gets assigned."
-smalltalk.addMethod(
-"_variableName",
-smalltalk.method({
-selector: "variableName",
-category: 'accessing',
-fn: function () {
-var self=this;
-return self['@variableName'];
-return self;},
-args: [],
-source: "variableName\x0a\x09^ variableName",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.InvalidAssignmentError);
-
-smalltalk.addMethod(
-"_variableName_",
-smalltalk.method({
-selector: "variableName:",
-category: 'accessing',
-fn: function (aString) {
-var self=this;
-(self['@variableName']=aString);
-return self;},
-args: ["aString"],
-source: "variableName: aString\x0a\x09variableName := aString",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.InvalidAssignmentError);
-
-
-
 smalltalk.addClass('LexicalScope', smalltalk.Object, ['node', 'temps', 'args', 'outerScope'], 'Compiler-Semantic');
 smalltalk.addClass('LexicalScope', smalltalk.Object, ['node', 'temps', 'args', 'outerScope'], 'Compiler-Semantic');
 smalltalk.LexicalScope.comment="I represent a lexical scope where variable names are associated with ScopeVars\x0aInstances are used for block scopes. Method scopes are instances of MethodLexicalScope.\x0a\x0aI am attached to a ScopeVar and method/block nodes.\x0aEach context (method/closure) get a fresh scope that inherits from its outer scope."
 smalltalk.LexicalScope.comment="I represent a lexical scope where variable names are associated with ScopeVars\x0aInstances are used for block scopes. Method scopes are instances of MethodLexicalScope.\x0a\x0aI am attached to a ScopeVar and method/block nodes.\x0aEach context (method/closure) get a fresh scope that inherits from its outer scope."
 smalltalk.addMethod(
 smalltalk.addMethod(
@@ -597,8 +561,40 @@ referencedClasses: []
 smalltalk.ScopeVar.klass);
 smalltalk.ScopeVar.klass);
 
 
 
 
-smalltalk.addClass('AliasVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
+smalltalk.addClass('AliasVar', smalltalk.ScopeVar, ['node'], 'Compiler-Semantic');
 smalltalk.AliasVar.comment="I am an internally defined variable by the compiler"
 smalltalk.AliasVar.comment="I am an internally defined variable by the compiler"
+smalltalk.addMethod(
+"_node",
+smalltalk.method({
+selector: "node",
+category: 'accessing',
+fn: function () {
+var self=this;
+return self['@node'];
+return self;},
+args: [],
+source: "node\x0a\x09^ node",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.AliasVar);
+
+smalltalk.addMethod(
+"_node_",
+smalltalk.method({
+selector: "node:",
+category: 'accessing',
+fn: function (aNode) {
+var self=this;
+(self['@node']=aNode);
+return self;},
+args: ["aNode"],
+source: "node: aNode\x0a\x09node := aNode",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.AliasVar);
+
 
 
 
 
 smalltalk.addClass('ArgVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
 smalltalk.addClass('ArgVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');

+ 16 - 0
st/Compiler-Exceptions.st

@@ -17,6 +17,22 @@ See my subclasses for concrete errors.
 
 
 The IDE should catch instances of Semantic error to deal with them when compiling!
 The IDE should catch instances of Semantic error to deal with them when compiling!
 
 
+SemanticError subclass: #InvalidAssignmentError
+	instanceVariableNames: 'variableName'
+	package: 'Compiler-Exceptions'!
+!InvalidAssignmentError commentStamp!
+I get signaled when a pseudo variable gets assigned.!
+
+!InvalidAssignmentError methodsFor: 'accessing'!
+
+variableName
+	^ variableName
+!
+
+variableName: aString
+	variableName := aString
+! !
+
 SemanticError subclass: #ShadowingVariableError
 SemanticError subclass: #ShadowingVariableError
 	instanceVariableNames: 'variableName'
 	instanceVariableNames: 'variableName'
 	package: 'Compiler-Exceptions'!
 	package: 'Compiler-Exceptions'!

+ 160 - 6
st/Compiler-IR.st

@@ -116,7 +116,10 @@ resolve: aNode
 		alias := self nextAlias.
 		alias := self nextAlias.
 		self builder method internalVariables add: alias.
 		self builder method internalVariables add: alias.
 		self builder assignment
 		self builder assignment
-			with: [ self builder variable: (AliasVar new name: alias) ];
+			with: [ self builder variable: (AliasVar new 
+				name: alias;
+				node: aNode;
+				yourself) ];
 			with: [ self visit: aNode resolving: false ].
 			with: [ self visit: aNode resolving: false ].
 			aNode alias: alias ]
 			aNode alias: alias ]
 !
 !
@@ -133,7 +136,10 @@ visit: aNode resolving: aBoolean
 !
 !
 
 
 visitAliased: aNode
 visitAliased: aNode
-	^ self builder variable: (AliasVar new name: aNode alias)
+	^ self builder variable: (AliasVar new 
+		name: aNode alias;
+		node: aNode;
+		yourself)
 ! !
 ! !
 
 
 Object subclass: #IRBuilder
 Object subclass: #IRBuilder
@@ -313,6 +319,12 @@ emitOn: aStream
 		each emitOn: aStream ]
 		each emitOn: aStream ]
 ! !
 ! !
 
 
+!IRInstruction methodsFor: 'visiting'!
+
+accept: aVisitor
+	aVisitor visitIRInstruction: self
+! !
+
 !IRInstruction class methodsFor: 'instance creation'!
 !IRInstruction class methodsFor: 'instance creation'!
 
 
 on: aBuilder
 on: aBuilder
@@ -333,6 +345,12 @@ emitOn: aStream
 		to: self instructions last
 		to: self instructions last
 ! !
 ! !
 
 
+!IRAssignment methodsFor: 'visiting'!
+
+accept: aVisitor
+	aVisitor visitIRAssignment: self
+! !
+
 IRInstruction subclass: #IRClosure
 IRInstruction subclass: #IRClosure
 	instanceVariableNames: 'arguments'
 	instanceVariableNames: 'arguments'
 	package: 'Compiler-IR'!
 	package: 'Compiler-IR'!
@@ -355,6 +373,12 @@ emitOn: aStream
 		arguments: self arguments
 		arguments: self arguments
 ! !
 ! !
 
 
+!IRClosure methodsFor: 'visiting'!
+
+accept: aVisitor
+	aVisitor visitIRClosure: self
+! !
+
 IRInstruction subclass: #IRMethod
 IRInstruction subclass: #IRMethod
 	instanceVariableNames: 'source selector classReferences messageSends arguments internalVariables source'
 	instanceVariableNames: 'source selector classReferences messageSends arguments internalVariables source'
 	package: 'Compiler-IR'!
 	package: 'Compiler-IR'!
@@ -409,6 +433,10 @@ source: aString
 
 
 !IRMethod methodsFor: 'emiting'!
 !IRMethod methodsFor: 'emiting'!
 
 
+accept: aVisitor
+	aVisitor visitIRMethod: self
+!
+
 emitOn: aStream
 emitOn: aStream
 	aStream
 	aStream
 		nextPutMethodDeclaration: self 
 		nextPutMethodDeclaration: self 
@@ -437,6 +465,12 @@ emitOn: aStream
 		super emitOn: aStream ]
 		super emitOn: aStream ]
 ! !
 ! !
 
 
+!IRNonLocalReturn methodsFor: 'visiting'!
+
+accept: aVisitor
+	aVisitor visitIRNonLocalReturn: self
+! !
+
 IRInstruction subclass: #IRNonLocalReturnHandling
 IRInstruction subclass: #IRNonLocalReturnHandling
 	instanceVariableNames: ''
 	instanceVariableNames: ''
 	package: 'Compiler-IR'!
 	package: 'Compiler-IR'!
@@ -451,6 +485,12 @@ emitOn: aStream
 		super emitOn: aStream ]
 		super emitOn: aStream ]
 ! !
 ! !
 
 
+!IRNonLocalReturnHandling methodsFor: 'visiting'!
+
+accept: aVisitor
+	aVisitor visitIRNonLocalReturnHandling: self
+! !
+
 IRInstruction subclass: #IRReturn
 IRInstruction subclass: #IRReturn
 	instanceVariableNames: ''
 	instanceVariableNames: ''
 	package: 'Compiler-IR'!
 	package: 'Compiler-IR'!
@@ -464,6 +504,12 @@ emitOn: aStream
 		super emitOn: aStream ]
 		super emitOn: aStream ]
 ! !
 ! !
 
 
+!IRReturn methodsFor: 'visiting'!
+
+accept: aVisitor
+	aVisitor visitIRReturn: self
+! !
+
 IRInstruction subclass: #IRSend
 IRInstruction subclass: #IRSend
 	instanceVariableNames: 'selector superSend'
 	instanceVariableNames: 'selector superSend'
 	package: 'Compiler-IR'!
 	package: 'Compiler-IR'!
@@ -499,6 +545,12 @@ superSend: aBoolean
 	superSend := aBoolean
 	superSend := aBoolean
 ! !
 ! !
 
 
+!IRSend methodsFor: 'visiting'!
+
+accept: aVisitor
+	aVisitor visitIRSend: self
+! !
+
 IRInstruction subclass: #IRSequence
 IRInstruction subclass: #IRSequence
 	instanceVariableNames: ''
 	instanceVariableNames: ''
 	package: 'Compiler-IR'!
 	package: 'Compiler-IR'!
@@ -519,6 +571,12 @@ emitOn: aStream
 		super emitOn: aStream ]
 		super emitOn: aStream ]
 ! !
 ! !
 
 
+!IRSequence methodsFor: 'visiting'!
+
+accept: aVisitor
+	aVisitor visitIRSequence: self
+! !
+
 IRInstruction subclass: #IRStatement
 IRInstruction subclass: #IRStatement
 	instanceVariableNames: 'pc'
 	instanceVariableNames: 'pc'
 	package: 'Compiler-IR'!
 	package: 'Compiler-IR'!
@@ -539,6 +597,12 @@ emitOn: aStream
 		super emitOn: aStream ]
 		super emitOn: aStream ]
 ! !
 ! !
 
 
+!IRStatement methodsFor: 'visiting'!
+
+accept: aVisitor
+	aVisitor visitIRStatement: self
+! !
+
 IRInstruction subclass: #IRTempDeclaration
 IRInstruction subclass: #IRTempDeclaration
 	instanceVariableNames: 'name'
 	instanceVariableNames: 'name'
 	package: 'Compiler-IR'!
 	package: 'Compiler-IR'!
@@ -561,6 +625,12 @@ emitOn: aStream
 	aStream nextPutVar: self name asVariableName
 	aStream nextPutVar: self name asVariableName
 ! !
 ! !
 
 
+!IRTempDeclaration methodsFor: 'visiting'!
+
+accept: aVisitor
+	aVisitor visitIRTempDeclaration: self
+! !
+
 IRInstruction subclass: #IRValue
 IRInstruction subclass: #IRValue
 	instanceVariableNames: 'value'
 	instanceVariableNames: 'value'
 	package: 'Compiler-IR'!
 	package: 'Compiler-IR'!
@@ -571,18 +641,24 @@ I am the simplest possible instruction. I represent a value.!
 
 
 value
 value
 	^value
 	^value
-!
-
-value: aString
-	value := aString
 ! !
 ! !
 
 
 !IRValue methodsFor: 'emiting'!
 !IRValue methodsFor: 'emiting'!
 
 
+accept: aVisitor
+	aVisitor visitIRValue: self
+!
+
 emitOn: aStream
 emitOn: aStream
 	aStream nextPutAll: self value asJavascript
 	aStream nextPutAll: self value asJavascript
 ! !
 ! !
 
 
+!IRValue methodsFor: 'visiting'!
+
+value: aString
+	value := aString
+! !
+
 IRInstruction subclass: #IRVariable
 IRInstruction subclass: #IRVariable
 	instanceVariableNames: 'variable'
 	instanceVariableNames: 'variable'
 	package: 'Compiler-IR'!
 	package: 'Compiler-IR'!
@@ -601,6 +677,12 @@ variable: aScopeVariable
 
 
 !IRVariable methodsFor: 'emiting'!
 !IRVariable methodsFor: 'emiting'!
 
 
+accept: aVisitor
+	aVisitor visitIRVariable: self
+! !
+
+!IRVariable methodsFor: 'visiting'!
+
 emitOn: aStream
 emitOn: aStream
 	aStream nextPutAll: self variable alias
 	aStream nextPutAll: self variable alias
 ! !
 ! !
@@ -625,6 +707,78 @@ emitOn: aStream
 	aStream nextPutAll: self source, ';'
 	aStream nextPutAll: self source, ';'
 ! !
 ! !
 
 
+!IRVerbatim methodsFor: 'visiting'!
+
+accept: aVisitor
+	aVisitor visitIRVerbatim: self
+! !
+
+Object subclass: #IRVisitor
+	instanceVariableNames: ''
+	package: 'Compiler-IR'!
+
+!IRVisitor methodsFor: 'visiting'!
+
+visit: anIRInstruction
+	anIRInstruction accept: self
+!
+
+visitIRAssignment: anIRAssignment
+	self visitIRInstruction: anIRAssignment
+!
+
+visitIRClosure: anIRClosure
+	self visitIRInstruction: anIRClosure
+!
+
+visitIRInstruction: anIRInstruction
+	anIRInstruction instructions do: [ :each | self visit: each ]
+!
+
+visitIRMethod: anIRMethod
+	self visitIRInstruction: anIRMethod
+!
+
+visitIRNonLocalReturn: anIRNonLocalReturn
+	self visitIRInstruction: anIRNonLocalReturn
+!
+
+visitIRNonLocalReturnHandling: anIRNonLocalReturnHandling
+	self visitIRInstruction: anIRNonLocalReturnHandling
+!
+
+visitIRReturn: anIRReturn
+	self visitIRInstruction: anIRReturn
+!
+
+visitIRSend: anIRSend
+	self visitIRInstruction: anIRSend
+!
+
+visitIRSequence: anIRSequence
+	self visitIRInstruction: anIRSequence
+!
+
+visitIRStatement: anIRStatement
+	self visitIRInstruction: anIRStatement
+!
+
+visitIRTempDeclaration: anIRTempDeclaration
+	self visitIRInstruction: anIRTempDeclaration
+!
+
+visitIRValue: anIRValue
+	self visitIRInstruction: anIRValue
+!
+
+visitIRVariable: anIRVariable
+	self visitIRInstruction: anIRVariable
+!
+
+visitIRVerbatim: anIRVerbatim
+	self visitIRInstruction: anIRVerbatim
+! !
+
 Object subclass: #JSStream
 Object subclass: #JSStream
 	instanceVariableNames: 'stream'
 	instanceVariableNames: 'stream'
 	package: 'Compiler-IR'!
 	package: 'Compiler-IR'!

+ 11 - 17
st/Compiler-Semantic.st

@@ -1,20 +1,4 @@
 Smalltalk current createPackage: 'Compiler-Semantic' properties: #{}!
 Smalltalk current createPackage: 'Compiler-Semantic' properties: #{}!
-SemanticError subclass: #InvalidAssignmentError
-	instanceVariableNames: 'variableName'
-	package: 'Compiler-Semantic'!
-!InvalidAssignmentError commentStamp!
-I get signaled when a pseudo variable gets assigned.!
-
-!InvalidAssignmentError methodsFor: 'accessing'!
-
-variableName
-	^ variableName
-!
-
-variableName: aString
-	variableName := aString
-! !
-
 Object subclass: #LexicalScope
 Object subclass: #LexicalScope
 	instanceVariableNames: 'node temps args outerScope'
 	instanceVariableNames: 'node temps args outerScope'
 	package: 'Compiler-Semantic'!
 	package: 'Compiler-Semantic'!
@@ -210,11 +194,21 @@ on: aString
 ! !
 ! !
 
 
 ScopeVar subclass: #AliasVar
 ScopeVar subclass: #AliasVar
-	instanceVariableNames: ''
+	instanceVariableNames: 'node'
 	package: 'Compiler-Semantic'!
 	package: 'Compiler-Semantic'!
 !AliasVar commentStamp!
 !AliasVar commentStamp!
 I am an internally defined variable by the compiler!
 I am an internally defined variable by the compiler!
 
 
+!AliasVar methodsFor: 'accessing'!
+
+node
+	^ node
+!
+
+node: aNode
+	node := aNode
+! !
+
 ScopeVar subclass: #ArgVar
 ScopeVar subclass: #ArgVar
 	instanceVariableNames: ''
 	instanceVariableNames: ''
 	package: 'Compiler-Semantic'!
 	package: 'Compiler-Semantic'!