|
@@ -3253,7 +3253,7 @@ var compiler,package_,method,compiledSource,source,node;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
return $core.withContext(function($ctx1) {
|
|
return $core.withContext(function($ctx1) {
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
-var $1,$2,$5,$4,$3,$6,$8,$7,$receiver;
|
|
|
|
|
|
+var $1,$2,$4,$3,$8,$7,$6,$5,$receiver;
|
|
var $early={};
|
|
var $early={};
|
|
try {
|
|
try {
|
|
source=$recv(self["@sourceArea"])._val();
|
|
source=$recv(self["@sourceArea"])._val();
|
|
@@ -3269,46 +3269,73 @@ compiler=$recv($globals.Compiler)._new();
|
|
$ctx1.sendIdx["new"]=1;
|
|
$ctx1.sendIdx["new"]=1;
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
$recv(compiler)._source_(source);
|
|
$recv(compiler)._source_(source);
|
|
|
|
+$recv((function(){
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+return $core.withContext(function($ctx2) {
|
|
|
|
+//>>excludeEnd("ctx");
|
|
node=$recv(compiler)._parse_(source);
|
|
node=$recv(compiler)._parse_(source);
|
|
-$2=$recv(node)._isParseFailure();
|
|
|
|
-if($core.assert($2)){
|
|
|
|
-$5="PARSE ERROR: ".__comma($recv(node)._reason());
|
|
|
|
|
|
+return node;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
-$ctx1.sendIdx[","]=3;
|
|
|
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
-$4=$recv($5).__comma(", position: ");
|
|
|
|
|
|
+}))._on_do_($globals.ParseError,(function(e){
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
-$ctx1.sendIdx[","]=2;
|
|
|
|
|
|
+return $core.withContext(function($ctx2) {
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
-$3=$recv($4).__comma($recv($recv(node)._position())._asString());
|
|
|
|
|
|
+$2="PARSE ERROR: ".__comma($recv(e)._messageText());
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
-$ctx1.sendIdx[","]=1;
|
|
|
|
|
|
+$ctx2.sendIdx[","]=1;
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+throw $early=[$recv($globals.Terminal)._alert_($2)];
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1,3)});
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+}));
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+$ctx1.sendIdx["on:do:"]=1;
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
-return $recv($globals.Terminal)._alert_($3);
|
|
|
|
-}
|
|
|
|
package_=$recv(aClass)._packageOfProtocol_(self["@selectedProtocol"]);
|
|
package_=$recv(aClass)._packageOfProtocol_(self["@selectedProtocol"]);
|
|
|
|
+$recv((function(){
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+return $core.withContext(function($ctx2) {
|
|
|
|
+//>>excludeEnd("ctx");
|
|
compiledSource=$recv(compiler)._compileNode_forClass_package_(node,aClass,package_);
|
|
compiledSource=$recv(compiler)._compileNode_forClass_package_(node,aClass,package_);
|
|
-method=$recv(compiler)._eval_forPackage_(compiledSource,package_);
|
|
|
|
-$recv($recv(compiler)._unknownVariables())._do_((function(each){
|
|
|
|
|
|
+return compiledSource;
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,4)});
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+}))._on_do_($globals.UnknownVariableError,(function(e){
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
return $core.withContext(function($ctx2) {
|
|
return $core.withContext(function($ctx2) {
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
-$6=$recv($globals.Smalltalk)._existsJsGlobal_(each);
|
|
|
|
-if(!$core.assert($6)){
|
|
|
|
-$8=$recv("Declare '".__comma(each)).__comma("' as instance variable?");
|
|
|
|
|
|
+$4=$recv(e)._variableName();
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
-$ctx2.sendIdx[","]=4;
|
|
|
|
|
|
+$ctx2.sendIdx["variableName"]=1;
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
-$7=$recv($globals.Terminal)._confirm_($8);
|
|
|
|
-if($core.assert($7)){
|
|
|
|
-self._addInstanceVariableNamed_toClass_(each,aClass);
|
|
|
|
|
|
+$3=$recv($globals.Smalltalk)._existsJsGlobal_($4);
|
|
|
|
+if(!$core.assert($3)){
|
|
|
|
+$8=$recv(e)._variableName();
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+$ctx2.sendIdx["variableName"]=2;
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+$7="Declare '".__comma($8);
|
|
|
|
+$6=$recv($7).__comma("' as instance variable?");
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+$ctx2.sendIdx[","]=2;
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+$5=$recv($globals.Terminal)._confirm_($6);
|
|
|
|
+if($core.assert($5)){
|
|
|
|
+self._addInstanceVariableNamed_toClass_($recv(e)._variableName(),aClass);
|
|
throw $early=[self._compileMethodDefinitionFor_(aClass)];
|
|
throw $early=[self._compileMethodDefinitionFor_(aClass)];
|
|
|
|
+} else {
|
|
|
|
+throw $early=[nil];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
-}, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,3)});
|
|
|
|
|
|
+}, function($ctx2) {$ctx2.fillBlock({e:e},$ctx1,5)});
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
}));
|
|
}));
|
|
|
|
+method=$recv(compiler)._eval_forPackage_(compiledSource,package_);
|
|
$recv($recv($globals.ClassBuilder)._new())._installMethod_forClass_protocol_(method,aClass,self["@selectedProtocol"]);
|
|
$recv($recv($globals.ClassBuilder)._new())._installMethod_forClass_protocol_(method,aClass,self["@selectedProtocol"]);
|
|
self._updateMethodsList();
|
|
self._updateMethodsList();
|
|
self._selectMethod_(method);
|
|
self._selectMethod_(method);
|
|
@@ -3321,10 +3348,10 @@ catch(e) {if(e===$early)return e[0]; throw e}
|
|
},
|
|
},
|
|
//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
args: ["aClass"],
|
|
args: ["aClass"],
|
|
-source: "compileMethodDefinitionFor: aClass\x0a\x09| compiler package method compiledSource source node |\x0a\x09source := sourceArea val.\x0a\x09selectedProtocol ifNil: [ selectedProtocol := selectedMethod protocol ].\x0a\x09compiler := Compiler new.\x0a\x09compiler source: source.\x0a\x09node := compiler parse: source.\x0a\x09node isParseFailure ifTrue: [\x0a\x09^ Terminal alert: 'PARSE ERROR: ', node reason, ', position: ', node position asString ].\x0a\x09package := aClass packageOfProtocol: selectedProtocol.\x0a\x09compiledSource := compiler compileNode: node forClass: aClass package: package.\x0a\x09method := compiler eval: compiledSource forPackage: package.\x0a\x09compiler unknownVariables do: [ :each |\x0a\x09\x09\x22Do not try to redeclare javascript's objects\x22\x0a\x09\x09(Smalltalk existsJsGlobal: each) ifFalse: [\x0a\x09\x09(Terminal 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 protocol: selectedProtocol.\x0a\x09self updateMethodsList.\x0a\x09self selectMethod: method",
|
|
|
|
-referencedClasses: ["Compiler", "Terminal", "Smalltalk", "ClassBuilder"],
|
|
|
|
|
|
+source: "compileMethodDefinitionFor: aClass\x0a\x09| compiler package method compiledSource source node |\x0a\x09source := sourceArea val.\x0a\x09selectedProtocol ifNil: [ selectedProtocol := selectedMethod protocol ].\x0a\x09compiler := Compiler new.\x0a\x09compiler source: source.\x0a\x09[ node := compiler parse: source ]\x0a\x09on: ParseError do: [ :e |\x0a\x09^ Terminal alert: 'PARSE ERROR: ', e messageText ].\x0a\x09package := aClass packageOfProtocol: selectedProtocol.\x0a\x09[ compiledSource := compiler compileNode: node forClass: aClass package: package ]\x0a\x09on: UnknownVariableError do: [ :e |\x0a\x09\x09\x22Do not try to redeclare javascript's objects\x22\x0a\x09\x09(Smalltalk existsJsGlobal: e variableName) ifFalse: [\x0a\x09\x09(Terminal confirm: 'Declare ''', e variableName, ''' as instance variable?') ifFalse: [ ^ nil ] ifTrue: [\x0a\x09\x09\x09self addInstanceVariableNamed: e variableName toClass: aClass.\x0a\x09\x09\x09^ self compileMethodDefinitionFor: aClass ]] ].\x0a\x09method := compiler eval: compiledSource forPackage: package.\x0a\x09ClassBuilder new installMethod: method forClass: aClass protocol: selectedProtocol.\x0a\x09self updateMethodsList.\x0a\x09self selectMethod: method",
|
|
|
|
+referencedClasses: ["Compiler", "ParseError", "Terminal", "UnknownVariableError", "Smalltalk", "ClassBuilder"],
|
|
//>>excludeEnd("ide");
|
|
//>>excludeEnd("ide");
|
|
-messageSends: ["val", "ifNil:", "protocol", "new", "source:", "parse:", "ifTrue:", "isParseFailure", "alert:", ",", "reason", "asString", "position", "packageOfProtocol:", "compileNode:forClass:package:", "eval:forPackage:", "do:", "unknownVariables", "ifFalse:", "existsJsGlobal:", "confirm:", "addInstanceVariableNamed:toClass:", "compileMethodDefinitionFor:", "installMethod:forClass:protocol:", "updateMethodsList", "selectMethod:"]
|
|
|
|
|
|
+messageSends: ["val", "ifNil:", "protocol", "new", "source:", "on:do:", "parse:", "alert:", ",", "messageText", "packageOfProtocol:", "compileNode:forClass:package:", "ifFalse:", "existsJsGlobal:", "variableName", "ifFalse:ifTrue:", "confirm:", "addInstanceVariableNamed:toClass:", "compileMethodDefinitionFor:", "eval:forPackage:", "installMethod:forClass:protocol:", "updateMethodsList", "selectMethod:"]
|
|
}),
|
|
}),
|
|
$globals.Browser);
|
|
$globals.Browser);
|
|
|
|
|