|
@@ -1730,7 +1730,7 @@ $globals.UnknownVar);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-$core.addClass('SemanticAnalyzer', $globals.NodeVisitor, ['currentScope', 'blockIndex', 'thePackage', 'theClass', 'classReferences', 'messageSends'], 'Compiler-Semantic');
|
|
|
|
|
|
+$core.addClass('SemanticAnalyzer', $globals.NodeVisitor, ['currentScope', 'blockIndex', 'thePackage', 'theClass', 'classReferences', 'messageSends', 'visitedRefIds'], 'Compiler-Semantic');
|
|
//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
$globals.SemanticAnalyzer.comment="I semantically analyze the abstract syntax tree and annotate it with informations such as non local returns and variable scopes.";
|
|
$globals.SemanticAnalyzer.comment="I semantically analyze the abstract syntax tree and annotate it with informations such as non local returns and variable scopes.";
|
|
//>>excludeEnd("ide");
|
|
//>>excludeEnd("ide");
|
|
@@ -1844,6 +1844,39 @@ messageSends: ["value", "ifTrue:ifFalse:", "and:", "not", "includes:", "globalJs
|
|
}),
|
|
}),
|
|
$globals.SemanticAnalyzer);
|
|
$globals.SemanticAnalyzer);
|
|
|
|
|
|
|
|
+$core.addMethod(
|
|
|
|
+$core.method({
|
|
|
|
+selector: "initialize",
|
|
|
|
+protocol: 'initialization',
|
|
|
|
+fn: function (){
|
|
|
|
+var self=this;
|
|
|
|
+function $Set(){return $globals.Set||(typeof Set=="undefined"?nil:Set)}
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+(
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+$ctx1.supercall = true,
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+($globals.SemanticAnalyzer.superclass||$boot.dnu).fn.prototype._initialize.apply($recv(self), []));
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+$ctx1.supercall = false;
|
|
|
|
+//>>excludeEnd("ctx");;
|
|
|
|
+self["@visitedRefIds"]=$recv($Set())._new();
|
|
|
|
+return self;
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"initialize",{},$globals.SemanticAnalyzer)});
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+},
|
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
|
+args: [],
|
|
|
|
+source: "initialize\x0a\x09super initialize.\x0a\x0a\x09visitedRefIds := Set new",
|
|
|
|
+referencedClasses: ["Set"],
|
|
|
|
+//>>excludeEnd("ide");
|
|
|
|
+messageSends: ["initialize", "new"]
|
|
|
|
+}),
|
|
|
|
+$globals.SemanticAnalyzer);
|
|
|
|
+
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "isVariableUndefined:inPackage:",
|
|
selector: "isVariableUndefined:inPackage:",
|
|
@@ -2380,12 +2413,21 @@ selector: "visitRefNode:",
|
|
protocol: 'visiting',
|
|
protocol: 'visiting',
|
|
fn: function (aNode){
|
|
fn: function (aNode){
|
|
var self=this;
|
|
var self=this;
|
|
|
|
+var ref,aux;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
return $core.withContext(function($ctx1) {
|
|
return $core.withContext(function($ctx1) {
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
-var $1;
|
|
|
|
-$recv($recv(aNode)._node())._shouldBeAliased_(true);
|
|
|
|
-$1=(
|
|
|
|
|
|
+var $1,$2;
|
|
|
|
+ref=$recv(aNode)._node();
|
|
|
|
+aux=$recv(self["@visitedRefIds"])._size();
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+$ctx1.sendIdx["size"]=1;
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+$recv(self["@visitedRefIds"])._add_($recv(ref)._nodeId());
|
|
|
|
+$1=$recv(aux).__lt($recv(self["@visitedRefIds"])._size());
|
|
|
|
+if($core.assert($1)){
|
|
|
|
+$recv(ref)._shouldBeAliased_(true);
|
|
|
|
+$2=(
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
$ctx1.supercall = true,
|
|
$ctx1.supercall = true,
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
@@ -2393,17 +2435,19 @@ $ctx1.supercall = true,
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
$ctx1.supercall = false;
|
|
$ctx1.supercall = false;
|
|
//>>excludeEnd("ctx");;
|
|
//>>excludeEnd("ctx");;
|
|
-return $1;
|
|
|
|
|
|
+return $2;
|
|
|
|
+};
|
|
|
|
+return self;
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
-}, function($ctx1) {$ctx1.fill(self,"visitRefNode:",{aNode:aNode},$globals.SemanticAnalyzer)});
|
|
|
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"visitRefNode:",{aNode:aNode,ref:ref,aux:aux},$globals.SemanticAnalyzer)});
|
|
//>>excludeEnd("ctx");
|
|
//>>excludeEnd("ctx");
|
|
},
|
|
},
|
|
//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
args: ["aNode"],
|
|
args: ["aNode"],
|
|
-source: "visitRefNode: aNode\x0a\x09aNode node shouldBeAliased: true.\x0a\x09^ super visitRefNode: aNode",
|
|
|
|
|
|
+source: "visitRefNode: aNode\x0a\x09| ref aux |\x0a\x09ref := aNode node.\x0a\x09aux := visitedRefIds size.\x0a\x09visitedRefIds add: ref nodeId.\x0a\x09aux < visitedRefIds size \x22added; not visited yet\x22 ifTrue: [\x0a\x09\x09ref shouldBeAliased: true.\x0a\x09\x09^ super visitRefNode: aNode ]",
|
|
referencedClasses: [],
|
|
referencedClasses: [],
|
|
//>>excludeEnd("ide");
|
|
//>>excludeEnd("ide");
|
|
-messageSends: ["shouldBeAliased:", "node", "visitRefNode:"]
|
|
|
|
|
|
+messageSends: ["node", "size", "add:", "nodeId", "ifTrue:", "<", "shouldBeAliased:", "visitRefNode:"]
|
|
}),
|
|
}),
|
|
$globals.SemanticAnalyzer);
|
|
$globals.SemanticAnalyzer);
|
|
|
|
|