Compiler-Semantic.js 90 KB

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