1
0
ソースを参照

- Context handling in blocks
- thisContext pseudo-variable local set in AIContext

Nicolas Petton 12 年 前
コミット
2c2f723a7c
3 ファイル変更332 行追加268 行削除
  1. 153 131
      js/Compiler-Interpreter.deploy.js
  2. 160 133
      js/Compiler-Interpreter.js
  3. 19 4
      st/Compiler-Interpreter.st

ファイルの差分が大きいため隠しています
+ 153 - 131
js/Compiler-Interpreter.deploy.js


ファイルの差分が大きいため隠しています
+ 160 - 133
js/Compiler-Interpreter.js


+ 19 - 4
st/Compiler-Interpreter.st

@@ -19,7 +19,9 @@ localAt: aString put: anObject
 !
 
 locals
-	^ locals ifNil: [ locals := Dictionary new ]
+	locals ifNil: [ self initializeLocals ].
+	
+	^ locals
 !
 
 method
@@ -69,6 +71,11 @@ initializeFromMethodContext: aMethodContext
 		self outerContext: (self class fromMethodContext: aMethodContext outerContext) ].
 	aMethodContext locals keysAndValuesDo: [ :key :value |
 		self locals at: key put: value ]
+!
+
+initializeLocals
+	locals := Dictionary new.
+	locals at: 'thisContext' put: self.
 ! !
 
 !AIContext class methodsFor: 'instance creation'!
@@ -254,11 +261,19 @@ interpretAssignmentNode: aNode continue: aBlock
 !
 
 interpretBlockNode: aNode continue: aBlock
-	"TODO: Context should be set"
-	
 	self
 		continue: aBlock
-		value: [ self interpret: aNode nodes first; result ]
+		value: [ 
+			| blockResult |
+			
+			self context: (AIContext new
+				outerContext: self context;
+				yourself).
+			
+			blockResult := self interpret: aNode nodes first; result.
+			
+			self context: self context outerContext.
+			blockResult ]
 !
 
 interpretBlockSequenceNode: aNode continue: aBlock

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません