|
@@ -2199,6 +2199,7 @@ fn: function (aClass){
|
|
|
var self=this;
|
|
|
var compiler,method,source,node;
|
|
|
function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
|
|
|
+function $PlatformInterface(){return smalltalk.PlatformInterface||(typeof PlatformInterface=="undefined"?nil:PlatformInterface)}
|
|
|
function $ClassBuilder(){return smalltalk.ClassBuilder||(typeof ClassBuilder=="undefined"?nil:ClassBuilder)}
|
|
|
return smalltalk.withContext(function($ctx1) {
|
|
|
var $1,$2,$3,$4,$5,$6;
|
|
@@ -2224,16 +2225,14 @@ _st(compiler)._currentClass_(aClass);
|
|
|
method=_st(compiler)._eval_(_st(compiler)._compileNode_(node));
|
|
|
_st(_st(compiler)._unknownVariables())._do_((function(each){
|
|
|
return smalltalk.withContext(function($ctx2) {
|
|
|
-$4=_st(window)._at_(each);
|
|
|
-if(($receiver = $4) == nil || $receiver == undefined){
|
|
|
+$4=_st($PlatformInterface())._existsGlobal_(each);
|
|
|
+if(! smalltalk.assert($4)){
|
|
|
$5=self._confirm_(_st("Declare '".__comma(each)).__comma("' as instance variable?"));
|
|
|
if(smalltalk.assert($5)){
|
|
|
self._addInstanceVariableNamed_toClass_(each,aClass);
|
|
|
$6=self._compileMethodDefinitionFor_(aClass);
|
|
|
throw $early=[$6];
|
|
|
};
|
|
|
-} else {
|
|
|
-return $4;
|
|
|
};
|
|
|
}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
|
|
|
_st(_st($ClassBuilder())._new())._installMethod_forClass_category_(method,aClass,self["@selectedProtocol"]);
|
|
@@ -2243,9 +2242,9 @@ return self}
|
|
|
catch(e) {if(e===$early)return e[0]; throw e}
|
|
|
}, function($ctx1) {$ctx1.fill(self,"compileMethodDefinitionFor:",{aClass:aClass,compiler:compiler,method:method,source:source,node:node},smalltalk.Browser)})},
|
|
|
args: ["aClass"],
|
|
|
-source: "compileMethodDefinitionFor: aClass\x0a\x09| compiler method source node |\x0a\x09source := sourceArea val.\x0a\x09selectedProtocol ifNil: [ selectedProtocol := selectedMethod category ].\x0a\x09compiler := Compiler new.\x0a\x09compiler source: source.\x0a\x09node := compiler parse: source.\x0a\x09node isParseFailure ifTrue: [\x0a\x09^self alert: 'PARSE ERROR: ', node reason, ', position: ', node position asString].\x0a\x09compiler currentClass: aClass.\x0a\x09method := compiler eval: (compiler compileNode: node).\x0a\x09compiler unknownVariables do: [:each |\x0a\x09\x09\x22Do not try to redeclare javascript's objects\x22\x0a\x09\x09(window at: each) ifNil: [\x0a\x09\x09(self confirm: 'Declare ''', each, ''' as instance variable?') ifTrue: [\x0a\x09\x09\x09self addInstanceVariableNamed: each toClass: aClass.\x0a\x09\x09\x09^self compileMethodDefinitionFor: aClass]]].\x0a\x09ClassBuilder new installMethod: method forClass: aClass category: selectedProtocol.\x0a\x09self updateMethodsList.\x0a\x09self selectMethod: method",
|
|
|
-messageSends: ["val", "ifNil:", "category", "new", "source:", "parse:", "ifTrue:", "alert:", ",", "asString", "position", "reason", "isParseFailure", "currentClass:", "eval:", "compileNode:", "do:", "addInstanceVariableNamed:toClass:", "compileMethodDefinitionFor:", "confirm:", "at:", "unknownVariables", "installMethod:forClass:category:", "updateMethodsList", "selectMethod:"],
|
|
|
-referencedClasses: ["Compiler", "ClassBuilder"]
|
|
|
+source: "compileMethodDefinitionFor: aClass\x0a\x09| compiler method source node |\x0a\x09source := sourceArea val.\x0a\x09selectedProtocol ifNil: [ selectedProtocol := selectedMethod category ].\x0a\x09compiler := Compiler new.\x0a\x09compiler source: source.\x0a\x09node := compiler parse: source.\x0a\x09node isParseFailure ifTrue: [\x0a\x09^self alert: 'PARSE ERROR: ', node reason, ', position: ', node position asString].\x0a\x09compiler currentClass: aClass.\x0a\x09method := compiler eval: (compiler compileNode: node).\x0a\x09compiler unknownVariables do: [:each |\x0a\x09\x09\x22Do not try to redeclare javascript's objects\x22\x0a\x09\x09(PlatformInterface existsGlobal: each) ifFalse: [\x0a\x09\x09(self confirm: 'Declare ''', each, ''' as instance variable?') ifTrue: [\x0a\x09\x09\x09self addInstanceVariableNamed: each toClass: aClass.\x0a\x09\x09\x09^self compileMethodDefinitionFor: aClass]]].\x0a\x09ClassBuilder new installMethod: method forClass: aClass category: selectedProtocol.\x0a\x09self updateMethodsList.\x0a\x09self selectMethod: method",
|
|
|
+messageSends: ["val", "ifNil:", "category", "new", "source:", "parse:", "ifTrue:", "alert:", ",", "asString", "position", "reason", "isParseFailure", "currentClass:", "eval:", "compileNode:", "do:", "ifFalse:", "addInstanceVariableNamed:toClass:", "compileMethodDefinitionFor:", "confirm:", "existsGlobal:", "unknownVariables", "installMethod:forClass:category:", "updateMethodsList", "selectMethod:"],
|
|
|
+referencedClasses: ["Compiler", "PlatformInterface", "ClassBuilder"]
|
|
|
}),
|
|
|
smalltalk.Browser);
|
|
|
|