Compiler-Semantic.js 87 KB

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