Explorar el Código

ASTInterpreter / ASTDebugger fixes.

Required slight change to tests and to Compiler internals.
Herby Vojčík hace 6 años
padre
commit
2bff134394
Se han modificado 7 ficheros con 193 adiciones y 221 borrados
  1. 7 0
      API-CHANGES.txt
  2. 4 4
      src/Compiler-AST.js
  3. 4 1
      src/Compiler-AST.st
  4. 124 40
      src/Compiler-Core.js
  5. 35 17
      src/Compiler-Core.st
  6. 12 129
      src/Compiler-Tests.js
  7. 7 30
      src/Compiler-Tests.st

+ 7 - 0
API-CHANGES.txt

@@ -1,5 +1,10 @@
 0.22.0:
 
++ Compiler >>
+  + ast:forClass:protocol:
+  + cleanCodeGenerator
+  + codeGenerator
+  + forClass:protocol:
 + JSObjectProxy >>
   + removeKey:
 + Number >>
@@ -11,6 +16,8 @@
   - initializeClasses
 - ClassBuilder >>
   - setupClass:
+- Compiler >>
+  - compileNode:forClass:package:
 - ProtoObject
   - asJSON
   - asJavascript

+ 4 - 4
src/Compiler-AST.js

@@ -3435,17 +3435,17 @@ return $self._error_("Method source is empty");
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
 //>>excludeEnd("ctx");
 }));
-return $recv($globals.Smalltalk)._parse_($self._source());
+return $recv($recv($globals.Compiler)._new())._ast_forClass_protocol_($self._source(),$self._methodClass(),$self._protocol());
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"ast",{},$globals.CompiledMethod)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "ast\x0a\x09self source ifEmpty: [ self error: 'Method source is empty' ].\x0a\x09\x0a\x09^ Smalltalk parse: self source",
-referencedClasses: ["Smalltalk"],
+source: "ast\x0a\x09self source ifEmpty: [ self error: 'Method source is empty' ].\x0a\x09\x0a\x09^ Compiler new\x0a\x09\x09ast: self source\x0a\x09\x09forClass: self methodClass\x0a\x09\x09protocol: self protocol",
+referencedClasses: ["Compiler"],
 //>>excludeEnd("ide");
-messageSends: ["ifEmpty:", "source", "error:", "parse:"]
+messageSends: ["ifEmpty:", "source", "error:", "ast:forClass:protocol:", "new", "methodClass", "protocol"]
 }),
 $globals.CompiledMethod);
 

+ 4 - 1
src/Compiler-AST.st

@@ -852,6 +852,9 @@ inlineJS: aString
 ast
 	self source ifEmpty: [ self error: 'Method source is empty' ].
 	
-	^ Smalltalk parse: self source
+	^ Compiler new
+		ast: self source
+		forClass: self methodClass
+		protocol: self protocol
 ! !
 

+ 124 - 40
src/Compiler-Core.js

@@ -394,10 +394,98 @@ $globals.CodeGenerator);
 
 
 
-$core.addClass("Compiler", $globals.Object, ["currentClass", "currentPackage", "source", "codeGeneratorClass"], "Compiler-Core");
+$core.addClass("Compiler", $globals.Object, ["currentClass", "currentPackage", "source", "codeGeneratorClass", "codeGenerator"], "Compiler-Core");
 //>>excludeStart("ide", pragmas.excludeIdeData);
 $globals.Compiler.comment="I provide the public interface for compiling Amber source code into JavaScript.\x0a\x0aThe code generator used to produce JavaScript can be plugged with `#codeGeneratorClass`.\x0aThe default code generator is an instance of `InlinedCodeGenerator`";
 //>>excludeEnd("ide");
+$core.addMethod(
+$core.method({
+selector: "ast:forClass:protocol:",
+protocol: "compiling",
+fn: function (aString,aClass,anotherString){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $early={};
+try {
+$self._source_(aString);
+$self._forClass_protocol_(aClass,anotherString);
+$recv($recv($self._codeGenerator())._transformersDictionary())._at_put_("2500-astCheckpoint",(function(x){
+throw $early=[x];
+
+}));
+$self._compileNode_($self._parse_(aString));
+$self._error_("AST transformation failed.");
+return self;
+}
+catch(e) {if(e===$early)return e[0]; throw e}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"ast:forClass:protocol:",{aString:aString,aClass:aClass,anotherString:anotherString},$globals.Compiler)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString", "aClass", "anotherString"],
+source: "ast: aString forClass: aClass protocol: anotherString\x0a\x09self\x0a\x09\x09source: aString;\x0a\x09\x09forClass: aClass protocol: anotherString.\x0a\x0a\x09self codeGenerator transformersDictionary at: '2500-astCheckpoint' put: [ :x | ^x ].\x0a\x09\x0a\x09self compileNode: (self parse: aString).\x0a\x0a\x09self error: 'AST transformation failed.'",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["source:", "forClass:protocol:", "at:put:", "transformersDictionary", "codeGenerator", "compileNode:", "parse:", "error:"]
+}),
+$globals.Compiler);
+
+$core.addMethod(
+$core.method({
+selector: "cleanCodeGenerator",
+protocol: "accessing",
+fn: function (){
+var self=this,$self=this;
+$self["@codeGenerator"]=nil;
+return self;
+
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "cleanCodeGenerator\x0a\x09codeGenerator := nil",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.Compiler);
+
+$core.addMethod(
+$core.method({
+selector: "codeGenerator",
+protocol: "accessing",
+fn: function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2,$receiver;
+$1=$self["@codeGenerator"];
+if(($receiver = $1) == null || $receiver.a$nil){
+$2=$recv($self._codeGeneratorClass())._new();
+$recv($2)._source_($self._source());
+$recv($2)._currentClass_($self._currentClass());
+$recv($2)._currentPackage_($self._currentPackage());
+$self["@codeGenerator"]=$recv($2)._yourself();
+return $self["@codeGenerator"];
+} else {
+return $1;
+}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"codeGenerator",{},$globals.Compiler)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "codeGenerator\x0a\x09^ codeGenerator ifNil: [ codeGenerator := self codeGeneratorClass new\x0a\x09\x09\x09source: self source;\x0a\x09\x09\x09currentClass: self currentClass;\x0a\x09\x09\x09currentPackage: self currentPackage;\x0a\x09\x09\x09yourself ]",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["ifNil:", "source:", "new", "codeGeneratorClass", "source", "currentClass:", "currentClass", "currentPackage:", "currentPackage", "yourself"]
+}),
+$globals.Compiler);
+
 $core.addMethod(
 $core.method({
 selector: "codeGeneratorClass",
@@ -456,17 +544,18 @@ var self=this,$self=this;
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 $self._source_(aString);
-return $self._compileNode_forClass_package_($self._parse_(aString),aClass,$recv(aClass)._packageOfProtocol_(anotherString));
+$self._forClass_protocol_(aClass,anotherString);
+return $self._compileNode_($self._parse_(aString));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"compile:forClass:protocol:",{aString:aString,aClass:aClass,anotherString:anotherString},$globals.Compiler)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString", "aClass", "anotherString"],
-source: "compile: aString forClass: aClass protocol: anotherString\x0a\x09^ self\x0a\x09\x09source: aString;\x0a\x09\x09compileNode: (self parse: aString)\x0a\x09\x09forClass: aClass\x0a\x09\x09package: (aClass packageOfProtocol: anotherString)",
+source: "compile: aString forClass: aClass protocol: anotherString\x0a\x09^ self\x0a\x09\x09source: aString;\x0a\x09\x09forClass: aClass protocol: anotherString;\x0a\x09\x09compileNode: (self parse: aString)",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["source:", "compileNode:forClass:package:", "parse:", "packageOfProtocol:"]
+messageSends: ["source:", "forClass:protocol:", "compileNode:", "parse:"]
 }),
 $globals.Compiler);
 
@@ -504,53 +593,23 @@ selector: "compileNode:",
 protocol: "compiling",
 fn: function (aNode){
 var self=this,$self=this;
-var generator,result;
+var result;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1;
-generator=$recv($self._codeGeneratorClass())._new();
-$1=generator;
-$recv($1)._source_($self._source());
-$recv($1)._currentClass_($self._currentClass());
-$recv($1)._currentPackage_($self._currentPackage());
-result=$recv(generator)._compileNode_(aNode);
+result=$recv($self._codeGenerator())._compileNode_(aNode);
+$self._cleanCodeGenerator();
 return result;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,generator:generator,result:result},$globals.Compiler)});
+}, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,result:result},$globals.Compiler)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aNode"],
-source: "compileNode: aNode\x0a\x09| generator result |\x0a\x09generator := self codeGeneratorClass new.\x0a\x09generator\x0a\x09\x09source: self source;\x0a\x09\x09currentClass: self currentClass;\x0a\x09\x09currentPackage: self currentPackage.\x0a\x09result := generator compileNode: aNode.\x0a\x09^ result",
+source: "compileNode: aNode\x0a    | result |\x0a\x09result := self codeGenerator compileNode: aNode.\x0a\x09self cleanCodeGenerator.\x0a\x09^ result",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["new", "codeGeneratorClass", "source:", "source", "currentClass:", "currentClass", "currentPackage:", "currentPackage", "compileNode:"]
-}),
-$globals.Compiler);
-
-$core.addMethod(
-$core.method({
-selector: "compileNode:forClass:package:",
-protocol: "compiling",
-fn: function (aNode,aClass,aPackage){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-$self._currentClass_(aClass);
-$self._currentPackage_(aPackage);
-return $self._compileNode_(aNode);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"compileNode:forClass:package:",{aNode:aNode,aClass:aClass,aPackage:aPackage},$globals.Compiler)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aNode", "aClass", "aPackage"],
-source: "compileNode: aNode forClass: aClass package: aPackage\x0a\x09^ self\x0a\x09\x09currentClass: aClass;\x0a\x09\x09currentPackage: aPackage;\x0a\x09\x09compileNode: aNode",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["currentClass:", "currentPackage:", "compileNode:"]
+messageSends: ["compileNode:", "codeGenerator", "cleanCodeGenerator"]
 }),
 $globals.Compiler);
 
@@ -740,6 +799,31 @@ messageSends: ["eval:", "compileExpression:on:", "protocol:", "addCompiledMethod
 }),
 $globals.Compiler);
 
+$core.addMethod(
+$core.method({
+selector: "forClass:protocol:",
+protocol: "compiling",
+fn: function (aClass,anotherString){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$self._currentPackage_($recv(aClass)._packageOfProtocol_(anotherString));
+$self._currentClass_(aClass);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"forClass:protocol:",{aClass:aClass,anotherString:anotherString},$globals.Compiler)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aClass", "anotherString"],
+source: "forClass: aClass protocol: anotherString\x0a\x09self\x0a\x09\x09currentPackage: (aClass packageOfProtocol: anotherString);\x0a\x09\x09currentClass: aClass",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["currentPackage:", "packageOfProtocol:", "currentClass:"]
+}),
+$globals.Compiler);
+
 $core.addMethod(
 $core.method({
 selector: "install:forClass:protocol:",

+ 35 - 17
src/Compiler-Core.st

@@ -95,7 +95,7 @@ translator
 ! !
 
 Object subclass: #Compiler
-	instanceVariableNames: 'currentClass currentPackage source codeGeneratorClass'
+	instanceVariableNames: 'currentClass currentPackage source codeGeneratorClass codeGenerator'
 	package: 'Compiler-Core'!
 !Compiler commentStamp!
 I provide the public interface for compiling Amber source code into JavaScript.
@@ -105,6 +105,18 @@ The default code generator is an instance of `InlinedCodeGenerator`!
 
 !Compiler methodsFor: 'accessing'!
 
+cleanCodeGenerator
+	codeGenerator := nil
+!
+
+codeGenerator
+	^ codeGenerator ifNil: [ codeGenerator := self codeGeneratorClass new
+			source: self source;
+			currentClass: self currentClass;
+			currentPackage: self currentPackage;
+			yourself ]
+!
+
 codeGeneratorClass
 	^ codeGeneratorClass ifNil: [ InliningCodeGenerator ]
 !
@@ -139,12 +151,23 @@ source: aString
 
 !Compiler methodsFor: 'compiling'!
 
+ast: aString forClass: aClass protocol: anotherString
+	self
+		source: aString;
+		forClass: aClass protocol: anotherString.
+
+	self codeGenerator transformersDictionary at: '2500-astCheckpoint' put: [ :x | ^x ].
+	
+	self compileNode: (self parse: aString).
+
+	self error: 'AST transformation failed.'
+!
+
 compile: aString forClass: aClass protocol: anotherString
 	^ self
 		source: aString;
+		forClass: aClass protocol: anotherString;
 		compileNode: (self parse: aString)
-		forClass: aClass
-		package: (aClass packageOfProtocol: anotherString)
 !
 
 compileExpression: aString on: anObject
@@ -155,23 +178,12 @@ compileExpression: aString on: anObject
 !
 
 compileNode: aNode
-	| generator result |
-	generator := self codeGeneratorClass new.
-	generator
-		source: self source;
-		currentClass: self currentClass;
-		currentPackage: self currentPackage.
-	result := generator compileNode: aNode.
+    | result |
+	result := self codeGenerator compileNode: aNode.
+	self cleanCodeGenerator.
 	^ result
 !
 
-compileNode: aNode forClass: aClass package: aPackage
-	^ self
-		currentClass: aClass;
-		currentPackage: aPackage;
-		compileNode: aNode
-!
-
 eval: aString
 	<inlineJS: 'return eval(aString)'>
 !
@@ -198,6 +210,12 @@ evaluateExpression: aString on: anObject
 	^ result
 !
 
+forClass: aClass protocol: anotherString
+	self
+		currentPackage: (aClass packageOfProtocol: anotherString);
+		currentClass: aClass
+!
+
 install: aString forClass: aBehavior protocol: anotherString
 	| compiledMethod |
 	compiledMethod := self

+ 12 - 129
src/Compiler-Tests.js

@@ -6,53 +6,6 @@ $core.addPackage("Compiler-Tests");
 ($core.packageDescriptors||$core.packages)["Compiler-Tests"].transport = {"type":"amd","amdNamespace":"amber_core"};
 
 $core.addClass("ASTParsingTest", $globals.TestCase, [], "Compiler-Tests");
-$core.addMethod(
-$core.method({
-selector: "analyze:forClass:",
-protocol: "convenience",
-fn: function (aNode,aClass){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-$recv($recv($globals.SemanticAnalyzer)._on_(aClass))._visit_(aNode);
-return aNode;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"analyze:forClass:",{aNode:aNode,aClass:aClass},$globals.ASTParsingTest)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aNode", "aClass"],
-source: "analyze: aNode forClass: aClass\x0a\x09(SemanticAnalyzer on: aClass) visit: aNode.\x0a\x09^ aNode",
-referencedClasses: ["SemanticAnalyzer"],
-//>>excludeEnd("ide");
-messageSends: ["visit:", "on:"]
-}),
-$globals.ASTParsingTest);
-
-$core.addMethod(
-$core.method({
-selector: "parse:",
-protocol: "parsing",
-fn: function (aString){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return $recv($globals.Smalltalk)._parse_(aString);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},$globals.ASTParsingTest)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aString"],
-source: "parse: aString\x0a\x09^ Smalltalk parse: aString",
-referencedClasses: ["Smalltalk"],
-//>>excludeEnd("ide");
-messageSends: ["parse:"]
-}),
-$globals.ASTParsingTest);
-
 $core.addMethod(
 $core.method({
 selector: "parse:forClass:",
@@ -62,17 +15,17 @@ var self=this,$self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-return $self._analyze_forClass_($self._parse_(aString),aClass);
+return $recv($recv($globals.Compiler)._new())._ast_forClass_protocol_(aString,aClass,"test");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass},$globals.ASTParsingTest)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["aString", "aClass"],
-source: "parse: aString forClass: aClass\x0a\x09^ self analyze: (self parse: aString) forClass: aClass",
-referencedClasses: [],
+source: "parse: aString forClass: aClass\x0a\x09^ Compiler new\x0a\x09\x09ast: aString\x0a\x09\x09forClass: aClass\x0a\x09\x09protocol: 'test'",
+referencedClasses: ["Compiler"],
 //>>excludeEnd("ide");
-messageSends: ["analyze:forClass:", "parse:"]
+messageSends: ["ast:forClass:protocol:", "new"]
 }),
 $globals.ASTParsingTest);
 
@@ -326,9 +279,9 @@ var node;
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $3,$4,$2,$1,$7,$8,$6,$5;
-node=$self._parse_("yourself\x0a\x09^ self");
+node=$self._parse_forClass_("yourself\x0a\x09^ self",$globals.Object);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["parse:"]=1;
+$ctx1.sendIdx["parse:forClass:"]=1;
 //>>excludeEnd("ctx");
 $3=node;
 $4=(2).__at((4));
@@ -347,9 +300,9 @@ $self._assert_equals_($1,"self");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["assert:equals:"]=1;
 //>>excludeEnd("ctx");
-node=$self._parse_("foo\x0a\x09true ifTrue: [ 1 ]");
+node=$self._parse_forClass_("foo\x0a\x09true ifTrue: [ 1 ]",$globals.Object);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["parse:"]=2;
+$ctx1.sendIdx["parse:forClass:"]=2;
 //>>excludeEnd("ctx");
 $7=node;
 $8=(2).__at((7));
@@ -371,7 +324,7 @@ $self._assert_equals_($5,"ifTrue:");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["assert:equals:"]=2;
 //>>excludeEnd("ctx");
-node=$self._parse_("foo\x0a\x09self foo; bar; baz");
+node=$self._parse_forClass_("foo\x0a\x09self foo; bar; baz",$globals.Object);
 $self._assert_equals_($recv($recv(node)._navigationNodeAt_ifAbsent_((2).__at((8)),(function(){
 return nil;
 
@@ -383,10 +336,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testNodeAtPosition\x0a\x09| node |\x0a\x09\x0a\x09node := self parse: 'yourself\x0a\x09^ self'.\x0a\x09\x0a\x09self assert: (node navigationNodeAt: 2@4 ifAbsent: [ nil ]) source equals: 'self'.\x0a\x09\x0a\x09node := self parse: 'foo\x0a\x09true ifTrue: [ 1 ]'.\x0a\x09\x0a\x09self assert: (node navigationNodeAt: 2@7 ifAbsent: [ nil ]) selector equals: 'ifTrue:'.\x0a\x09\x0a\x09node := self parse: 'foo\x0a\x09self foo; bar; baz'.\x0a\x09\x0a\x09self assert: (node navigationNodeAt: 2@8 ifAbsent: [ nil ]) selector equals: 'foo'",
-referencedClasses: [],
+source: "testNodeAtPosition\x0a\x09| node |\x0a\x09\x0a\x09node := self parse: 'yourself\x0a\x09^ self' forClass: Object.\x0a\x09\x0a\x09self assert: (node navigationNodeAt: 2@4 ifAbsent: [ nil ]) source equals: 'self'.\x0a\x09\x0a\x09node := self parse: 'foo\x0a\x09true ifTrue: [ 1 ]' forClass: Object.\x0a\x09\x0a\x09self assert: (node navigationNodeAt: 2@7 ifAbsent: [ nil ]) selector equals: 'ifTrue:'.\x0a\x09\x0a\x09node := self parse: 'foo\x0a\x09self foo; bar; baz' forClass: Object.\x0a\x09\x0a\x09self assert: (node navigationNodeAt: 2@8 ifAbsent: [ nil ]) selector equals: 'foo'",
+referencedClasses: ["Object"],
 //>>excludeEnd("ide");
-messageSends: ["parse:", "assert:equals:", "source", "navigationNodeAt:ifAbsent:", "@", "selector"]
+messageSends: ["parse:forClass:", "assert:equals:", "source", "navigationNodeAt:ifAbsent:", "@", "selector"]
 }),
 $globals.ASTPositionTest);
 
@@ -1833,30 +1786,6 @@ $globals.CodeGeneratorTest);
 
 
 $core.addClass("ASTInterpreterTest", $globals.CodeGeneratorTest, [], "Compiler-Tests");
-$core.addMethod(
-$core.method({
-selector: "analyze:forClass:",
-protocol: "parsing",
-fn: function (aNode,aClass){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-$recv($recv($globals.SemanticAnalyzer)._on_(aClass))._visit_(aNode);
-return aNode;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"analyze:forClass:",{aNode:aNode,aClass:aClass},$globals.ASTInterpreterTest)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aNode", "aClass"],
-source: "analyze: aNode forClass: aClass\x0a\x09(SemanticAnalyzer on: aClass) visit: aNode.\x0a\x09^ aNode",
-referencedClasses: ["SemanticAnalyzer"],
-//>>excludeEnd("ide");
-messageSends: ["visit:", "on:"]
-}),
-$globals.ASTInterpreterTest);
-
 $core.addMethod(
 $core.method({
 selector: "interpret:receiver:withArguments:",
@@ -1921,52 +1850,6 @@ messageSends: ["new", "parse:forClass:", "class", "receiver:", "interpreter:", "
 }),
 $globals.ASTInterpreterTest);
 
-$core.addMethod(
-$core.method({
-selector: "parse:",
-protocol: "parsing",
-fn: function (aString){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return $recv($globals.Smalltalk)._parse_(aString);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},$globals.ASTInterpreterTest)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aString"],
-source: "parse: aString\x0a\x09^ Smalltalk parse: aString",
-referencedClasses: ["Smalltalk"],
-//>>excludeEnd("ide");
-messageSends: ["parse:"]
-}),
-$globals.ASTInterpreterTest);
-
-$core.addMethod(
-$core.method({
-selector: "parse:forClass:",
-protocol: "parsing",
-fn: function (aString,aClass){
-var self=this,$self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-return $self._analyze_forClass_($self._parse_(aString),aClass);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass},$globals.ASTInterpreterTest)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aString", "aClass"],
-source: "parse: aString forClass: aClass\x0a\x09^ self analyze: (self parse: aString) forClass: aClass",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: ["analyze:forClass:", "parse:"]
-}),
-$globals.ASTInterpreterTest);
-
 $core.addMethod(
 $core.method({
 selector: "should:receiver:return:",

+ 7 - 30
src/Compiler-Tests.st

@@ -3,21 +3,13 @@ TestCase subclass: #ASTParsingTest
 	instanceVariableNames: ''
 	package: 'Compiler-Tests'!
 
-!ASTParsingTest methodsFor: 'convenience'!
-
-analyze: aNode forClass: aClass
-	(SemanticAnalyzer on: aClass) visit: aNode.
-	^ aNode
-! !
-
 !ASTParsingTest methodsFor: 'parsing'!
 
-parse: aString
-	^ Smalltalk parse: aString
-!
-
 parse: aString forClass: aClass
-	^ self analyze: (self parse: aString) forClass: aClass
+	^ Compiler new
+		ast: aString
+		forClass: aClass
+		protocol: 'test'
 ! !
 
 ASTParsingTest subclass: #ASTPCNodeVisitorTest
@@ -101,17 +93,17 @@ testNodeAtPosition
 	| node |
 	
 	node := self parse: 'yourself
-	^ self'.
+	^ self' forClass: Object.
 	
 	self assert: (node navigationNodeAt: 2@4 ifAbsent: [ nil ]) source equals: 'self'.
 	
 	node := self parse: 'foo
-	true ifTrue: [ 1 ]'.
+	true ifTrue: [ 1 ]' forClass: Object.
 	
 	self assert: (node navigationNodeAt: 2@7 ifAbsent: [ nil ]) selector equals: 'ifTrue:'.
 	
 	node := self parse: 'foo
-	self foo; bar; baz'.
+	self foo; bar; baz' forClass: Object.
 	
 	self assert: (node navigationNodeAt: 2@8 ifAbsent: [ nil ]) selector equals: 'foo'
 ! !
@@ -475,21 +467,6 @@ CodeGeneratorTest subclass: #ASTInterpreterTest
 	instanceVariableNames: ''
 	package: 'Compiler-Tests'!
 
-!ASTInterpreterTest methodsFor: 'parsing'!
-
-analyze: aNode forClass: aClass
-	(SemanticAnalyzer on: aClass) visit: aNode.
-	^ aNode
-!
-
-parse: aString
-	^ Smalltalk parse: aString
-!
-
-parse: aString forClass: aClass
-	^ self analyze: (self parse: aString) forClass: aClass
-! !
-
 !ASTInterpreterTest methodsFor: 'private'!
 
 interpret: aString receiver: anObject withArguments: aDictionary