Compiler-Semantic.js 84 KB

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