1
0
فهرست منبع

Try to stock to the coding conventions (https://github.com/NicolasPetton/amber/wiki/Coding-conventions)

Nicolas Petton 12 سال پیش
والد
کامیت
4a7d6d2821
2فایلهای تغییر یافته به همراه18 افزوده شده و 18 حذف شده
  1. 5 5
      js/Compiler-Interpreter.js
  2. 13 13
      st/Compiler-Interpreter.st

+ 5 - 5
js/Compiler-Interpreter.js

@@ -4,7 +4,7 @@ smalltalk.addMethod(
 "_initializeFromMethodContext_",
 smalltalk.method({
 selector: "initializeFromMethodContext:",
-category: 'accessing',
+category: 'initialization',
 fn: function (aMethodContext){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
var $1;
@@ -389,7 +389,7 @@ self["@currentValue"];
 _st(aBlock)._value_(_st(self)._currentValue());
 return self}, function($ctx1) {$ctx1.fill(self,"interpret:continue:",{aNode:aNode,aBlock:aBlock}, smalltalk.ASTInterpreter)})},
 args: ["aNode", "aBlock"],
-source: "interpret: aNode continue: aBlock\x0a\x0a\x09shouldReturn ifTrue: [ ^ self ].\x0a\x0a\x09aNode isNode \x0a    \x09ifTrue: [ self visit: aNode ]\x0a        ifFalse: [ currentValue := aNode ].\x0a\x09aBlock value: self currentValue",
+source: "interpret: aNode continue: aBlock\x0a\x09shouldReturn ifTrue: [ ^ self ].\x0a\x0a\x09aNode isNode \x0a    \x09ifTrue: [ self visit: aNode ]\x0a        ifFalse: [ currentValue := aNode ].\x0a\x09aBlock value: self currentValue",
 messageSends: ["ifTrue:", "ifTrue:ifFalse:", "visit:", "isNode", "value:", "currentValue"],
 referencedClasses: []
 }),
@@ -492,7 +492,7 @@ return $2;
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
 return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
 args: ["aNode"],
-source: "visitBlockNode: aNode\x0a\x09\x22TODO: Context should be set\x22\x0a    self continue: [ self interpret: aNode nodes first; currentValue ]",
+source: "visitBlockNode: aNode\x0a\x09\x22TODO: Context should be set\x22\x0a    \x0a    self continue: [ self interpret: aNode nodes first; currentValue ]",
 messageSends: ["continue:", "interpret:", "first", "nodes", "currentValue"],
 referencedClasses: []
 }),
@@ -551,7 +551,7 @@ return smalltalk.withContext(function($ctx2) {
return _st(self)._continue_(array
 }, function($ctx2) {$ctx2.fillBlock({array:array},$ctx1)})}));
 return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicArrayNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
 args: ["aNode"],
-source: "visitDynamicArrayNode: aNode\x0a\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a    \x09self continue: array ]",
+source: "visitDynamicArrayNode: aNode\x0a\x09self interpretAll: aNode nodes continue: [ :array |\x0a    \x09self continue: array ]",
 messageSends: ["interpretAll:continue:", "nodes", "continue:"],
 referencedClasses: []
 }),
@@ -575,7 +575,7 @@ return _st(self)._continue_(hashedCollection);
 }, function($ctx2) {$ctx2.fillBlock({array:array,hashedCollection:hashedCollection},$ctx1)})}));
 return self}, function($ctx1) {$ctx1.fill(self,"visitDynamicDictionaryNode:",{aNode:aNode}, smalltalk.ASTInterpreter)})},
 args: ["aNode"],
-source: "visitDynamicDictionaryNode: aNode\x0a\x09\x0a    self interpretAll: aNode nodes continue: [ :array | | hashedCollection |\x0a    \x09hashedCollection := HashedCollection new.\x0a        array do: [ :each | hashedCollection add: each ].\x0a        self continue: hashedCollection ]",
+source: "visitDynamicDictionaryNode: aNode\x0a    self interpretAll: aNode nodes continue: [ :array | | hashedCollection |\x0a    \x09hashedCollection := HashedCollection new.\x0a        array do: [ :each | hashedCollection add: each ].\x0a        self continue: hashedCollection ]",
 messageSends: ["interpretAll:continue:", "nodes", "new", "do:", "add:", "continue:"],
 referencedClasses: ["HashedCollection"]
 }),

+ 13 - 13
st/Compiler-Interpreter.st

@@ -5,16 +5,6 @@ NodeVisitor subclass: #AIContext
 
 !AIContext methodsFor: 'accessing'!
 
-initializeFromMethodContext: aMethodContext
-	self pc: aMethodContext pc.
-    self receiver: aMethodContext receiver.
-    self selector: aMethodContext selector.
-    aMethodContext outerContext ifNotNil: [
-		self outerContext: (self class fromMethodContext: aMethodContext outerContext) ].
-    aMethodContext locals keysAndValuesDo: [ :key :value |
-    	self locals at: key put: value ]
-!
-
 localAt: aString
 	^ self locals at: aString ifAbsent: [ nil ]
 !
@@ -51,6 +41,18 @@ receiver: anObject
 	self localAt: 'self' put: anObject
 ! !
 
+!AIContext methodsFor: 'initialization'!
+
+initializeFromMethodContext: aMethodContext
+	self pc: aMethodContext pc.
+    self receiver: aMethodContext receiver.
+    self selector: aMethodContext selector.
+    aMethodContext outerContext ifNotNil: [
+		self outerContext: (self class fromMethodContext: aMethodContext outerContext) ].
+    aMethodContext locals keysAndValuesDo: [ :key :value |
+    	self locals at: key put: value ]
+! !
+
 NodeVisitor subclass: #ASTInterpreter
 	instanceVariableNames: 'currentNode context shouldReturn currentValue'
 	package: 'Compiler-Interpreter'!
@@ -116,7 +118,6 @@ interpret: aNode
 !
 
 interpret: aNode continue: aBlock
-
 	shouldReturn ifTrue: [ ^ self ].
 
 	aNode isNode 
@@ -160,6 +161,7 @@ visitAssignmentNode: aNode
 
 visitBlockNode: aNode
 	"TODO: Context should be set"
+    
     self continue: [ self interpret: aNode nodes first; currentValue ]
 !
 
@@ -183,13 +185,11 @@ visitClassReferenceNode: aNode
 !
 
 visitDynamicArrayNode: aNode
-
 	self interpretAll: aNode nodes continue: [ :array |
     	self continue: array ]
 !
 
 visitDynamicDictionaryNode: aNode
-	
     self interpretAll: aNode nodes continue: [ :array | | hashedCollection |
     	hashedCollection := HashedCollection new.
         array do: [ :each | hashedCollection add: each ].