Compiler-Semantic.js 85 KB

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