Compiler-Semantic.js 87 KB

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