Browse Source

Adds comments for ClassRefVar >> alias and JSStream >> nextPutClassRefFunction:

Nicolas Petton 11 years ago
parent
commit
cb506d312d
4 changed files with 9 additions and 2 deletions
  1. 1 1
      js/Compiler-IR.js
  2. 1 1
      js/Compiler-Semantic.js
  3. 3 0
      st/Compiler-IR.st
  4. 4 0
      st/Compiler-Semantic.st

+ 1 - 1
js/Compiler-IR.js

@@ -3055,7 +3055,7 @@ _st($1)._nextPutAll_(")}");
 $2=_st($1)._lf();
 return self}, function($ctx1) {$ctx1.fill(self,"nextPutClassRefFunction:",{aString:aString},smalltalk.JSStream)})},
 args: ["aString"],
-source: "nextPutClassRefFunction: aString\x0a\x09stream\x0a\x09\x09nextPutAll: 'function $';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: '(){return smalltalk.';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: '||(typeof ';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: '==\x22undefined\x22?nil:';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: ')}';\x0a\x09\x09lf",
+source: "nextPutClassRefFunction: aString\x0a\x09\x22Creates an inner function $aString into method and called as `$Foo()`whenever the global is accessed.\x0a\x09This ensures that undefined global access will answer `nil`\x22\x0a\x09\x0a\x09stream\x0a\x09\x09nextPutAll: 'function $';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: '(){return smalltalk.';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: '||(typeof ';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: '==\x22undefined\x22?nil:';\x0a\x09\x09nextPutAll: aString;\x0a\x09\x09nextPutAll: ')}';\x0a\x09\x09lf",
 messageSends: ["nextPutAll:", "lf"],
 referencedClasses: []
 }),

+ 1 - 1
js/Compiler-Semantic.js

@@ -1052,7 +1052,7 @@ $1=_st(_st("$").__comma(_st(self)._name())).__comma("()");
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"alias",{},smalltalk.ClassRefVar)})},
 args: [],
-source: "alias\x0a\x09^ '$', self name, '()'",
+source: "alias\x0a\x09\x22Fixes issue #190.\x0a\x09A function is created in the method definition, answering the class or nil.\x0a\x09See JSStream >> #nextPutClassRefFunction:\x22\x0a\x09\x0a\x09^ '$', self name, '()'",
 messageSends: [",", "name"],
 referencedClasses: []
 }),

+ 3 - 0
st/Compiler-IR.st

@@ -1055,6 +1055,9 @@ nextPutBlockContextFor: anIRClosure during: aBlock
 !
 
 nextPutClassRefFunction: aString
+	"Creates an inner function $aString into method and called as `$Foo()`whenever the global is accessed.
+	This ensures that undefined global access will answer `nil`"
+	
 	stream
 		nextPutAll: 'function $';
 		nextPutAll: aString;

+ 4 - 0
st/Compiler-Semantic.st

@@ -306,6 +306,10 @@ I am an class reference variable!
 !ClassRefVar methodsFor: 'accessing'!
 
 alias
+	"Fixes issue #190.
+	A function is created in the method definition, answering the class or nil.
+	See JSStream >> #nextPutClassRefFunction:"
+	
 	^ '$', self name, '()'
 ! !