Compiler-Semantic.js 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849
  1. define(["amber/boot", "amber_core/Compiler-AST", "amber_core/Compiler-Core", "amber_core/Kernel-Objects"], function($boot){"use strict";
  2. if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
  3. if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver;
  4. var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
  5. if(!$boot.nilAsClass)$boot.nilAsClass=$boot.dnu;
  6. $core.addPackage("Compiler-Semantic");
  7. $core.packages["Compiler-Semantic"].innerEval = function (expr) { return eval(expr); };
  8. $core.packages["Compiler-Semantic"].transport = {"type":"amd","amdNamespace":"amber_core"};
  9. $core.addClass("LexicalScope", $globals.Object, ["node", "instruction", "temps", "args", "outerScope", "blockIndex"], "Compiler-Semantic");
  10. //>>excludeStart("ide", pragmas.excludeIdeData);
  11. $globals.LexicalScope.comment="I represent a lexical scope where variable names are associated with ScopeVars\x0aInstances are used for block scopes. Method scopes are instances of MethodLexicalScope.\x0a\x0aI am attached to a ScopeVar and method/block nodes.\x0aEach context (method/closure) get a fresh scope that inherits from its outer scope.";
  12. //>>excludeEnd("ide");
  13. $core.addMethod(
  14. $core.method({
  15. selector: "addArg:",
  16. protocol: "adding",
  17. fn: function (aString){
  18. var self=this,$self=this;
  19. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  20. return $core.withContext(function($ctx1) {
  21. //>>excludeEnd("ctx");
  22. var $1;
  23. $1=$self._args();
  24. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  25. $ctx1.sendIdx["args"]=1;
  26. //>>excludeEnd("ctx");
  27. $recv($1)._at_put_(aString,$recv($globals.ArgVar)._on_(aString));
  28. $recv($recv($self._args())._at_(aString))._scope_(self);
  29. return self;
  30. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  31. }, function($ctx1) {$ctx1.fill(self,"addArg:",{aString:aString},$globals.LexicalScope)});
  32. //>>excludeEnd("ctx");
  33. },
  34. //>>excludeStart("ide", pragmas.excludeIdeData);
  35. args: ["aString"],
  36. source: "addArg: aString\x0a\x09self args at: aString put: (ArgVar on: aString).\x0a\x09(self args at: aString) scope: self",
  37. referencedClasses: ["ArgVar"],
  38. //>>excludeEnd("ide");
  39. messageSends: ["at:put:", "args", "on:", "scope:", "at:"]
  40. }),
  41. $globals.LexicalScope);
  42. $core.addMethod(
  43. $core.method({
  44. selector: "addTemp:",
  45. protocol: "adding",
  46. fn: function (aString){
  47. var self=this,$self=this;
  48. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  49. return $core.withContext(function($ctx1) {
  50. //>>excludeEnd("ctx");
  51. var $1;
  52. $1=$self._temps();
  53. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  54. $ctx1.sendIdx["temps"]=1;
  55. //>>excludeEnd("ctx");
  56. $recv($1)._at_put_(aString,$recv($globals.TempVar)._on_(aString));
  57. $recv($recv($self._temps())._at_(aString))._scope_(self);
  58. return self;
  59. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  60. }, function($ctx1) {$ctx1.fill(self,"addTemp:",{aString:aString},$globals.LexicalScope)});
  61. //>>excludeEnd("ctx");
  62. },
  63. //>>excludeStart("ide", pragmas.excludeIdeData);
  64. args: ["aString"],
  65. source: "addTemp: aString\x0a\x09self temps at: aString put: (TempVar on: aString).\x0a\x09(self temps at: aString) scope: self",
  66. referencedClasses: ["TempVar"],
  67. //>>excludeEnd("ide");
  68. messageSends: ["at:put:", "temps", "on:", "scope:", "at:"]
  69. }),
  70. $globals.LexicalScope);
  71. $core.addMethod(
  72. $core.method({
  73. selector: "alias",
  74. protocol: "accessing",
  75. fn: function (){
  76. var self=this,$self=this;
  77. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  78. return $core.withContext(function($ctx1) {
  79. //>>excludeEnd("ctx");
  80. return "$ctx".__comma($recv($self._scopeLevel())._asString());
  81. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  82. }, function($ctx1) {$ctx1.fill(self,"alias",{},$globals.LexicalScope)});
  83. //>>excludeEnd("ctx");
  84. },
  85. //>>excludeStart("ide", pragmas.excludeIdeData);
  86. args: [],
  87. source: "alias\x0a\x09^ '$ctx', self scopeLevel asString",
  88. referencedClasses: [],
  89. //>>excludeEnd("ide");
  90. messageSends: [",", "asString", "scopeLevel"]
  91. }),
  92. $globals.LexicalScope);
  93. $core.addMethod(
  94. $core.method({
  95. selector: "allVariableNames",
  96. protocol: "accessing",
  97. fn: function (){
  98. var self=this,$self=this;
  99. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  100. return $core.withContext(function($ctx1) {
  101. //>>excludeEnd("ctx");
  102. var $1;
  103. $1=$recv($self._args())._keys();
  104. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  105. $ctx1.sendIdx["keys"]=1;
  106. //>>excludeEnd("ctx");
  107. return $recv($1).__comma($recv($self._temps())._keys());
  108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  109. }, function($ctx1) {$ctx1.fill(self,"allVariableNames",{},$globals.LexicalScope)});
  110. //>>excludeEnd("ctx");
  111. },
  112. //>>excludeStart("ide", pragmas.excludeIdeData);
  113. args: [],
  114. source: "allVariableNames\x0a\x09^ self args keys, self temps keys",
  115. referencedClasses: [],
  116. //>>excludeEnd("ide");
  117. messageSends: [",", "keys", "args", "temps"]
  118. }),
  119. $globals.LexicalScope);
  120. $core.addMethod(
  121. $core.method({
  122. selector: "args",
  123. protocol: "accessing",
  124. fn: function (){
  125. var self=this,$self=this;
  126. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  127. return $core.withContext(function($ctx1) {
  128. //>>excludeEnd("ctx");
  129. var $1,$receiver;
  130. $1=$self["@args"];
  131. if(($receiver = $1) == null || $receiver.a$nil){
  132. $self["@args"]=$recv($globals.Dictionary)._new();
  133. return $self["@args"];
  134. } else {
  135. return $1;
  136. }
  137. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  138. }, function($ctx1) {$ctx1.fill(self,"args",{},$globals.LexicalScope)});
  139. //>>excludeEnd("ctx");
  140. },
  141. //>>excludeStart("ide", pragmas.excludeIdeData);
  142. args: [],
  143. source: "args\x0a\x09^ args ifNil: [ args := Dictionary new ]",
  144. referencedClasses: ["Dictionary"],
  145. //>>excludeEnd("ide");
  146. messageSends: ["ifNil:", "new"]
  147. }),
  148. $globals.LexicalScope);
  149. $core.addMethod(
  150. $core.method({
  151. selector: "bindingFor:",
  152. protocol: "accessing",
  153. fn: function (aStringOrNode){
  154. var self=this,$self=this;
  155. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  156. return $core.withContext(function($ctx1) {
  157. //>>excludeEnd("ctx");
  158. var $2,$3,$4,$5,$1;
  159. $2=$self._pseudoVars();
  160. $3=$recv(aStringOrNode)._value();
  161. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  162. $ctx1.sendIdx["value"]=1;
  163. //>>excludeEnd("ctx");
  164. $1=$recv($2)._at_ifAbsent_($3,(function(){
  165. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  166. return $core.withContext(function($ctx2) {
  167. //>>excludeEnd("ctx");
  168. $4=$self._args();
  169. $5=$recv(aStringOrNode)._value();
  170. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  171. $ctx2.sendIdx["value"]=2;
  172. //>>excludeEnd("ctx");
  173. return $recv($4)._at_ifAbsent_($5,(function(){
  174. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  175. return $core.withContext(function($ctx3) {
  176. //>>excludeEnd("ctx");
  177. return $recv($self._temps())._at_ifAbsent_($recv(aStringOrNode)._value(),(function(){
  178. return nil;
  179. }));
  180. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  181. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  182. //>>excludeEnd("ctx");
  183. }));
  184. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  185. $ctx2.sendIdx["at:ifAbsent:"]=2;
  186. //>>excludeEnd("ctx");
  187. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  188. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  189. //>>excludeEnd("ctx");
  190. }));
  191. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  192. $ctx1.sendIdx["at:ifAbsent:"]=1;
  193. //>>excludeEnd("ctx");
  194. return $1;
  195. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  196. }, function($ctx1) {$ctx1.fill(self,"bindingFor:",{aStringOrNode:aStringOrNode},$globals.LexicalScope)});
  197. //>>excludeEnd("ctx");
  198. },
  199. //>>excludeStart("ide", pragmas.excludeIdeData);
  200. args: ["aStringOrNode"],
  201. source: "bindingFor: aStringOrNode\x0a\x09^ self pseudoVars at: aStringOrNode value ifAbsent: [\x0a\x09\x09self args at: aStringOrNode value ifAbsent: [\x0a\x09\x09\x09self temps at: aStringOrNode value ifAbsent: [ nil ]]]",
  202. referencedClasses: [],
  203. //>>excludeEnd("ide");
  204. messageSends: ["at:ifAbsent:", "pseudoVars", "value", "args", "temps"]
  205. }),
  206. $globals.LexicalScope);
  207. $core.addMethod(
  208. $core.method({
  209. selector: "blockIndex",
  210. protocol: "accessing",
  211. fn: function (){
  212. var self=this,$self=this;
  213. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  214. return $core.withContext(function($ctx1) {
  215. //>>excludeEnd("ctx");
  216. var $1,$receiver;
  217. $1=$self["@blockIndex"];
  218. if(($receiver = $1) == null || $receiver.a$nil){
  219. return (0);
  220. } else {
  221. return $1;
  222. }
  223. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  224. }, function($ctx1) {$ctx1.fill(self,"blockIndex",{},$globals.LexicalScope)});
  225. //>>excludeEnd("ctx");
  226. },
  227. //>>excludeStart("ide", pragmas.excludeIdeData);
  228. args: [],
  229. source: "blockIndex\x0a\x09^ blockIndex ifNil: [ 0 ]",
  230. referencedClasses: [],
  231. //>>excludeEnd("ide");
  232. messageSends: ["ifNil:"]
  233. }),
  234. $globals.LexicalScope);
  235. $core.addMethod(
  236. $core.method({
  237. selector: "blockIndex:",
  238. protocol: "accessing",
  239. fn: function (anInteger){
  240. var self=this,$self=this;
  241. $self["@blockIndex"]=anInteger;
  242. return self;
  243. },
  244. //>>excludeStart("ide", pragmas.excludeIdeData);
  245. args: ["anInteger"],
  246. source: "blockIndex: anInteger \x0a\x09blockIndex := anInteger",
  247. referencedClasses: [],
  248. //>>excludeEnd("ide");
  249. messageSends: []
  250. }),
  251. $globals.LexicalScope);
  252. $core.addMethod(
  253. $core.method({
  254. selector: "canInlineNonLocalReturns",
  255. protocol: "testing",
  256. fn: function (){
  257. var self=this,$self=this;
  258. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  259. return $core.withContext(function($ctx1) {
  260. //>>excludeEnd("ctx");
  261. return $recv($self._isInlined())._and_((function(){
  262. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  263. return $core.withContext(function($ctx2) {
  264. //>>excludeEnd("ctx");
  265. return $recv($self._outerScope())._canInlineNonLocalReturns();
  266. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  267. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  268. //>>excludeEnd("ctx");
  269. }));
  270. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  271. }, function($ctx1) {$ctx1.fill(self,"canInlineNonLocalReturns",{},$globals.LexicalScope)});
  272. //>>excludeEnd("ctx");
  273. },
  274. //>>excludeStart("ide", pragmas.excludeIdeData);
  275. args: [],
  276. source: "canInlineNonLocalReturns\x0a\x09^ self isInlined and: [ self outerScope canInlineNonLocalReturns ]",
  277. referencedClasses: [],
  278. //>>excludeEnd("ide");
  279. messageSends: ["and:", "isInlined", "canInlineNonLocalReturns", "outerScope"]
  280. }),
  281. $globals.LexicalScope);
  282. $core.addMethod(
  283. $core.method({
  284. selector: "instruction",
  285. protocol: "accessing",
  286. fn: function (){
  287. var self=this,$self=this;
  288. return $self["@instruction"];
  289. },
  290. //>>excludeStart("ide", pragmas.excludeIdeData);
  291. args: [],
  292. source: "instruction\x0a\x09^ instruction",
  293. referencedClasses: [],
  294. //>>excludeEnd("ide");
  295. messageSends: []
  296. }),
  297. $globals.LexicalScope);
  298. $core.addMethod(
  299. $core.method({
  300. selector: "instruction:",
  301. protocol: "accessing",
  302. fn: function (anIRInstruction){
  303. var self=this,$self=this;
  304. $self["@instruction"]=anIRInstruction;
  305. return self;
  306. },
  307. //>>excludeStart("ide", pragmas.excludeIdeData);
  308. args: ["anIRInstruction"],
  309. source: "instruction: anIRInstruction\x0a\x09instruction := anIRInstruction",
  310. referencedClasses: [],
  311. //>>excludeEnd("ide");
  312. messageSends: []
  313. }),
  314. $globals.LexicalScope);
  315. $core.addMethod(
  316. $core.method({
  317. selector: "isBlockScope",
  318. protocol: "testing",
  319. fn: function (){
  320. var self=this,$self=this;
  321. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  322. return $core.withContext(function($ctx1) {
  323. //>>excludeEnd("ctx");
  324. return $recv($self._isMethodScope())._not();
  325. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  326. }, function($ctx1) {$ctx1.fill(self,"isBlockScope",{},$globals.LexicalScope)});
  327. //>>excludeEnd("ctx");
  328. },
  329. //>>excludeStart("ide", pragmas.excludeIdeData);
  330. args: [],
  331. source: "isBlockScope\x0a\x09^ self isMethodScope not",
  332. referencedClasses: [],
  333. //>>excludeEnd("ide");
  334. messageSends: ["not", "isMethodScope"]
  335. }),
  336. $globals.LexicalScope);
  337. $core.addMethod(
  338. $core.method({
  339. selector: "isInlined",
  340. protocol: "testing",
  341. fn: function (){
  342. var self=this,$self=this;
  343. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  344. return $core.withContext(function($ctx1) {
  345. //>>excludeEnd("ctx");
  346. var $2,$1;
  347. $2=$self._instruction();
  348. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  349. $ctx1.sendIdx["instruction"]=1;
  350. //>>excludeEnd("ctx");
  351. $1=$recv($2)._notNil();
  352. return $recv($1)._and_((function(){
  353. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  354. return $core.withContext(function($ctx2) {
  355. //>>excludeEnd("ctx");
  356. return $recv($self._instruction())._isInlined();
  357. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  358. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  359. //>>excludeEnd("ctx");
  360. }));
  361. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  362. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},$globals.LexicalScope)});
  363. //>>excludeEnd("ctx");
  364. },
  365. //>>excludeStart("ide", pragmas.excludeIdeData);
  366. args: [],
  367. source: "isInlined\x0a\x09^ self instruction notNil and: [\x0a\x09\x09self instruction isInlined ]",
  368. referencedClasses: [],
  369. //>>excludeEnd("ide");
  370. messageSends: ["and:", "notNil", "instruction", "isInlined"]
  371. }),
  372. $globals.LexicalScope);
  373. $core.addMethod(
  374. $core.method({
  375. selector: "isMethodScope",
  376. protocol: "testing",
  377. fn: function (){
  378. var self=this,$self=this;
  379. return false;
  380. },
  381. //>>excludeStart("ide", pragmas.excludeIdeData);
  382. args: [],
  383. source: "isMethodScope\x0a\x09^ false",
  384. referencedClasses: [],
  385. //>>excludeEnd("ide");
  386. messageSends: []
  387. }),
  388. $globals.LexicalScope);
  389. $core.addMethod(
  390. $core.method({
  391. selector: "lookupVariable:",
  392. protocol: "accessing",
  393. fn: function (aNode){
  394. var self=this,$self=this;
  395. var lookup;
  396. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  397. return $core.withContext(function($ctx1) {
  398. //>>excludeEnd("ctx");
  399. var $1,$2,$receiver;
  400. lookup=$self._bindingFor_(aNode);
  401. $1=lookup;
  402. if(($receiver = $1) == null || $receiver.a$nil){
  403. $2=$self._outerScope();
  404. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  405. $ctx1.sendIdx["outerScope"]=1;
  406. //>>excludeEnd("ctx");
  407. if(($receiver = $2) == null || $receiver.a$nil){
  408. lookup=$2;
  409. } else {
  410. lookup=$recv($self._outerScope())._lookupVariable_(aNode);
  411. }
  412. lookup;
  413. } else {
  414. $1;
  415. }
  416. return lookup;
  417. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  418. }, function($ctx1) {$ctx1.fill(self,"lookupVariable:",{aNode:aNode,lookup:lookup},$globals.LexicalScope)});
  419. //>>excludeEnd("ctx");
  420. },
  421. //>>excludeStart("ide", pragmas.excludeIdeData);
  422. args: ["aNode"],
  423. source: "lookupVariable: aNode\x0a\x09| lookup |\x0a\x09lookup := (self bindingFor: aNode).\x0a\x09lookup ifNil: [\x0a\x09\x09lookup := self outerScope ifNotNil: [\x0a\x09\x09\x09(self outerScope lookupVariable: aNode) ]].\x0a\x09^ lookup",
  424. referencedClasses: [],
  425. //>>excludeEnd("ide");
  426. messageSends: ["bindingFor:", "ifNil:", "ifNotNil:", "outerScope", "lookupVariable:"]
  427. }),
  428. $globals.LexicalScope);
  429. $core.addMethod(
  430. $core.method({
  431. selector: "methodScope",
  432. protocol: "accessing",
  433. fn: function (){
  434. var self=this,$self=this;
  435. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  436. return $core.withContext(function($ctx1) {
  437. //>>excludeEnd("ctx");
  438. var $1,$receiver;
  439. $1=$self._outerScope();
  440. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  441. $ctx1.sendIdx["outerScope"]=1;
  442. //>>excludeEnd("ctx");
  443. if(($receiver = $1) == null || $receiver.a$nil){
  444. return $1;
  445. } else {
  446. return $recv($self._outerScope())._methodScope();
  447. }
  448. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  449. }, function($ctx1) {$ctx1.fill(self,"methodScope",{},$globals.LexicalScope)});
  450. //>>excludeEnd("ctx");
  451. },
  452. //>>excludeStart("ide", pragmas.excludeIdeData);
  453. args: [],
  454. source: "methodScope\x0a\x09^ self outerScope ifNotNil: [\x0a\x09\x09self outerScope methodScope ]",
  455. referencedClasses: [],
  456. //>>excludeEnd("ide");
  457. messageSends: ["ifNotNil:", "outerScope", "methodScope"]
  458. }),
  459. $globals.LexicalScope);
  460. $core.addMethod(
  461. $core.method({
  462. selector: "node",
  463. protocol: "accessing",
  464. fn: function (){
  465. var self=this,$self=this;
  466. return $self["@node"];
  467. },
  468. //>>excludeStart("ide", pragmas.excludeIdeData);
  469. args: [],
  470. source: "node\x0a\x09\x22Answer the node in which I am defined\x22\x0a\x09\x0a\x09^ node",
  471. referencedClasses: [],
  472. //>>excludeEnd("ide");
  473. messageSends: []
  474. }),
  475. $globals.LexicalScope);
  476. $core.addMethod(
  477. $core.method({
  478. selector: "node:",
  479. protocol: "accessing",
  480. fn: function (aNode){
  481. var self=this,$self=this;
  482. $self["@node"]=aNode;
  483. return self;
  484. },
  485. //>>excludeStart("ide", pragmas.excludeIdeData);
  486. args: ["aNode"],
  487. source: "node: aNode\x0a\x09node := aNode",
  488. referencedClasses: [],
  489. //>>excludeEnd("ide");
  490. messageSends: []
  491. }),
  492. $globals.LexicalScope);
  493. $core.addMethod(
  494. $core.method({
  495. selector: "outerScope",
  496. protocol: "accessing",
  497. fn: function (){
  498. var self=this,$self=this;
  499. return $self["@outerScope"];
  500. },
  501. //>>excludeStart("ide", pragmas.excludeIdeData);
  502. args: [],
  503. source: "outerScope\x0a\x09^ outerScope",
  504. referencedClasses: [],
  505. //>>excludeEnd("ide");
  506. messageSends: []
  507. }),
  508. $globals.LexicalScope);
  509. $core.addMethod(
  510. $core.method({
  511. selector: "outerScope:",
  512. protocol: "accessing",
  513. fn: function (aLexicalScope){
  514. var self=this,$self=this;
  515. $self["@outerScope"]=aLexicalScope;
  516. return self;
  517. },
  518. //>>excludeStart("ide", pragmas.excludeIdeData);
  519. args: ["aLexicalScope"],
  520. source: "outerScope: aLexicalScope\x0a\x09outerScope := aLexicalScope",
  521. referencedClasses: [],
  522. //>>excludeEnd("ide");
  523. messageSends: []
  524. }),
  525. $globals.LexicalScope);
  526. $core.addMethod(
  527. $core.method({
  528. selector: "pseudoVars",
  529. protocol: "accessing",
  530. fn: function (){
  531. var self=this,$self=this;
  532. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  533. return $core.withContext(function($ctx1) {
  534. //>>excludeEnd("ctx");
  535. return $recv($self._methodScope())._pseudoVars();
  536. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  537. }, function($ctx1) {$ctx1.fill(self,"pseudoVars",{},$globals.LexicalScope)});
  538. //>>excludeEnd("ctx");
  539. },
  540. //>>excludeStart("ide", pragmas.excludeIdeData);
  541. args: [],
  542. source: "pseudoVars\x0a\x09^ self methodScope pseudoVars",
  543. referencedClasses: [],
  544. //>>excludeEnd("ide");
  545. messageSends: ["pseudoVars", "methodScope"]
  546. }),
  547. $globals.LexicalScope);
  548. $core.addMethod(
  549. $core.method({
  550. selector: "scopeLevel",
  551. protocol: "accessing",
  552. fn: function (){
  553. var self=this,$self=this;
  554. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  555. return $core.withContext(function($ctx1) {
  556. //>>excludeEnd("ctx");
  557. var $1,$2,$4,$3,$receiver;
  558. $1=$self._outerScope();
  559. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  560. $ctx1.sendIdx["outerScope"]=1;
  561. //>>excludeEnd("ctx");
  562. if(($receiver = $1) == null || $receiver.a$nil){
  563. return (1);
  564. } else {
  565. $1;
  566. }
  567. $2=$self._isInlined();
  568. if($core.assert($2)){
  569. $4=$self._outerScope();
  570. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  571. $ctx1.sendIdx["outerScope"]=2;
  572. //>>excludeEnd("ctx");
  573. $3=$recv($4)._scopeLevel();
  574. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  575. $ctx1.sendIdx["scopeLevel"]=1;
  576. //>>excludeEnd("ctx");
  577. return $3;
  578. }
  579. return $recv($recv($self._outerScope())._scopeLevel()).__plus((1));
  580. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  581. }, function($ctx1) {$ctx1.fill(self,"scopeLevel",{},$globals.LexicalScope)});
  582. //>>excludeEnd("ctx");
  583. },
  584. //>>excludeStart("ide", pragmas.excludeIdeData);
  585. args: [],
  586. source: "scopeLevel\x0a\x09self outerScope ifNil: [ ^ 1 ].\x0a\x09self isInlined ifTrue: [ ^ self outerScope scopeLevel ].\x0a\x09\x0a\x09^ self outerScope scopeLevel + 1",
  587. referencedClasses: [],
  588. //>>excludeEnd("ide");
  589. messageSends: ["ifNil:", "outerScope", "ifTrue:", "isInlined", "scopeLevel", "+"]
  590. }),
  591. $globals.LexicalScope);
  592. $core.addMethod(
  593. $core.method({
  594. selector: "temps",
  595. protocol: "accessing",
  596. fn: function (){
  597. var self=this,$self=this;
  598. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  599. return $core.withContext(function($ctx1) {
  600. //>>excludeEnd("ctx");
  601. var $1,$receiver;
  602. $1=$self["@temps"];
  603. if(($receiver = $1) == null || $receiver.a$nil){
  604. $self["@temps"]=$recv($globals.Dictionary)._new();
  605. return $self["@temps"];
  606. } else {
  607. return $1;
  608. }
  609. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  610. }, function($ctx1) {$ctx1.fill(self,"temps",{},$globals.LexicalScope)});
  611. //>>excludeEnd("ctx");
  612. },
  613. //>>excludeStart("ide", pragmas.excludeIdeData);
  614. args: [],
  615. source: "temps\x0a\x09^ temps ifNil: [ temps := Dictionary new ]",
  616. referencedClasses: ["Dictionary"],
  617. //>>excludeEnd("ide");
  618. messageSends: ["ifNil:", "new"]
  619. }),
  620. $globals.LexicalScope);
  621. $core.addClass("MethodLexicalScope", $globals.LexicalScope, ["iVars", "pseudoVars", "unknownVariables", "localReturn", "nonLocalReturns"], "Compiler-Semantic");
  622. //>>excludeStart("ide", pragmas.excludeIdeData);
  623. $globals.MethodLexicalScope.comment="I represent a method scope.";
  624. //>>excludeEnd("ide");
  625. $core.addMethod(
  626. $core.method({
  627. selector: "addIVar:",
  628. protocol: "adding",
  629. fn: function (aString){
  630. var self=this,$self=this;
  631. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  632. return $core.withContext(function($ctx1) {
  633. //>>excludeEnd("ctx");
  634. var $1;
  635. $1=$self._iVars();
  636. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  637. $ctx1.sendIdx["iVars"]=1;
  638. //>>excludeEnd("ctx");
  639. $recv($1)._at_put_(aString,$recv($globals.InstanceVar)._on_(aString));
  640. $recv($recv($self._iVars())._at_(aString))._scope_(self);
  641. return self;
  642. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  643. }, function($ctx1) {$ctx1.fill(self,"addIVar:",{aString:aString},$globals.MethodLexicalScope)});
  644. //>>excludeEnd("ctx");
  645. },
  646. //>>excludeStart("ide", pragmas.excludeIdeData);
  647. args: ["aString"],
  648. source: "addIVar: aString\x0a\x09self iVars at: aString put: (InstanceVar on: aString).\x0a\x09(self iVars at: aString) scope: self",
  649. referencedClasses: ["InstanceVar"],
  650. //>>excludeEnd("ide");
  651. messageSends: ["at:put:", "iVars", "on:", "scope:", "at:"]
  652. }),
  653. $globals.MethodLexicalScope);
  654. $core.addMethod(
  655. $core.method({
  656. selector: "addNonLocalReturn:",
  657. protocol: "adding",
  658. fn: function (aScope){
  659. var self=this,$self=this;
  660. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  661. return $core.withContext(function($ctx1) {
  662. //>>excludeEnd("ctx");
  663. $recv($self._nonLocalReturns())._add_(aScope);
  664. return self;
  665. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  666. }, function($ctx1) {$ctx1.fill(self,"addNonLocalReturn:",{aScope:aScope},$globals.MethodLexicalScope)});
  667. //>>excludeEnd("ctx");
  668. },
  669. //>>excludeStart("ide", pragmas.excludeIdeData);
  670. args: ["aScope"],
  671. source: "addNonLocalReturn: aScope\x0a\x09self nonLocalReturns add: aScope",
  672. referencedClasses: [],
  673. //>>excludeEnd("ide");
  674. messageSends: ["add:", "nonLocalReturns"]
  675. }),
  676. $globals.MethodLexicalScope);
  677. $core.addMethod(
  678. $core.method({
  679. selector: "allVariableNames",
  680. protocol: "accessing",
  681. fn: function (){
  682. var self=this,$self=this;
  683. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  684. return $core.withContext(function($ctx1) {
  685. //>>excludeEnd("ctx");
  686. var $1;
  687. $1=(
  688. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  689. $ctx1.supercall = true,
  690. //>>excludeEnd("ctx");
  691. ($globals.MethodLexicalScope.superclass||$boot.nilAsClass).fn.prototype._allVariableNames.apply($self, []));
  692. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  693. $ctx1.supercall = false;
  694. //>>excludeEnd("ctx");;
  695. return $recv($1).__comma($recv($self._iVars())._keys());
  696. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  697. }, function($ctx1) {$ctx1.fill(self,"allVariableNames",{},$globals.MethodLexicalScope)});
  698. //>>excludeEnd("ctx");
  699. },
  700. //>>excludeStart("ide", pragmas.excludeIdeData);
  701. args: [],
  702. source: "allVariableNames\x0a\x09^ super allVariableNames, self iVars keys",
  703. referencedClasses: [],
  704. //>>excludeEnd("ide");
  705. messageSends: [",", "allVariableNames", "keys", "iVars"]
  706. }),
  707. $globals.MethodLexicalScope);
  708. $core.addMethod(
  709. $core.method({
  710. selector: "bindingFor:",
  711. protocol: "accessing",
  712. fn: function (aNode){
  713. var self=this,$self=this;
  714. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  715. return $core.withContext(function($ctx1) {
  716. //>>excludeEnd("ctx");
  717. var $1,$receiver;
  718. $1=(
  719. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  720. $ctx1.supercall = true,
  721. //>>excludeEnd("ctx");
  722. ($globals.MethodLexicalScope.superclass||$boot.nilAsClass).fn.prototype._bindingFor_.apply($self, [aNode]));
  723. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  724. $ctx1.supercall = false;
  725. //>>excludeEnd("ctx");;
  726. if(($receiver = $1) == null || $receiver.a$nil){
  727. return $recv($self._iVars())._at_ifAbsent_($recv(aNode)._value(),(function(){
  728. return nil;
  729. }));
  730. } else {
  731. return $1;
  732. }
  733. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  734. }, function($ctx1) {$ctx1.fill(self,"bindingFor:",{aNode:aNode},$globals.MethodLexicalScope)});
  735. //>>excludeEnd("ctx");
  736. },
  737. //>>excludeStart("ide", pragmas.excludeIdeData);
  738. args: ["aNode"],
  739. source: "bindingFor: aNode\x0a\x09^ (super bindingFor: aNode) ifNil: [\x0a\x09\x09self iVars at: aNode value ifAbsent: [ nil ]]",
  740. referencedClasses: [],
  741. //>>excludeEnd("ide");
  742. messageSends: ["ifNil:", "bindingFor:", "at:ifAbsent:", "iVars", "value"]
  743. }),
  744. $globals.MethodLexicalScope);
  745. $core.addMethod(
  746. $core.method({
  747. selector: "canInlineNonLocalReturns",
  748. protocol: "testing",
  749. fn: function (){
  750. var self=this,$self=this;
  751. return true;
  752. },
  753. //>>excludeStart("ide", pragmas.excludeIdeData);
  754. args: [],
  755. source: "canInlineNonLocalReturns\x0a\x09^ true",
  756. referencedClasses: [],
  757. //>>excludeEnd("ide");
  758. messageSends: []
  759. }),
  760. $globals.MethodLexicalScope);
  761. $core.addMethod(
  762. $core.method({
  763. selector: "hasLocalReturn",
  764. protocol: "testing",
  765. fn: function (){
  766. var self=this,$self=this;
  767. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  768. return $core.withContext(function($ctx1) {
  769. //>>excludeEnd("ctx");
  770. return $self._localReturn();
  771. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  772. }, function($ctx1) {$ctx1.fill(self,"hasLocalReturn",{},$globals.MethodLexicalScope)});
  773. //>>excludeEnd("ctx");
  774. },
  775. //>>excludeStart("ide", pragmas.excludeIdeData);
  776. args: [],
  777. source: "hasLocalReturn\x0a\x09^ self localReturn",
  778. referencedClasses: [],
  779. //>>excludeEnd("ide");
  780. messageSends: ["localReturn"]
  781. }),
  782. $globals.MethodLexicalScope);
  783. $core.addMethod(
  784. $core.method({
  785. selector: "hasNonLocalReturn",
  786. protocol: "testing",
  787. fn: function (){
  788. var self=this,$self=this;
  789. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  790. return $core.withContext(function($ctx1) {
  791. //>>excludeEnd("ctx");
  792. return $recv($self._nonLocalReturns())._notEmpty();
  793. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  794. }, function($ctx1) {$ctx1.fill(self,"hasNonLocalReturn",{},$globals.MethodLexicalScope)});
  795. //>>excludeEnd("ctx");
  796. },
  797. //>>excludeStart("ide", pragmas.excludeIdeData);
  798. args: [],
  799. source: "hasNonLocalReturn\x0a\x09^ self nonLocalReturns notEmpty",
  800. referencedClasses: [],
  801. //>>excludeEnd("ide");
  802. messageSends: ["notEmpty", "nonLocalReturns"]
  803. }),
  804. $globals.MethodLexicalScope);
  805. $core.addMethod(
  806. $core.method({
  807. selector: "iVars",
  808. protocol: "accessing",
  809. fn: function (){
  810. var self=this,$self=this;
  811. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  812. return $core.withContext(function($ctx1) {
  813. //>>excludeEnd("ctx");
  814. var $1,$receiver;
  815. $1=$self["@iVars"];
  816. if(($receiver = $1) == null || $receiver.a$nil){
  817. $self["@iVars"]=$recv($globals.Dictionary)._new();
  818. return $self["@iVars"];
  819. } else {
  820. return $1;
  821. }
  822. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  823. }, function($ctx1) {$ctx1.fill(self,"iVars",{},$globals.MethodLexicalScope)});
  824. //>>excludeEnd("ctx");
  825. },
  826. //>>excludeStart("ide", pragmas.excludeIdeData);
  827. args: [],
  828. source: "iVars\x0a\x09^ iVars ifNil: [ iVars := Dictionary new ]",
  829. referencedClasses: ["Dictionary"],
  830. //>>excludeEnd("ide");
  831. messageSends: ["ifNil:", "new"]
  832. }),
  833. $globals.MethodLexicalScope);
  834. $core.addMethod(
  835. $core.method({
  836. selector: "isMethodScope",
  837. protocol: "testing",
  838. fn: function (){
  839. var self=this,$self=this;
  840. return true;
  841. },
  842. //>>excludeStart("ide", pragmas.excludeIdeData);
  843. args: [],
  844. source: "isMethodScope\x0a\x09^ true",
  845. referencedClasses: [],
  846. //>>excludeEnd("ide");
  847. messageSends: []
  848. }),
  849. $globals.MethodLexicalScope);
  850. $core.addMethod(
  851. $core.method({
  852. selector: "localReturn",
  853. protocol: "accessing",
  854. fn: function (){
  855. var self=this,$self=this;
  856. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  857. return $core.withContext(function($ctx1) {
  858. //>>excludeEnd("ctx");
  859. var $1,$receiver;
  860. $1=$self["@localReturn"];
  861. if(($receiver = $1) == null || $receiver.a$nil){
  862. return false;
  863. } else {
  864. return $1;
  865. }
  866. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  867. }, function($ctx1) {$ctx1.fill(self,"localReturn",{},$globals.MethodLexicalScope)});
  868. //>>excludeEnd("ctx");
  869. },
  870. //>>excludeStart("ide", pragmas.excludeIdeData);
  871. args: [],
  872. source: "localReturn\x0a\x09^ localReturn ifNil: [ false ]",
  873. referencedClasses: [],
  874. //>>excludeEnd("ide");
  875. messageSends: ["ifNil:"]
  876. }),
  877. $globals.MethodLexicalScope);
  878. $core.addMethod(
  879. $core.method({
  880. selector: "localReturn:",
  881. protocol: "accessing",
  882. fn: function (aBoolean){
  883. var self=this,$self=this;
  884. $self["@localReturn"]=aBoolean;
  885. return self;
  886. },
  887. //>>excludeStart("ide", pragmas.excludeIdeData);
  888. args: ["aBoolean"],
  889. source: "localReturn: aBoolean\x0a\x09localReturn := aBoolean",
  890. referencedClasses: [],
  891. //>>excludeEnd("ide");
  892. messageSends: []
  893. }),
  894. $globals.MethodLexicalScope);
  895. $core.addMethod(
  896. $core.method({
  897. selector: "methodScope",
  898. protocol: "accessing",
  899. fn: function (){
  900. var self=this,$self=this;
  901. return self;
  902. },
  903. //>>excludeStart("ide", pragmas.excludeIdeData);
  904. args: [],
  905. source: "methodScope\x0a\x09^ self",
  906. referencedClasses: [],
  907. //>>excludeEnd("ide");
  908. messageSends: []
  909. }),
  910. $globals.MethodLexicalScope);
  911. $core.addMethod(
  912. $core.method({
  913. selector: "nonLocalReturns",
  914. protocol: "accessing",
  915. fn: function (){
  916. var self=this,$self=this;
  917. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  918. return $core.withContext(function($ctx1) {
  919. //>>excludeEnd("ctx");
  920. var $1,$receiver;
  921. $1=$self["@nonLocalReturns"];
  922. if(($receiver = $1) == null || $receiver.a$nil){
  923. $self["@nonLocalReturns"]=$recv($globals.OrderedCollection)._new();
  924. return $self["@nonLocalReturns"];
  925. } else {
  926. return $1;
  927. }
  928. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  929. }, function($ctx1) {$ctx1.fill(self,"nonLocalReturns",{},$globals.MethodLexicalScope)});
  930. //>>excludeEnd("ctx");
  931. },
  932. //>>excludeStart("ide", pragmas.excludeIdeData);
  933. args: [],
  934. source: "nonLocalReturns\x0a\x09^ nonLocalReturns ifNil: [ nonLocalReturns := OrderedCollection new ]",
  935. referencedClasses: ["OrderedCollection"],
  936. //>>excludeEnd("ide");
  937. messageSends: ["ifNil:", "new"]
  938. }),
  939. $globals.MethodLexicalScope);
  940. $core.addMethod(
  941. $core.method({
  942. selector: "pseudoVars",
  943. protocol: "accessing",
  944. fn: function (){
  945. var self=this,$self=this;
  946. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  947. return $core.withContext(function($ctx1) {
  948. //>>excludeEnd("ctx");
  949. var $1,$2,$4,$3,$receiver;
  950. $1=$self["@pseudoVars"];
  951. if(($receiver = $1) == null || $receiver.a$nil){
  952. $self["@pseudoVars"]=$recv($globals.Dictionary)._new();
  953. $self["@pseudoVars"];
  954. $recv($recv($globals.Smalltalk)._pseudoVariableNames())._do_((function(each){
  955. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  956. return $core.withContext(function($ctx2) {
  957. //>>excludeEnd("ctx");
  958. $2=$self["@pseudoVars"];
  959. $4=$recv($globals.PseudoVar)._on_(each);
  960. $recv($4)._scope_($self._methodScope());
  961. $3=$recv($4)._yourself();
  962. return $recv($2)._at_put_(each,$3);
  963. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  964. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  965. //>>excludeEnd("ctx");
  966. }));
  967. } else {
  968. $1;
  969. }
  970. return $self["@pseudoVars"];
  971. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  972. }, function($ctx1) {$ctx1.fill(self,"pseudoVars",{},$globals.MethodLexicalScope)});
  973. //>>excludeEnd("ctx");
  974. },
  975. //>>excludeStart("ide", pragmas.excludeIdeData);
  976. args: [],
  977. source: "pseudoVars\x0a\x09pseudoVars ifNil: [\x0a\x09\x09pseudoVars := Dictionary new.\x0a\x09\x09Smalltalk pseudoVariableNames do: [ :each |\x0a\x09\x09\x09pseudoVars at: each put: ((PseudoVar on: each)\x0a\x09\x09\x09\x09scope: self methodScope;\x0a\x09\x09\x09\x09yourself) ]].\x0a\x09^ pseudoVars",
  978. referencedClasses: ["Dictionary", "Smalltalk", "PseudoVar"],
  979. //>>excludeEnd("ide");
  980. messageSends: ["ifNil:", "new", "do:", "pseudoVariableNames", "at:put:", "scope:", "on:", "methodScope", "yourself"]
  981. }),
  982. $globals.MethodLexicalScope);
  983. $core.addMethod(
  984. $core.method({
  985. selector: "removeNonLocalReturn:",
  986. protocol: "adding",
  987. fn: function (aScope){
  988. var self=this,$self=this;
  989. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  990. return $core.withContext(function($ctx1) {
  991. //>>excludeEnd("ctx");
  992. $recv($self._nonLocalReturns())._remove_ifAbsent_(aScope,(function(){
  993. }));
  994. return self;
  995. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  996. }, function($ctx1) {$ctx1.fill(self,"removeNonLocalReturn:",{aScope:aScope},$globals.MethodLexicalScope)});
  997. //>>excludeEnd("ctx");
  998. },
  999. //>>excludeStart("ide", pragmas.excludeIdeData);
  1000. args: ["aScope"],
  1001. source: "removeNonLocalReturn: aScope\x0a\x09self nonLocalReturns remove: aScope ifAbsent: []",
  1002. referencedClasses: [],
  1003. //>>excludeEnd("ide");
  1004. messageSends: ["remove:ifAbsent:", "nonLocalReturns"]
  1005. }),
  1006. $globals.MethodLexicalScope);
  1007. $core.addMethod(
  1008. $core.method({
  1009. selector: "unknownVariables",
  1010. protocol: "accessing",
  1011. fn: function (){
  1012. var self=this,$self=this;
  1013. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1014. return $core.withContext(function($ctx1) {
  1015. //>>excludeEnd("ctx");
  1016. var $1,$receiver;
  1017. $1=$self["@unknownVariables"];
  1018. if(($receiver = $1) == null || $receiver.a$nil){
  1019. $self["@unknownVariables"]=$recv($globals.OrderedCollection)._new();
  1020. return $self["@unknownVariables"];
  1021. } else {
  1022. return $1;
  1023. }
  1024. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1025. }, function($ctx1) {$ctx1.fill(self,"unknownVariables",{},$globals.MethodLexicalScope)});
  1026. //>>excludeEnd("ctx");
  1027. },
  1028. //>>excludeStart("ide", pragmas.excludeIdeData);
  1029. args: [],
  1030. source: "unknownVariables\x0a\x09^ unknownVariables ifNil: [ unknownVariables := OrderedCollection new ]",
  1031. referencedClasses: ["OrderedCollection"],
  1032. //>>excludeEnd("ide");
  1033. messageSends: ["ifNil:", "new"]
  1034. }),
  1035. $globals.MethodLexicalScope);
  1036. $core.addClass("ScopeVar", $globals.Object, ["scope", "name"], "Compiler-Semantic");
  1037. //>>excludeStart("ide", pragmas.excludeIdeData);
  1038. $globals.ScopeVar.comment="I am an entry in a LexicalScope that gets associated with variable nodes of the same name.\x0aThere are 4 different subclasses of vars: temp vars, local vars, args, and unknown/global vars.";
  1039. //>>excludeEnd("ide");
  1040. $core.addMethod(
  1041. $core.method({
  1042. selector: "alias",
  1043. protocol: "accessing",
  1044. fn: function (){
  1045. var self=this,$self=this;
  1046. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1047. return $core.withContext(function($ctx1) {
  1048. //>>excludeEnd("ctx");
  1049. return $recv($self._name())._asVariableName();
  1050. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1051. }, function($ctx1) {$ctx1.fill(self,"alias",{},$globals.ScopeVar)});
  1052. //>>excludeEnd("ctx");
  1053. },
  1054. //>>excludeStart("ide", pragmas.excludeIdeData);
  1055. args: [],
  1056. source: "alias\x0a\x09^ self name asVariableName",
  1057. referencedClasses: [],
  1058. //>>excludeEnd("ide");
  1059. messageSends: ["asVariableName", "name"]
  1060. }),
  1061. $globals.ScopeVar);
  1062. $core.addMethod(
  1063. $core.method({
  1064. selector: "isArgVar",
  1065. protocol: "testing",
  1066. fn: function (){
  1067. var self=this,$self=this;
  1068. return false;
  1069. },
  1070. //>>excludeStart("ide", pragmas.excludeIdeData);
  1071. args: [],
  1072. source: "isArgVar\x0a\x09^ false",
  1073. referencedClasses: [],
  1074. //>>excludeEnd("ide");
  1075. messageSends: []
  1076. }),
  1077. $globals.ScopeVar);
  1078. $core.addMethod(
  1079. $core.method({
  1080. selector: "isClassRefVar",
  1081. protocol: "testing",
  1082. fn: function (){
  1083. var self=this,$self=this;
  1084. return false;
  1085. },
  1086. //>>excludeStart("ide", pragmas.excludeIdeData);
  1087. args: [],
  1088. source: "isClassRefVar\x0a\x09^ false",
  1089. referencedClasses: [],
  1090. //>>excludeEnd("ide");
  1091. messageSends: []
  1092. }),
  1093. $globals.ScopeVar);
  1094. $core.addMethod(
  1095. $core.method({
  1096. selector: "isImmutable",
  1097. protocol: "testing",
  1098. fn: function (){
  1099. var self=this,$self=this;
  1100. return false;
  1101. },
  1102. //>>excludeStart("ide", pragmas.excludeIdeData);
  1103. args: [],
  1104. source: "isImmutable\x0a\x09^ false",
  1105. referencedClasses: [],
  1106. //>>excludeEnd("ide");
  1107. messageSends: []
  1108. }),
  1109. $globals.ScopeVar);
  1110. $core.addMethod(
  1111. $core.method({
  1112. selector: "isInstanceVar",
  1113. protocol: "testing",
  1114. fn: function (){
  1115. var self=this,$self=this;
  1116. return false;
  1117. },
  1118. //>>excludeStart("ide", pragmas.excludeIdeData);
  1119. args: [],
  1120. source: "isInstanceVar\x0a\x09^ false",
  1121. referencedClasses: [],
  1122. //>>excludeEnd("ide");
  1123. messageSends: []
  1124. }),
  1125. $globals.ScopeVar);
  1126. $core.addMethod(
  1127. $core.method({
  1128. selector: "isPseudoVar",
  1129. protocol: "testing",
  1130. fn: function (){
  1131. var self=this,$self=this;
  1132. return false;
  1133. },
  1134. //>>excludeStart("ide", pragmas.excludeIdeData);
  1135. args: [],
  1136. source: "isPseudoVar\x0a\x09^ false",
  1137. referencedClasses: [],
  1138. //>>excludeEnd("ide");
  1139. messageSends: []
  1140. }),
  1141. $globals.ScopeVar);
  1142. $core.addMethod(
  1143. $core.method({
  1144. selector: "isSelf",
  1145. protocol: "testing",
  1146. fn: function (){
  1147. var self=this,$self=this;
  1148. return false;
  1149. },
  1150. //>>excludeStart("ide", pragmas.excludeIdeData);
  1151. args: [],
  1152. source: "isSelf\x0a\x09^ false",
  1153. referencedClasses: [],
  1154. //>>excludeEnd("ide");
  1155. messageSends: []
  1156. }),
  1157. $globals.ScopeVar);
  1158. $core.addMethod(
  1159. $core.method({
  1160. selector: "isSuper",
  1161. protocol: "testing",
  1162. fn: function (){
  1163. var self=this,$self=this;
  1164. return false;
  1165. },
  1166. //>>excludeStart("ide", pragmas.excludeIdeData);
  1167. args: [],
  1168. source: "isSuper\x0a\x09^ false",
  1169. referencedClasses: [],
  1170. //>>excludeEnd("ide");
  1171. messageSends: []
  1172. }),
  1173. $globals.ScopeVar);
  1174. $core.addMethod(
  1175. $core.method({
  1176. selector: "isTempVar",
  1177. protocol: "testing",
  1178. fn: function (){
  1179. var self=this,$self=this;
  1180. return false;
  1181. },
  1182. //>>excludeStart("ide", pragmas.excludeIdeData);
  1183. args: [],
  1184. source: "isTempVar\x0a\x09^ false",
  1185. referencedClasses: [],
  1186. //>>excludeEnd("ide");
  1187. messageSends: []
  1188. }),
  1189. $globals.ScopeVar);
  1190. $core.addMethod(
  1191. $core.method({
  1192. selector: "isUnknownVar",
  1193. protocol: "testing",
  1194. fn: function (){
  1195. var self=this,$self=this;
  1196. return false;
  1197. },
  1198. //>>excludeStart("ide", pragmas.excludeIdeData);
  1199. args: [],
  1200. source: "isUnknownVar\x0a\x09^ false",
  1201. referencedClasses: [],
  1202. //>>excludeEnd("ide");
  1203. messageSends: []
  1204. }),
  1205. $globals.ScopeVar);
  1206. $core.addMethod(
  1207. $core.method({
  1208. selector: "name",
  1209. protocol: "accessing",
  1210. fn: function (){
  1211. var self=this,$self=this;
  1212. return $self["@name"];
  1213. },
  1214. //>>excludeStart("ide", pragmas.excludeIdeData);
  1215. args: [],
  1216. source: "name\x0a\x09^ name",
  1217. referencedClasses: [],
  1218. //>>excludeEnd("ide");
  1219. messageSends: []
  1220. }),
  1221. $globals.ScopeVar);
  1222. $core.addMethod(
  1223. $core.method({
  1224. selector: "name:",
  1225. protocol: "accessing",
  1226. fn: function (aString){
  1227. var self=this,$self=this;
  1228. $self["@name"]=aString;
  1229. return self;
  1230. },
  1231. //>>excludeStart("ide", pragmas.excludeIdeData);
  1232. args: ["aString"],
  1233. source: "name: aString\x0a\x09name := aString",
  1234. referencedClasses: [],
  1235. //>>excludeEnd("ide");
  1236. messageSends: []
  1237. }),
  1238. $globals.ScopeVar);
  1239. $core.addMethod(
  1240. $core.method({
  1241. selector: "scope",
  1242. protocol: "accessing",
  1243. fn: function (){
  1244. var self=this,$self=this;
  1245. return $self["@scope"];
  1246. },
  1247. //>>excludeStart("ide", pragmas.excludeIdeData);
  1248. args: [],
  1249. source: "scope\x0a\x09^ scope",
  1250. referencedClasses: [],
  1251. //>>excludeEnd("ide");
  1252. messageSends: []
  1253. }),
  1254. $globals.ScopeVar);
  1255. $core.addMethod(
  1256. $core.method({
  1257. selector: "scope:",
  1258. protocol: "accessing",
  1259. fn: function (aScope){
  1260. var self=this,$self=this;
  1261. $self["@scope"]=aScope;
  1262. return self;
  1263. },
  1264. //>>excludeStart("ide", pragmas.excludeIdeData);
  1265. args: ["aScope"],
  1266. source: "scope: aScope\x0a\x09scope := aScope",
  1267. referencedClasses: [],
  1268. //>>excludeEnd("ide");
  1269. messageSends: []
  1270. }),
  1271. $globals.ScopeVar);
  1272. $core.addMethod(
  1273. $core.method({
  1274. selector: "validateAssignment",
  1275. protocol: "testing",
  1276. fn: function (){
  1277. var self=this,$self=this;
  1278. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1279. return $core.withContext(function($ctx1) {
  1280. //>>excludeEnd("ctx");
  1281. var $1,$2;
  1282. $1=$recv($self._isArgVar())._or_((function(){
  1283. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1284. return $core.withContext(function($ctx2) {
  1285. //>>excludeEnd("ctx");
  1286. return $self._isPseudoVar();
  1287. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1288. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1289. //>>excludeEnd("ctx");
  1290. }));
  1291. if($core.assert($1)){
  1292. $2=$recv($globals.InvalidAssignmentError)._new();
  1293. $recv($2)._variableName_($self._name());
  1294. $recv($2)._signal();
  1295. }
  1296. return self;
  1297. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1298. }, function($ctx1) {$ctx1.fill(self,"validateAssignment",{},$globals.ScopeVar)});
  1299. //>>excludeEnd("ctx");
  1300. },
  1301. //>>excludeStart("ide", pragmas.excludeIdeData);
  1302. args: [],
  1303. source: "validateAssignment\x0a\x09(self isArgVar or: [ self isPseudoVar ]) ifTrue: [\x0a\x09\x09InvalidAssignmentError new\x0a\x09\x09\x09variableName: self name;\x0a\x09\x09\x09signal]",
  1304. referencedClasses: ["InvalidAssignmentError"],
  1305. //>>excludeEnd("ide");
  1306. messageSends: ["ifTrue:", "or:", "isArgVar", "isPseudoVar", "variableName:", "new", "name", "signal"]
  1307. }),
  1308. $globals.ScopeVar);
  1309. $core.addMethod(
  1310. $core.method({
  1311. selector: "on:",
  1312. protocol: "instance creation",
  1313. fn: function (aString){
  1314. var self=this,$self=this;
  1315. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1316. return $core.withContext(function($ctx1) {
  1317. //>>excludeEnd("ctx");
  1318. var $1;
  1319. $1=$self._new();
  1320. $recv($1)._name_(aString);
  1321. return $recv($1)._yourself();
  1322. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1323. }, function($ctx1) {$ctx1.fill(self,"on:",{aString:aString},$globals.ScopeVar.a$cls)});
  1324. //>>excludeEnd("ctx");
  1325. },
  1326. //>>excludeStart("ide", pragmas.excludeIdeData);
  1327. args: ["aString"],
  1328. source: "on: aString\x0a\x09^ self new\x0a\x09\x09name: aString;\x0a\x09\x09yourself",
  1329. referencedClasses: [],
  1330. //>>excludeEnd("ide");
  1331. messageSends: ["name:", "new", "yourself"]
  1332. }),
  1333. $globals.ScopeVar.a$cls);
  1334. $core.addClass("AliasVar", $globals.ScopeVar, ["node"], "Compiler-Semantic");
  1335. //>>excludeStart("ide", pragmas.excludeIdeData);
  1336. $globals.AliasVar.comment="I am an internally defined variable by the compiler";
  1337. //>>excludeEnd("ide");
  1338. $core.addMethod(
  1339. $core.method({
  1340. selector: "isImmutable",
  1341. protocol: "testing",
  1342. fn: function (){
  1343. var self=this,$self=this;
  1344. return true;
  1345. },
  1346. //>>excludeStart("ide", pragmas.excludeIdeData);
  1347. args: [],
  1348. source: "isImmutable\x0a\x09^ true",
  1349. referencedClasses: [],
  1350. //>>excludeEnd("ide");
  1351. messageSends: []
  1352. }),
  1353. $globals.AliasVar);
  1354. $core.addMethod(
  1355. $core.method({
  1356. selector: "node",
  1357. protocol: "accessing",
  1358. fn: function (){
  1359. var self=this,$self=this;
  1360. return $self["@node"];
  1361. },
  1362. //>>excludeStart("ide", pragmas.excludeIdeData);
  1363. args: [],
  1364. source: "node\x0a\x09^ node",
  1365. referencedClasses: [],
  1366. //>>excludeEnd("ide");
  1367. messageSends: []
  1368. }),
  1369. $globals.AliasVar);
  1370. $core.addMethod(
  1371. $core.method({
  1372. selector: "node:",
  1373. protocol: "accessing",
  1374. fn: function (aNode){
  1375. var self=this,$self=this;
  1376. $self["@node"]=aNode;
  1377. return self;
  1378. },
  1379. //>>excludeStart("ide", pragmas.excludeIdeData);
  1380. args: ["aNode"],
  1381. source: "node: aNode\x0a\x09node := aNode",
  1382. referencedClasses: [],
  1383. //>>excludeEnd("ide");
  1384. messageSends: []
  1385. }),
  1386. $globals.AliasVar);
  1387. $core.addClass("ArgVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1388. //>>excludeStart("ide", pragmas.excludeIdeData);
  1389. $globals.ArgVar.comment="I am an argument of a method or block.";
  1390. //>>excludeEnd("ide");
  1391. $core.addMethod(
  1392. $core.method({
  1393. selector: "isArgVar",
  1394. protocol: "testing",
  1395. fn: function (){
  1396. var self=this,$self=this;
  1397. return true;
  1398. },
  1399. //>>excludeStart("ide", pragmas.excludeIdeData);
  1400. args: [],
  1401. source: "isArgVar\x0a\x09^ true",
  1402. referencedClasses: [],
  1403. //>>excludeEnd("ide");
  1404. messageSends: []
  1405. }),
  1406. $globals.ArgVar);
  1407. $core.addMethod(
  1408. $core.method({
  1409. selector: "isImmutable",
  1410. protocol: "testing",
  1411. fn: function (){
  1412. var self=this,$self=this;
  1413. return true;
  1414. },
  1415. //>>excludeStart("ide", pragmas.excludeIdeData);
  1416. args: [],
  1417. source: "isImmutable\x0a\x09^ true",
  1418. referencedClasses: [],
  1419. //>>excludeEnd("ide");
  1420. messageSends: []
  1421. }),
  1422. $globals.ArgVar);
  1423. $core.addClass("ClassRefVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1424. //>>excludeStart("ide", pragmas.excludeIdeData);
  1425. $globals.ClassRefVar.comment="I am an class reference variable";
  1426. //>>excludeEnd("ide");
  1427. $core.addMethod(
  1428. $core.method({
  1429. selector: "alias",
  1430. protocol: "accessing",
  1431. fn: function (){
  1432. var self=this,$self=this;
  1433. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1434. return $core.withContext(function($ctx1) {
  1435. //>>excludeEnd("ctx");
  1436. return "$globals.".__comma($self._name());
  1437. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1438. }, function($ctx1) {$ctx1.fill(self,"alias",{},$globals.ClassRefVar)});
  1439. //>>excludeEnd("ctx");
  1440. },
  1441. //>>excludeStart("ide", pragmas.excludeIdeData);
  1442. args: [],
  1443. 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^ '$globals.', self name",
  1444. referencedClasses: [],
  1445. //>>excludeEnd("ide");
  1446. messageSends: [",", "name"]
  1447. }),
  1448. $globals.ClassRefVar);
  1449. $core.addMethod(
  1450. $core.method({
  1451. selector: "isClassRefVar",
  1452. protocol: "testing",
  1453. fn: function (){
  1454. var self=this,$self=this;
  1455. return true;
  1456. },
  1457. //>>excludeStart("ide", pragmas.excludeIdeData);
  1458. args: [],
  1459. source: "isClassRefVar\x0a\x09^ true",
  1460. referencedClasses: [],
  1461. //>>excludeEnd("ide");
  1462. messageSends: []
  1463. }),
  1464. $globals.ClassRefVar);
  1465. $core.addMethod(
  1466. $core.method({
  1467. selector: "isImmutable",
  1468. protocol: "testing",
  1469. fn: function (){
  1470. var self=this,$self=this;
  1471. return true;
  1472. },
  1473. //>>excludeStart("ide", pragmas.excludeIdeData);
  1474. args: [],
  1475. source: "isImmutable\x0a\x09^ true",
  1476. referencedClasses: [],
  1477. //>>excludeEnd("ide");
  1478. messageSends: []
  1479. }),
  1480. $globals.ClassRefVar);
  1481. $core.addClass("InstanceVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1482. //>>excludeStart("ide", pragmas.excludeIdeData);
  1483. $globals.InstanceVar.comment="I am an instance variable of a method or block.";
  1484. //>>excludeEnd("ide");
  1485. $core.addMethod(
  1486. $core.method({
  1487. selector: "alias",
  1488. protocol: "testing",
  1489. fn: function (){
  1490. var self=this,$self=this;
  1491. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1492. return $core.withContext(function($ctx1) {
  1493. //>>excludeEnd("ctx");
  1494. var $1;
  1495. $1=$recv("$self[\x22@".__comma($self._name())).__comma("\x22]");
  1496. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1497. $ctx1.sendIdx[","]=1;
  1498. //>>excludeEnd("ctx");
  1499. return $1;
  1500. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1501. }, function($ctx1) {$ctx1.fill(self,"alias",{},$globals.InstanceVar)});
  1502. //>>excludeEnd("ctx");
  1503. },
  1504. //>>excludeStart("ide", pragmas.excludeIdeData);
  1505. args: [],
  1506. source: "alias\x0a\x09^ '$self[\x22@', self name, '\x22]'",
  1507. referencedClasses: [],
  1508. //>>excludeEnd("ide");
  1509. messageSends: [",", "name"]
  1510. }),
  1511. $globals.InstanceVar);
  1512. $core.addMethod(
  1513. $core.method({
  1514. selector: "isInstanceVar",
  1515. protocol: "testing",
  1516. fn: function (){
  1517. var self=this,$self=this;
  1518. return true;
  1519. },
  1520. //>>excludeStart("ide", pragmas.excludeIdeData);
  1521. args: [],
  1522. source: "isInstanceVar\x0a\x09^ true",
  1523. referencedClasses: [],
  1524. //>>excludeEnd("ide");
  1525. messageSends: []
  1526. }),
  1527. $globals.InstanceVar);
  1528. $core.addClass("PseudoVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1529. //>>excludeStart("ide", pragmas.excludeIdeData);
  1530. $globals.PseudoVar.comment="I am an pseudo variable.\x0a\x0aThe five Smalltalk pseudo variables are: 'self', 'super', 'nil', 'true' and 'false'";
  1531. //>>excludeEnd("ide");
  1532. $core.addMethod(
  1533. $core.method({
  1534. selector: "alias",
  1535. protocol: "accessing",
  1536. fn: function (){
  1537. var self=this,$self=this;
  1538. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1539. return $core.withContext(function($ctx1) {
  1540. //>>excludeEnd("ctx");
  1541. return $self._name();
  1542. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1543. }, function($ctx1) {$ctx1.fill(self,"alias",{},$globals.PseudoVar)});
  1544. //>>excludeEnd("ctx");
  1545. },
  1546. //>>excludeStart("ide", pragmas.excludeIdeData);
  1547. args: [],
  1548. source: "alias\x0a\x09^ self name",
  1549. referencedClasses: [],
  1550. //>>excludeEnd("ide");
  1551. messageSends: ["name"]
  1552. }),
  1553. $globals.PseudoVar);
  1554. $core.addMethod(
  1555. $core.method({
  1556. selector: "isImmutable",
  1557. protocol: "testing",
  1558. fn: function (){
  1559. var self=this,$self=this;
  1560. return true;
  1561. },
  1562. //>>excludeStart("ide", pragmas.excludeIdeData);
  1563. args: [],
  1564. source: "isImmutable\x0a\x09^ true",
  1565. referencedClasses: [],
  1566. //>>excludeEnd("ide");
  1567. messageSends: []
  1568. }),
  1569. $globals.PseudoVar);
  1570. $core.addMethod(
  1571. $core.method({
  1572. selector: "isPseudoVar",
  1573. protocol: "testing",
  1574. fn: function (){
  1575. var self=this,$self=this;
  1576. return true;
  1577. },
  1578. //>>excludeStart("ide", pragmas.excludeIdeData);
  1579. args: [],
  1580. source: "isPseudoVar\x0a\x09^ true",
  1581. referencedClasses: [],
  1582. //>>excludeEnd("ide");
  1583. messageSends: []
  1584. }),
  1585. $globals.PseudoVar);
  1586. $core.addMethod(
  1587. $core.method({
  1588. selector: "isSelf",
  1589. protocol: "testing",
  1590. fn: function (){
  1591. var self=this,$self=this;
  1592. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1593. return $core.withContext(function($ctx1) {
  1594. //>>excludeEnd("ctx");
  1595. return $recv($self["@name"]).__eq("self");
  1596. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1597. }, function($ctx1) {$ctx1.fill(self,"isSelf",{},$globals.PseudoVar)});
  1598. //>>excludeEnd("ctx");
  1599. },
  1600. //>>excludeStart("ide", pragmas.excludeIdeData);
  1601. args: [],
  1602. source: "isSelf\x0a\x09^ name = 'self'",
  1603. referencedClasses: [],
  1604. //>>excludeEnd("ide");
  1605. messageSends: ["="]
  1606. }),
  1607. $globals.PseudoVar);
  1608. $core.addMethod(
  1609. $core.method({
  1610. selector: "isSuper",
  1611. protocol: "testing",
  1612. fn: function (){
  1613. var self=this,$self=this;
  1614. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1615. return $core.withContext(function($ctx1) {
  1616. //>>excludeEnd("ctx");
  1617. return $recv($self["@name"]).__eq("super");
  1618. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1619. }, function($ctx1) {$ctx1.fill(self,"isSuper",{},$globals.PseudoVar)});
  1620. //>>excludeEnd("ctx");
  1621. },
  1622. //>>excludeStart("ide", pragmas.excludeIdeData);
  1623. args: [],
  1624. source: "isSuper\x0a\x09^ name = 'super'",
  1625. referencedClasses: [],
  1626. //>>excludeEnd("ide");
  1627. messageSends: ["="]
  1628. }),
  1629. $globals.PseudoVar);
  1630. $core.addClass("TempVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1631. //>>excludeStart("ide", pragmas.excludeIdeData);
  1632. $globals.TempVar.comment="I am an temporary variable of a method or block.";
  1633. //>>excludeEnd("ide");
  1634. $core.addMethod(
  1635. $core.method({
  1636. selector: "isTempVar",
  1637. protocol: "testing",
  1638. fn: function (){
  1639. var self=this,$self=this;
  1640. return true;
  1641. },
  1642. //>>excludeStart("ide", pragmas.excludeIdeData);
  1643. args: [],
  1644. source: "isTempVar\x0a\x09^ true",
  1645. referencedClasses: [],
  1646. //>>excludeEnd("ide");
  1647. messageSends: []
  1648. }),
  1649. $globals.TempVar);
  1650. $core.addClass("UnknownVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1651. //>>excludeStart("ide", pragmas.excludeIdeData);
  1652. $globals.UnknownVar.comment="I am an unknown variable. Amber uses unknown variables as JavaScript globals";
  1653. //>>excludeEnd("ide");
  1654. $core.addMethod(
  1655. $core.method({
  1656. selector: "isUnknownVar",
  1657. protocol: "testing",
  1658. fn: function (){
  1659. var self=this,$self=this;
  1660. return true;
  1661. },
  1662. //>>excludeStart("ide", pragmas.excludeIdeData);
  1663. args: [],
  1664. source: "isUnknownVar\x0a\x09^ true",
  1665. referencedClasses: [],
  1666. //>>excludeEnd("ide");
  1667. messageSends: []
  1668. }),
  1669. $globals.UnknownVar);
  1670. $core.addClass("SemanticAnalyzer", $globals.NodeVisitor, ["currentScope", "blockIndex", "thePackage", "theClass", "classReferences", "messageSends"], "Compiler-Semantic");
  1671. //>>excludeStart("ide", pragmas.excludeIdeData);
  1672. $globals.SemanticAnalyzer.comment="I semantically analyze the abstract syntax tree and annotate it with informations such as non local returns and variable scopes.";
  1673. //>>excludeEnd("ide");
  1674. $core.addMethod(
  1675. $core.method({
  1676. selector: "classReferences",
  1677. protocol: "accessing",
  1678. fn: function (){
  1679. var self=this,$self=this;
  1680. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1681. return $core.withContext(function($ctx1) {
  1682. //>>excludeEnd("ctx");
  1683. var $1,$receiver;
  1684. $1=$self["@classReferences"];
  1685. if(($receiver = $1) == null || $receiver.a$nil){
  1686. $self["@classReferences"]=$recv($globals.Set)._new();
  1687. return $self["@classReferences"];
  1688. } else {
  1689. return $1;
  1690. }
  1691. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1692. }, function($ctx1) {$ctx1.fill(self,"classReferences",{},$globals.SemanticAnalyzer)});
  1693. //>>excludeEnd("ctx");
  1694. },
  1695. //>>excludeStart("ide", pragmas.excludeIdeData);
  1696. args: [],
  1697. source: "classReferences\x0a\x09^ classReferences ifNil: [ classReferences := Set new ]",
  1698. referencedClasses: ["Set"],
  1699. //>>excludeEnd("ide");
  1700. messageSends: ["ifNil:", "new"]
  1701. }),
  1702. $globals.SemanticAnalyzer);
  1703. $core.addMethod(
  1704. $core.method({
  1705. selector: "errorShadowingVariable:",
  1706. protocol: "error handling",
  1707. fn: function (aString){
  1708. var self=this,$self=this;
  1709. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1710. return $core.withContext(function($ctx1) {
  1711. //>>excludeEnd("ctx");
  1712. var $1;
  1713. $1=$recv($globals.ShadowingVariableError)._new();
  1714. $recv($1)._variableName_(aString);
  1715. $recv($1)._signal();
  1716. return self;
  1717. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1718. }, function($ctx1) {$ctx1.fill(self,"errorShadowingVariable:",{aString:aString},$globals.SemanticAnalyzer)});
  1719. //>>excludeEnd("ctx");
  1720. },
  1721. //>>excludeStart("ide", pragmas.excludeIdeData);
  1722. args: ["aString"],
  1723. source: "errorShadowingVariable: aString\x0a\x09ShadowingVariableError new\x0a\x09\x09variableName: aString;\x0a\x09\x09signal",
  1724. referencedClasses: ["ShadowingVariableError"],
  1725. //>>excludeEnd("ide");
  1726. messageSends: ["variableName:", "new", "signal"]
  1727. }),
  1728. $globals.SemanticAnalyzer);
  1729. $core.addMethod(
  1730. $core.method({
  1731. selector: "errorUnknownVariable:",
  1732. protocol: "error handling",
  1733. fn: function (aNode){
  1734. var self=this,$self=this;
  1735. var identifier;
  1736. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1737. return $core.withContext(function($ctx1) {
  1738. //>>excludeEnd("ctx");
  1739. var $1,$2,$3;
  1740. identifier=$recv(aNode)._value();
  1741. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1742. $ctx1.sendIdx["value"]=1;
  1743. //>>excludeEnd("ctx");
  1744. $1=$recv($recv($recv($recv($globals.Smalltalk)._globalJsVariables())._includes_(identifier))._not())._and_((function(){
  1745. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1746. return $core.withContext(function($ctx2) {
  1747. //>>excludeEnd("ctx");
  1748. return $self._isVariableUndefined_inPackage_(identifier,$self._thePackage());
  1749. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1750. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1751. //>>excludeEnd("ctx");
  1752. }));
  1753. if($core.assert($1)){
  1754. $2=$recv($globals.UnknownVariableError)._new();
  1755. $3=$recv(aNode)._value();
  1756. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1757. $ctx1.sendIdx["value"]=2;
  1758. //>>excludeEnd("ctx");
  1759. $recv($2)._variableName_($3);
  1760. $recv($2)._signal();
  1761. } else {
  1762. $recv($recv($recv($self["@currentScope"])._methodScope())._unknownVariables())._add_($recv(aNode)._value());
  1763. }
  1764. return self;
  1765. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1766. }, function($ctx1) {$ctx1.fill(self,"errorUnknownVariable:",{aNode:aNode,identifier:identifier},$globals.SemanticAnalyzer)});
  1767. //>>excludeEnd("ctx");
  1768. },
  1769. //>>excludeStart("ide", pragmas.excludeIdeData);
  1770. args: ["aNode"],
  1771. source: "errorUnknownVariable: aNode\x0a\x09\x22Throw an error if the variable is undeclared in the global JS scope (i.e. window).\x0a\x09We allow all variables listed by Smalltalk>>#globalJsVariables.\x0a\x09This list includes: `window`, `document`, `process` and `global`\x0a\x09for nodejs and browser environments.\x0a\x09\x0a\x09This is only to make sure compilation works on both browser-based and nodejs environments.\x0a\x09The ideal solution would be to use a pragma instead\x22\x0a\x0a\x09| identifier |\x0a\x09identifier := aNode value.\x0a\x09\x0a\x09((Smalltalk globalJsVariables includes: identifier) not\x0a\x09\x09and: [ self isVariableUndefined: identifier inPackage: self thePackage ])\x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09UnknownVariableError new\x0a\x09\x09\x09\x09\x09variableName: aNode value;\x0a\x09\x09\x09\x09\x09signal ]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09currentScope methodScope unknownVariables add: aNode value ]",
  1772. referencedClasses: ["Smalltalk", "UnknownVariableError"],
  1773. //>>excludeEnd("ide");
  1774. messageSends: ["value", "ifTrue:ifFalse:", "and:", "not", "includes:", "globalJsVariables", "isVariableUndefined:inPackage:", "thePackage", "variableName:", "new", "signal", "add:", "unknownVariables", "methodScope"]
  1775. }),
  1776. $globals.SemanticAnalyzer);
  1777. $core.addMethod(
  1778. $core.method({
  1779. selector: "isVariableUndefined:inPackage:",
  1780. protocol: "testing",
  1781. fn: function (aString,aPackage){
  1782. var self=this,$self=this;
  1783. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1784. return $core.withContext(function($ctx1) {
  1785. //>>excludeEnd("ctx");
  1786. var $1,$2,$3,$receiver;
  1787. if(($receiver = aPackage) == null || $receiver.a$nil){
  1788. aPackage;
  1789. } else {
  1790. var packageKnownVars;
  1791. packageKnownVars=$recv($recv($recv(aPackage)._imports())._reject_("isString"))._collect_("key");
  1792. packageKnownVars;
  1793. $1=$recv(packageKnownVars)._includes_(aString);
  1794. if($core.assert($1)){
  1795. return false;
  1796. }
  1797. }
  1798. $2=$recv($globals.Compiler)._new();
  1799. $3=$recv("typeof ".__comma(aString)).__comma(" == \x22undefined\x22");
  1800. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1801. $ctx1.sendIdx[","]=1;
  1802. //>>excludeEnd("ctx");
  1803. return $recv($2)._eval_($3);
  1804. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1805. }, function($ctx1) {$ctx1.fill(self,"isVariableUndefined:inPackage:",{aString:aString,aPackage:aPackage},$globals.SemanticAnalyzer)});
  1806. //>>excludeEnd("ctx");
  1807. },
  1808. //>>excludeStart("ide", pragmas.excludeIdeData);
  1809. args: ["aString", "aPackage"],
  1810. source: "isVariableUndefined: aString inPackage: aPackage\x0a\x09aPackage ifNotNil: [\x0a\x09\x09| packageKnownVars |\x0a\x09\x09packageKnownVars := (aPackage imports\x0a\x09\x09\x09reject: #isString)\x0a\x09\x09\x09collect: #key.\x0a\x09\x09(packageKnownVars includes: aString) ifTrue: [ ^ false ]].\x0a\x09^ Compiler new\x0a\x09\x09eval: 'typeof ', aString, ' == \x22undefined\x22'",
  1811. referencedClasses: ["Compiler"],
  1812. //>>excludeEnd("ide");
  1813. messageSends: ["ifNotNil:", "collect:", "reject:", "imports", "ifTrue:", "includes:", "eval:", "new", ","]
  1814. }),
  1815. $globals.SemanticAnalyzer);
  1816. $core.addMethod(
  1817. $core.method({
  1818. selector: "messageSends",
  1819. protocol: "accessing",
  1820. fn: function (){
  1821. var self=this,$self=this;
  1822. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1823. return $core.withContext(function($ctx1) {
  1824. //>>excludeEnd("ctx");
  1825. var $1,$receiver;
  1826. $1=$self["@messageSends"];
  1827. if(($receiver = $1) == null || $receiver.a$nil){
  1828. $self["@messageSends"]=$recv($globals.Dictionary)._new();
  1829. return $self["@messageSends"];
  1830. } else {
  1831. return $1;
  1832. }
  1833. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1834. }, function($ctx1) {$ctx1.fill(self,"messageSends",{},$globals.SemanticAnalyzer)});
  1835. //>>excludeEnd("ctx");
  1836. },
  1837. //>>excludeStart("ide", pragmas.excludeIdeData);
  1838. args: [],
  1839. source: "messageSends\x0a\x09^ messageSends ifNil: [ messageSends := Dictionary new ]",
  1840. referencedClasses: ["Dictionary"],
  1841. //>>excludeEnd("ide");
  1842. messageSends: ["ifNil:", "new"]
  1843. }),
  1844. $globals.SemanticAnalyzer);
  1845. $core.addMethod(
  1846. $core.method({
  1847. selector: "newBlockScope",
  1848. protocol: "factory",
  1849. fn: function (){
  1850. var self=this,$self=this;
  1851. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1852. return $core.withContext(function($ctx1) {
  1853. //>>excludeEnd("ctx");
  1854. return $self._newScopeOfClass_($globals.LexicalScope);
  1855. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1856. }, function($ctx1) {$ctx1.fill(self,"newBlockScope",{},$globals.SemanticAnalyzer)});
  1857. //>>excludeEnd("ctx");
  1858. },
  1859. //>>excludeStart("ide", pragmas.excludeIdeData);
  1860. args: [],
  1861. source: "newBlockScope\x0a\x09^ self newScopeOfClass: LexicalScope",
  1862. referencedClasses: ["LexicalScope"],
  1863. //>>excludeEnd("ide");
  1864. messageSends: ["newScopeOfClass:"]
  1865. }),
  1866. $globals.SemanticAnalyzer);
  1867. $core.addMethod(
  1868. $core.method({
  1869. selector: "newMethodScope",
  1870. protocol: "factory",
  1871. fn: function (){
  1872. var self=this,$self=this;
  1873. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1874. return $core.withContext(function($ctx1) {
  1875. //>>excludeEnd("ctx");
  1876. return $self._newScopeOfClass_($globals.MethodLexicalScope);
  1877. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1878. }, function($ctx1) {$ctx1.fill(self,"newMethodScope",{},$globals.SemanticAnalyzer)});
  1879. //>>excludeEnd("ctx");
  1880. },
  1881. //>>excludeStart("ide", pragmas.excludeIdeData);
  1882. args: [],
  1883. source: "newMethodScope\x0a\x09^ self newScopeOfClass: MethodLexicalScope",
  1884. referencedClasses: ["MethodLexicalScope"],
  1885. //>>excludeEnd("ide");
  1886. messageSends: ["newScopeOfClass:"]
  1887. }),
  1888. $globals.SemanticAnalyzer);
  1889. $core.addMethod(
  1890. $core.method({
  1891. selector: "newScopeOfClass:",
  1892. protocol: "factory",
  1893. fn: function (aLexicalScopeClass){
  1894. var self=this,$self=this;
  1895. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1896. return $core.withContext(function($ctx1) {
  1897. //>>excludeEnd("ctx");
  1898. var $1;
  1899. $1=$recv(aLexicalScopeClass)._new();
  1900. $recv($1)._outerScope_($self["@currentScope"]);
  1901. return $recv($1)._yourself();
  1902. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1903. }, function($ctx1) {$ctx1.fill(self,"newScopeOfClass:",{aLexicalScopeClass:aLexicalScopeClass},$globals.SemanticAnalyzer)});
  1904. //>>excludeEnd("ctx");
  1905. },
  1906. //>>excludeStart("ide", pragmas.excludeIdeData);
  1907. args: ["aLexicalScopeClass"],
  1908. source: "newScopeOfClass: aLexicalScopeClass\x0a\x09^ aLexicalScopeClass new\x0a\x09\x09outerScope: currentScope;\x0a\x09\x09yourself",
  1909. referencedClasses: [],
  1910. //>>excludeEnd("ide");
  1911. messageSends: ["outerScope:", "new", "yourself"]
  1912. }),
  1913. $globals.SemanticAnalyzer);
  1914. $core.addMethod(
  1915. $core.method({
  1916. selector: "nextBlockIndex",
  1917. protocol: "private",
  1918. fn: function (){
  1919. var self=this,$self=this;
  1920. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1921. return $core.withContext(function($ctx1) {
  1922. //>>excludeEnd("ctx");
  1923. var $1,$receiver;
  1924. $1=$self["@blockIndex"];
  1925. if(($receiver = $1) == null || $receiver.a$nil){
  1926. $self["@blockIndex"]=(0);
  1927. $self["@blockIndex"];
  1928. } else {
  1929. $1;
  1930. }
  1931. $self["@blockIndex"]=$recv($self["@blockIndex"]).__plus((1));
  1932. return $self["@blockIndex"];
  1933. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1934. }, function($ctx1) {$ctx1.fill(self,"nextBlockIndex",{},$globals.SemanticAnalyzer)});
  1935. //>>excludeEnd("ctx");
  1936. },
  1937. //>>excludeStart("ide", pragmas.excludeIdeData);
  1938. args: [],
  1939. source: "nextBlockIndex\x0a\x09blockIndex ifNil: [ blockIndex := 0 ].\x0a\x09\x0a\x09blockIndex := blockIndex + 1.\x0a\x09^ blockIndex",
  1940. referencedClasses: [],
  1941. //>>excludeEnd("ide");
  1942. messageSends: ["ifNil:", "+"]
  1943. }),
  1944. $globals.SemanticAnalyzer);
  1945. $core.addMethod(
  1946. $core.method({
  1947. selector: "popScope",
  1948. protocol: "scope",
  1949. fn: function (){
  1950. var self=this,$self=this;
  1951. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1952. return $core.withContext(function($ctx1) {
  1953. //>>excludeEnd("ctx");
  1954. var $1,$receiver;
  1955. $1=$self["@currentScope"];
  1956. if(($receiver = $1) == null || $receiver.a$nil){
  1957. $1;
  1958. } else {
  1959. $self["@currentScope"]=$recv($self["@currentScope"])._outerScope();
  1960. $self["@currentScope"];
  1961. }
  1962. return self;
  1963. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1964. }, function($ctx1) {$ctx1.fill(self,"popScope",{},$globals.SemanticAnalyzer)});
  1965. //>>excludeEnd("ctx");
  1966. },
  1967. //>>excludeStart("ide", pragmas.excludeIdeData);
  1968. args: [],
  1969. source: "popScope\x0a\x09currentScope ifNotNil: [\x0a\x09\x09currentScope := currentScope outerScope ]",
  1970. referencedClasses: [],
  1971. //>>excludeEnd("ide");
  1972. messageSends: ["ifNotNil:", "outerScope"]
  1973. }),
  1974. $globals.SemanticAnalyzer);
  1975. $core.addMethod(
  1976. $core.method({
  1977. selector: "pushScope:",
  1978. protocol: "scope",
  1979. fn: function (aScope){
  1980. var self=this,$self=this;
  1981. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1982. return $core.withContext(function($ctx1) {
  1983. //>>excludeEnd("ctx");
  1984. $recv(aScope)._outerScope_($self["@currentScope"]);
  1985. $self["@currentScope"]=aScope;
  1986. return self;
  1987. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1988. }, function($ctx1) {$ctx1.fill(self,"pushScope:",{aScope:aScope},$globals.SemanticAnalyzer)});
  1989. //>>excludeEnd("ctx");
  1990. },
  1991. //>>excludeStart("ide", pragmas.excludeIdeData);
  1992. args: ["aScope"],
  1993. source: "pushScope: aScope\x0a\x09aScope outerScope: currentScope.\x0a\x09currentScope := aScope",
  1994. referencedClasses: [],
  1995. //>>excludeEnd("ide");
  1996. messageSends: ["outerScope:"]
  1997. }),
  1998. $globals.SemanticAnalyzer);
  1999. $core.addMethod(
  2000. $core.method({
  2001. selector: "theClass",
  2002. protocol: "accessing",
  2003. fn: function (){
  2004. var self=this,$self=this;
  2005. return $self["@theClass"];
  2006. },
  2007. //>>excludeStart("ide", pragmas.excludeIdeData);
  2008. args: [],
  2009. source: "theClass\x0a\x09^ theClass",
  2010. referencedClasses: [],
  2011. //>>excludeEnd("ide");
  2012. messageSends: []
  2013. }),
  2014. $globals.SemanticAnalyzer);
  2015. $core.addMethod(
  2016. $core.method({
  2017. selector: "theClass:",
  2018. protocol: "accessing",
  2019. fn: function (aClass){
  2020. var self=this,$self=this;
  2021. $self["@theClass"]=aClass;
  2022. return self;
  2023. },
  2024. //>>excludeStart("ide", pragmas.excludeIdeData);
  2025. args: ["aClass"],
  2026. source: "theClass: aClass\x0a\x09theClass := aClass",
  2027. referencedClasses: [],
  2028. //>>excludeEnd("ide");
  2029. messageSends: []
  2030. }),
  2031. $globals.SemanticAnalyzer);
  2032. $core.addMethod(
  2033. $core.method({
  2034. selector: "thePackage",
  2035. protocol: "accessing",
  2036. fn: function (){
  2037. var self=this,$self=this;
  2038. return $self["@thePackage"];
  2039. },
  2040. //>>excludeStart("ide", pragmas.excludeIdeData);
  2041. args: [],
  2042. source: "thePackage\x0a\x09^ thePackage",
  2043. referencedClasses: [],
  2044. //>>excludeEnd("ide");
  2045. messageSends: []
  2046. }),
  2047. $globals.SemanticAnalyzer);
  2048. $core.addMethod(
  2049. $core.method({
  2050. selector: "thePackage:",
  2051. protocol: "accessing",
  2052. fn: function (aPackage){
  2053. var self=this,$self=this;
  2054. $self["@thePackage"]=aPackage;
  2055. return self;
  2056. },
  2057. //>>excludeStart("ide", pragmas.excludeIdeData);
  2058. args: ["aPackage"],
  2059. source: "thePackage: aPackage\x0a\x09thePackage := aPackage",
  2060. referencedClasses: [],
  2061. //>>excludeEnd("ide");
  2062. messageSends: []
  2063. }),
  2064. $globals.SemanticAnalyzer);
  2065. $core.addMethod(
  2066. $core.method({
  2067. selector: "validateVariableScope:",
  2068. protocol: "scope",
  2069. fn: function (aString){
  2070. var self=this,$self=this;
  2071. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2072. return $core.withContext(function($ctx1) {
  2073. //>>excludeEnd("ctx");
  2074. var $1,$receiver;
  2075. $1=$recv($self["@currentScope"])._lookupVariable_(aString);
  2076. if(($receiver = $1) == null || $receiver.a$nil){
  2077. $1;
  2078. } else {
  2079. $self._errorShadowingVariable_(aString);
  2080. }
  2081. return self;
  2082. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2083. }, function($ctx1) {$ctx1.fill(self,"validateVariableScope:",{aString:aString},$globals.SemanticAnalyzer)});
  2084. //>>excludeEnd("ctx");
  2085. },
  2086. //>>excludeStart("ide", pragmas.excludeIdeData);
  2087. args: ["aString"],
  2088. source: "validateVariableScope: aString\x0a\x09\x22Validate the variable scope in by doing a recursive lookup, up to the method scope\x22\x0a\x0a\x09(currentScope lookupVariable: aString) ifNotNil: [\x0a\x09\x09self errorShadowingVariable: aString ]",
  2089. referencedClasses: [],
  2090. //>>excludeEnd("ide");
  2091. messageSends: ["ifNotNil:", "lookupVariable:", "errorShadowingVariable:"]
  2092. }),
  2093. $globals.SemanticAnalyzer);
  2094. $core.addMethod(
  2095. $core.method({
  2096. selector: "visitAssignmentNode:",
  2097. protocol: "visiting",
  2098. fn: function (aNode){
  2099. var self=this,$self=this;
  2100. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2101. return $core.withContext(function($ctx1) {
  2102. //>>excludeEnd("ctx");
  2103. (
  2104. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2105. $ctx1.supercall = true,
  2106. //>>excludeEnd("ctx");
  2107. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitAssignmentNode_.apply($self, [aNode]));
  2108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2109. $ctx1.supercall = false;
  2110. //>>excludeEnd("ctx");;
  2111. $recv($recv(aNode)._left())._beAssigned();
  2112. return self;
  2113. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2114. }, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode},$globals.SemanticAnalyzer)});
  2115. //>>excludeEnd("ctx");
  2116. },
  2117. //>>excludeStart("ide", pragmas.excludeIdeData);
  2118. args: ["aNode"],
  2119. source: "visitAssignmentNode: aNode\x0a\x09super visitAssignmentNode: aNode.\x0a\x09aNode left beAssigned",
  2120. referencedClasses: [],
  2121. //>>excludeEnd("ide");
  2122. messageSends: ["visitAssignmentNode:", "beAssigned", "left"]
  2123. }),
  2124. $globals.SemanticAnalyzer);
  2125. $core.addMethod(
  2126. $core.method({
  2127. selector: "visitBlockNode:",
  2128. protocol: "visiting",
  2129. fn: function (aNode){
  2130. var self=this,$self=this;
  2131. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2132. return $core.withContext(function($ctx1) {
  2133. //>>excludeEnd("ctx");
  2134. $self._pushScope_($self._newBlockScope());
  2135. $recv(aNode)._scope_($self["@currentScope"]);
  2136. $recv($self["@currentScope"])._node_(aNode);
  2137. $recv($self["@currentScope"])._blockIndex_($self._nextBlockIndex());
  2138. $recv($recv(aNode)._parameters())._do_((function(each){
  2139. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2140. return $core.withContext(function($ctx2) {
  2141. //>>excludeEnd("ctx");
  2142. $self._validateVariableScope_(each);
  2143. return $recv($self["@currentScope"])._addArg_(each);
  2144. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2145. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2146. //>>excludeEnd("ctx");
  2147. }));
  2148. (
  2149. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2150. $ctx1.supercall = true,
  2151. //>>excludeEnd("ctx");
  2152. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitBlockNode_.apply($self, [aNode]));
  2153. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2154. $ctx1.supercall = false;
  2155. //>>excludeEnd("ctx");;
  2156. $self._popScope();
  2157. return self;
  2158. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2159. }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},$globals.SemanticAnalyzer)});
  2160. //>>excludeEnd("ctx");
  2161. },
  2162. //>>excludeStart("ide", pragmas.excludeIdeData);
  2163. args: ["aNode"],
  2164. source: "visitBlockNode: aNode\x0a\x09self pushScope: self newBlockScope.\x0a\x09aNode scope: currentScope.\x0a\x09currentScope node: aNode.\x0a\x09currentScope blockIndex: self nextBlockIndex.\x0a\x0a\x09aNode parameters do: [ :each |\x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addArg: each ].\x0a\x0a\x09super visitBlockNode: aNode.\x0a\x09self popScope",
  2165. referencedClasses: [],
  2166. //>>excludeEnd("ide");
  2167. messageSends: ["pushScope:", "newBlockScope", "scope:", "node:", "blockIndex:", "nextBlockIndex", "do:", "parameters", "validateVariableScope:", "addArg:", "visitBlockNode:", "popScope"]
  2168. }),
  2169. $globals.SemanticAnalyzer);
  2170. $core.addMethod(
  2171. $core.method({
  2172. selector: "visitCascadeNode:",
  2173. protocol: "visiting",
  2174. fn: function (aNode){
  2175. var self=this,$self=this;
  2176. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2177. return $core.withContext(function($ctx1) {
  2178. //>>excludeEnd("ctx");
  2179. $recv(aNode)._receiver_($recv($recv($recv(aNode)._dagChildren())._first())._receiver());
  2180. (
  2181. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2182. $ctx1.supercall = true,
  2183. //>>excludeEnd("ctx");
  2184. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitCascadeNode_.apply($self, [aNode]));
  2185. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2186. $ctx1.supercall = false;
  2187. //>>excludeEnd("ctx");;
  2188. return self;
  2189. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2190. }, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode},$globals.SemanticAnalyzer)});
  2191. //>>excludeEnd("ctx");
  2192. },
  2193. //>>excludeStart("ide", pragmas.excludeIdeData);
  2194. args: ["aNode"],
  2195. source: "visitCascadeNode: aNode\x0a\x09aNode receiver: aNode dagChildren first receiver.\x0a\x09super visitCascadeNode: aNode",
  2196. referencedClasses: [],
  2197. //>>excludeEnd("ide");
  2198. messageSends: ["receiver:", "receiver", "first", "dagChildren", "visitCascadeNode:"]
  2199. }),
  2200. $globals.SemanticAnalyzer);
  2201. $core.addMethod(
  2202. $core.method({
  2203. selector: "visitMethodNode:",
  2204. protocol: "visiting",
  2205. fn: function (aNode){
  2206. var self=this,$self=this;
  2207. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2208. return $core.withContext(function($ctx1) {
  2209. //>>excludeEnd("ctx");
  2210. $self._pushScope_($self._newMethodScope());
  2211. $recv(aNode)._scope_($self["@currentScope"]);
  2212. $recv($self["@currentScope"])._node_(aNode);
  2213. $recv($recv($self._theClass())._allInstanceVariableNames())._do_((function(each){
  2214. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2215. return $core.withContext(function($ctx2) {
  2216. //>>excludeEnd("ctx");
  2217. return $recv($self["@currentScope"])._addIVar_(each);
  2218. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2219. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2220. //>>excludeEnd("ctx");
  2221. }));
  2222. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2223. $ctx1.sendIdx["do:"]=1;
  2224. //>>excludeEnd("ctx");
  2225. $recv($recv(aNode)._arguments())._do_((function(each){
  2226. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2227. return $core.withContext(function($ctx2) {
  2228. //>>excludeEnd("ctx");
  2229. $self._validateVariableScope_(each);
  2230. return $recv($self["@currentScope"])._addArg_(each);
  2231. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2232. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  2233. //>>excludeEnd("ctx");
  2234. }));
  2235. (
  2236. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2237. $ctx1.supercall = true,
  2238. //>>excludeEnd("ctx");
  2239. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitMethodNode_.apply($self, [aNode]));
  2240. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2241. $ctx1.supercall = false;
  2242. //>>excludeEnd("ctx");;
  2243. $recv(aNode)._classReferences_($self._classReferences());
  2244. $recv(aNode)._sendIndexes_($self._messageSends());
  2245. $self._popScope();
  2246. return aNode;
  2247. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2248. }, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},$globals.SemanticAnalyzer)});
  2249. //>>excludeEnd("ctx");
  2250. },
  2251. //>>excludeStart("ide", pragmas.excludeIdeData);
  2252. args: ["aNode"],
  2253. source: "visitMethodNode: aNode\x0a\x09self pushScope: self newMethodScope.\x0a\x09aNode scope: currentScope.\x0a\x09currentScope node: aNode.\x0a\x0a\x09self theClass allInstanceVariableNames do: [ :each |\x0a\x09\x09currentScope addIVar: each ].\x0a\x09aNode arguments do: [ :each |\x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addArg: each ].\x0a\x0a\x09super visitMethodNode: aNode.\x0a\x0a\x09aNode\x0a\x09\x09classReferences: self classReferences;\x0a\x09\x09sendIndexes: self messageSends.\x0a\x09self popScope.\x0a\x09^ aNode",
  2254. referencedClasses: [],
  2255. //>>excludeEnd("ide");
  2256. messageSends: ["pushScope:", "newMethodScope", "scope:", "node:", "do:", "allInstanceVariableNames", "theClass", "addIVar:", "arguments", "validateVariableScope:", "addArg:", "visitMethodNode:", "classReferences:", "classReferences", "sendIndexes:", "messageSends", "popScope"]
  2257. }),
  2258. $globals.SemanticAnalyzer);
  2259. $core.addMethod(
  2260. $core.method({
  2261. selector: "visitReturnNode:",
  2262. protocol: "visiting",
  2263. fn: function (aNode){
  2264. var self=this,$self=this;
  2265. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2266. return $core.withContext(function($ctx1) {
  2267. //>>excludeEnd("ctx");
  2268. var $1;
  2269. $recv(aNode)._scope_($self["@currentScope"]);
  2270. $1=$recv($self["@currentScope"])._isMethodScope();
  2271. if($core.assert($1)){
  2272. $recv($self["@currentScope"])._localReturn_(true);
  2273. } else {
  2274. $recv($recv($self["@currentScope"])._methodScope())._addNonLocalReturn_($self["@currentScope"]);
  2275. }
  2276. (
  2277. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2278. $ctx1.supercall = true,
  2279. //>>excludeEnd("ctx");
  2280. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitReturnNode_.apply($self, [aNode]));
  2281. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2282. $ctx1.supercall = false;
  2283. //>>excludeEnd("ctx");;
  2284. return self;
  2285. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2286. }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},$globals.SemanticAnalyzer)});
  2287. //>>excludeEnd("ctx");
  2288. },
  2289. //>>excludeStart("ide", pragmas.excludeIdeData);
  2290. args: ["aNode"],
  2291. source: "visitReturnNode: aNode\x0a\x09aNode scope: currentScope.\x0a\x09currentScope isMethodScope\x0a\x09\x09ifTrue: [ currentScope localReturn: true ]\x0a\x09\x09ifFalse: [ currentScope methodScope addNonLocalReturn: currentScope ].\x0a\x09super visitReturnNode: aNode",
  2292. referencedClasses: [],
  2293. //>>excludeEnd("ide");
  2294. messageSends: ["scope:", "ifTrue:ifFalse:", "isMethodScope", "localReturn:", "addNonLocalReturn:", "methodScope", "visitReturnNode:"]
  2295. }),
  2296. $globals.SemanticAnalyzer);
  2297. $core.addMethod(
  2298. $core.method({
  2299. selector: "visitSendNode:",
  2300. protocol: "visiting",
  2301. fn: function (aNode){
  2302. var self=this,$self=this;
  2303. var sends;
  2304. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2305. return $core.withContext(function($ctx1) {
  2306. //>>excludeEnd("ctx");
  2307. sends=$recv($self._messageSends())._at_ifAbsentPut_($recv(aNode)._selector(),(function(){
  2308. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2309. return $core.withContext(function($ctx2) {
  2310. //>>excludeEnd("ctx");
  2311. return $recv($globals.OrderedCollection)._new();
  2312. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2313. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2314. //>>excludeEnd("ctx");
  2315. }));
  2316. $recv(sends)._add_(aNode);
  2317. $recv(aNode)._index_($recv(sends)._size());
  2318. (
  2319. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2320. $ctx1.supercall = true,
  2321. //>>excludeEnd("ctx");
  2322. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitSendNode_.apply($self, [aNode]));
  2323. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2324. $ctx1.supercall = false;
  2325. //>>excludeEnd("ctx");;
  2326. return self;
  2327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2328. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,sends:sends},$globals.SemanticAnalyzer)});
  2329. //>>excludeEnd("ctx");
  2330. },
  2331. //>>excludeStart("ide", pragmas.excludeIdeData);
  2332. args: ["aNode"],
  2333. source: "visitSendNode: aNode\x0a\x0a\x09| sends |\x0a\x09sends := self messageSends at: aNode selector ifAbsentPut: [ OrderedCollection new ].\x0a\x09sends add: aNode.\x0a\x0a\x09aNode index: sends size.\x0a\x0a\x09super visitSendNode: aNode",
  2334. referencedClasses: ["OrderedCollection"],
  2335. //>>excludeEnd("ide");
  2336. messageSends: ["at:ifAbsentPut:", "messageSends", "selector", "new", "add:", "index:", "size", "visitSendNode:"]
  2337. }),
  2338. $globals.SemanticAnalyzer);
  2339. $core.addMethod(
  2340. $core.method({
  2341. selector: "visitSequenceNode:",
  2342. protocol: "visiting",
  2343. fn: function (aNode){
  2344. var self=this,$self=this;
  2345. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2346. return $core.withContext(function($ctx1) {
  2347. //>>excludeEnd("ctx");
  2348. $recv($recv(aNode)._temps())._do_((function(each){
  2349. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2350. return $core.withContext(function($ctx2) {
  2351. //>>excludeEnd("ctx");
  2352. $self._validateVariableScope_(each);
  2353. return $recv($self["@currentScope"])._addTemp_(each);
  2354. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2355. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2356. //>>excludeEnd("ctx");
  2357. }));
  2358. (
  2359. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2360. $ctx1.supercall = true,
  2361. //>>excludeEnd("ctx");
  2362. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitSequenceNode_.apply($self, [aNode]));
  2363. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2364. $ctx1.supercall = false;
  2365. //>>excludeEnd("ctx");;
  2366. return self;
  2367. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2368. }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},$globals.SemanticAnalyzer)});
  2369. //>>excludeEnd("ctx");
  2370. },
  2371. //>>excludeStart("ide", pragmas.excludeIdeData);
  2372. args: ["aNode"],
  2373. source: "visitSequenceNode: aNode\x0a\x09aNode temps do: [ :each |\x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addTemp: each ].\x0a\x0a\x09super visitSequenceNode: aNode",
  2374. referencedClasses: [],
  2375. //>>excludeEnd("ide");
  2376. messageSends: ["do:", "temps", "validateVariableScope:", "addTemp:", "visitSequenceNode:"]
  2377. }),
  2378. $globals.SemanticAnalyzer);
  2379. $core.addMethod(
  2380. $core.method({
  2381. selector: "visitVariableNode:",
  2382. protocol: "visiting",
  2383. fn: function (aNode){
  2384. var self=this,$self=this;
  2385. var binding;
  2386. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2387. return $core.withContext(function($ctx1) {
  2388. //>>excludeEnd("ctx");
  2389. var $1,$3,$2,$4,$5,$6,$7,$8,$9,$receiver;
  2390. binding=$recv($self["@currentScope"])._lookupVariable_(aNode);
  2391. $1=binding;
  2392. if(($receiver = $1) == null || $receiver.a$nil){
  2393. $3=$recv(aNode)._value();
  2394. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2395. $ctx1.sendIdx["value"]=1;
  2396. //>>excludeEnd("ctx");
  2397. $2=$recv($3)._isCapitalized();
  2398. if($core.assert($2)){
  2399. $4=$recv($globals.ClassRefVar)._new();
  2400. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2401. $ctx1.sendIdx["new"]=1;
  2402. //>>excludeEnd("ctx");
  2403. $5=$recv(aNode)._value();
  2404. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2405. $ctx1.sendIdx["value"]=2;
  2406. //>>excludeEnd("ctx");
  2407. $recv($4)._name_($5);
  2408. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2409. $ctx1.sendIdx["name:"]=1;
  2410. //>>excludeEnd("ctx");
  2411. $6=$recv($4)._yourself();
  2412. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2413. $ctx1.sendIdx["yourself"]=1;
  2414. //>>excludeEnd("ctx");
  2415. binding=$6;
  2416. binding;
  2417. $7=$self._classReferences();
  2418. $8=$recv(aNode)._value();
  2419. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2420. $ctx1.sendIdx["value"]=3;
  2421. //>>excludeEnd("ctx");
  2422. $recv($7)._add_($8);
  2423. } else {
  2424. $self._errorUnknownVariable_(aNode);
  2425. $9=$recv($globals.UnknownVar)._new();
  2426. $recv($9)._name_($recv(aNode)._value());
  2427. binding=$recv($9)._yourself();
  2428. binding;
  2429. }
  2430. } else {
  2431. $1;
  2432. }
  2433. $recv(aNode)._binding_(binding);
  2434. return self;
  2435. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2436. }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode,binding:binding},$globals.SemanticAnalyzer)});
  2437. //>>excludeEnd("ctx");
  2438. },
  2439. //>>excludeStart("ide", pragmas.excludeIdeData);
  2440. args: ["aNode"],
  2441. source: "visitVariableNode: aNode\x0a\x09\x22Bind a ScopeVar to aNode by doing a lookup in the current scope.\x0a\x09If no ScopeVar is found, bind a UnknowVar and throw an error.\x22\x0a\x0a\x09| binding |\x0a\x09binding := currentScope lookupVariable: aNode.\x0a\x09\x0a\x09binding ifNil: [\x0a\x09\x09aNode value isCapitalized\x0a\x09\x09\x09ifTrue: [ \x22Capital letter variables might be globals.\x22\x0a\x09\x09\x09\x09binding := ClassRefVar new name: aNode value; yourself.\x0a\x09\x09\x09\x09self classReferences add: aNode value]\x0a\x09\x09\x09ifFalse: [\x0a\x09\x09\x09\x09self errorUnknownVariable: aNode.\x0a\x09\x09\x09\x09binding := UnknownVar new name: aNode value; yourself ] ].\x0a\x09\x09\x0a\x09aNode binding: binding.",
  2442. referencedClasses: ["ClassRefVar", "UnknownVar"],
  2443. //>>excludeEnd("ide");
  2444. messageSends: ["lookupVariable:", "ifNil:", "ifTrue:ifFalse:", "isCapitalized", "value", "name:", "new", "yourself", "add:", "classReferences", "errorUnknownVariable:", "binding:"]
  2445. }),
  2446. $globals.SemanticAnalyzer);
  2447. $core.addMethod(
  2448. $core.method({
  2449. selector: "on:",
  2450. protocol: "instance creation",
  2451. fn: function (aClass){
  2452. var self=this,$self=this;
  2453. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2454. return $core.withContext(function($ctx1) {
  2455. //>>excludeEnd("ctx");
  2456. var $1;
  2457. $1=$self._new();
  2458. $recv($1)._theClass_(aClass);
  2459. return $recv($1)._yourself();
  2460. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2461. }, function($ctx1) {$ctx1.fill(self,"on:",{aClass:aClass},$globals.SemanticAnalyzer.a$cls)});
  2462. //>>excludeEnd("ctx");
  2463. },
  2464. //>>excludeStart("ide", pragmas.excludeIdeData);
  2465. args: ["aClass"],
  2466. source: "on: aClass\x0a\x09^ self new\x0a\x09\x09theClass: aClass;\x0a\x09\x09yourself",
  2467. referencedClasses: [],
  2468. //>>excludeEnd("ide");
  2469. messageSends: ["theClass:", "new", "yourself"]
  2470. }),
  2471. $globals.SemanticAnalyzer.a$cls);
  2472. $core.addClass("SemanticError", $globals.CompilerError, [], "Compiler-Semantic");
  2473. //>>excludeStart("ide", pragmas.excludeIdeData);
  2474. $globals.SemanticError.comment="I represent an abstract semantic error thrown by the SemanticAnalyzer.\x0aSemantic errors can be unknown variable errors, etc.\x0aSee my subclasses for concrete errors.\x0a\x0aThe IDE should catch instances of Semantic error to deal with them when compiling";
  2475. //>>excludeEnd("ide");
  2476. $core.addClass("InvalidAssignmentError", $globals.SemanticError, ["variableName"], "Compiler-Semantic");
  2477. //>>excludeStart("ide", pragmas.excludeIdeData);
  2478. $globals.InvalidAssignmentError.comment="I get signaled when a pseudo variable gets assigned.";
  2479. //>>excludeEnd("ide");
  2480. $core.addMethod(
  2481. $core.method({
  2482. selector: "messageText",
  2483. protocol: "accessing",
  2484. fn: function (){
  2485. var self=this,$self=this;
  2486. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2487. return $core.withContext(function($ctx1) {
  2488. //>>excludeEnd("ctx");
  2489. return " Invalid assignment to variable: ".__comma($self._variableName());
  2490. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2491. }, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.InvalidAssignmentError)});
  2492. //>>excludeEnd("ctx");
  2493. },
  2494. //>>excludeStart("ide", pragmas.excludeIdeData);
  2495. args: [],
  2496. source: "messageText\x0a\x09^ ' Invalid assignment to variable: ', self variableName",
  2497. referencedClasses: [],
  2498. //>>excludeEnd("ide");
  2499. messageSends: [",", "variableName"]
  2500. }),
  2501. $globals.InvalidAssignmentError);
  2502. $core.addMethod(
  2503. $core.method({
  2504. selector: "variableName",
  2505. protocol: "accessing",
  2506. fn: function (){
  2507. var self=this,$self=this;
  2508. return $self["@variableName"];
  2509. },
  2510. //>>excludeStart("ide", pragmas.excludeIdeData);
  2511. args: [],
  2512. source: "variableName\x0a\x09^ variableName",
  2513. referencedClasses: [],
  2514. //>>excludeEnd("ide");
  2515. messageSends: []
  2516. }),
  2517. $globals.InvalidAssignmentError);
  2518. $core.addMethod(
  2519. $core.method({
  2520. selector: "variableName:",
  2521. protocol: "accessing",
  2522. fn: function (aString){
  2523. var self=this,$self=this;
  2524. $self["@variableName"]=aString;
  2525. return self;
  2526. },
  2527. //>>excludeStart("ide", pragmas.excludeIdeData);
  2528. args: ["aString"],
  2529. source: "variableName: aString\x0a\x09variableName := aString",
  2530. referencedClasses: [],
  2531. //>>excludeEnd("ide");
  2532. messageSends: []
  2533. }),
  2534. $globals.InvalidAssignmentError);
  2535. $core.addClass("ShadowingVariableError", $globals.SemanticError, ["variableName"], "Compiler-Semantic");
  2536. //>>excludeStart("ide", pragmas.excludeIdeData);
  2537. $globals.ShadowingVariableError.comment="I get signaled when a variable in a block or method scope shadows a variable of the same name in an outer scope.";
  2538. //>>excludeEnd("ide");
  2539. $core.addMethod(
  2540. $core.method({
  2541. selector: "messageText",
  2542. protocol: "accessing",
  2543. fn: function (){
  2544. var self=this,$self=this;
  2545. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2546. return $core.withContext(function($ctx1) {
  2547. //>>excludeEnd("ctx");
  2548. var $1;
  2549. $1=$recv("Variable shadowing error: ".__comma($self._variableName())).__comma(" is already defined");
  2550. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2551. $ctx1.sendIdx[","]=1;
  2552. //>>excludeEnd("ctx");
  2553. return $1;
  2554. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2555. }, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.ShadowingVariableError)});
  2556. //>>excludeEnd("ctx");
  2557. },
  2558. //>>excludeStart("ide", pragmas.excludeIdeData);
  2559. args: [],
  2560. source: "messageText\x0a\x09^ 'Variable shadowing error: ', self variableName, ' is already defined'",
  2561. referencedClasses: [],
  2562. //>>excludeEnd("ide");
  2563. messageSends: [",", "variableName"]
  2564. }),
  2565. $globals.ShadowingVariableError);
  2566. $core.addMethod(
  2567. $core.method({
  2568. selector: "variableName",
  2569. protocol: "accessing",
  2570. fn: function (){
  2571. var self=this,$self=this;
  2572. return $self["@variableName"];
  2573. },
  2574. //>>excludeStart("ide", pragmas.excludeIdeData);
  2575. args: [],
  2576. source: "variableName\x0a\x09^ variableName",
  2577. referencedClasses: [],
  2578. //>>excludeEnd("ide");
  2579. messageSends: []
  2580. }),
  2581. $globals.ShadowingVariableError);
  2582. $core.addMethod(
  2583. $core.method({
  2584. selector: "variableName:",
  2585. protocol: "accessing",
  2586. fn: function (aString){
  2587. var self=this,$self=this;
  2588. $self["@variableName"]=aString;
  2589. return self;
  2590. },
  2591. //>>excludeStart("ide", pragmas.excludeIdeData);
  2592. args: ["aString"],
  2593. source: "variableName: aString\x0a\x09variableName := aString",
  2594. referencedClasses: [],
  2595. //>>excludeEnd("ide");
  2596. messageSends: []
  2597. }),
  2598. $globals.ShadowingVariableError);
  2599. $core.addClass("UnknownVariableError", $globals.SemanticError, ["variableName"], "Compiler-Semantic");
  2600. //>>excludeStart("ide", pragmas.excludeIdeData);
  2601. $globals.UnknownVariableError.comment="I get signaled when a variable is not defined.\x0aThe default behavior is to allow it, as this is how Amber currently is able to seamlessly send messages to JavaScript objects.";
  2602. //>>excludeEnd("ide");
  2603. $core.addMethod(
  2604. $core.method({
  2605. selector: "messageText",
  2606. protocol: "accessing",
  2607. fn: function (){
  2608. var self=this,$self=this;
  2609. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2610. return $core.withContext(function($ctx1) {
  2611. //>>excludeEnd("ctx");
  2612. var $1;
  2613. $1=$recv("Unknown Variable error: ".__comma($self._variableName())).__comma(" is not defined");
  2614. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2615. $ctx1.sendIdx[","]=1;
  2616. //>>excludeEnd("ctx");
  2617. return $1;
  2618. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2619. }, function($ctx1) {$ctx1.fill(self,"messageText",{},$globals.UnknownVariableError)});
  2620. //>>excludeEnd("ctx");
  2621. },
  2622. //>>excludeStart("ide", pragmas.excludeIdeData);
  2623. args: [],
  2624. source: "messageText\x0a\x09^ 'Unknown Variable error: ', self variableName, ' is not defined'",
  2625. referencedClasses: [],
  2626. //>>excludeEnd("ide");
  2627. messageSends: [",", "variableName"]
  2628. }),
  2629. $globals.UnknownVariableError);
  2630. $core.addMethod(
  2631. $core.method({
  2632. selector: "variableName",
  2633. protocol: "accessing",
  2634. fn: function (){
  2635. var self=this,$self=this;
  2636. return $self["@variableName"];
  2637. },
  2638. //>>excludeStart("ide", pragmas.excludeIdeData);
  2639. args: [],
  2640. source: "variableName\x0a\x09^ variableName",
  2641. referencedClasses: [],
  2642. //>>excludeEnd("ide");
  2643. messageSends: []
  2644. }),
  2645. $globals.UnknownVariableError);
  2646. $core.addMethod(
  2647. $core.method({
  2648. selector: "variableName:",
  2649. protocol: "accessing",
  2650. fn: function (aString){
  2651. var self=this,$self=this;
  2652. $self["@variableName"]=aString;
  2653. return self;
  2654. },
  2655. //>>excludeStart("ide", pragmas.excludeIdeData);
  2656. args: ["aString"],
  2657. source: "variableName: aString\x0a\x09variableName := aString",
  2658. referencedClasses: [],
  2659. //>>excludeEnd("ide");
  2660. messageSends: []
  2661. }),
  2662. $globals.UnknownVariableError);
  2663. });