2
0

Compiler-Semantic.js 84 KB

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