소스 검색

- 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

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.