Compiler-Semantic.js 85 KB

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