Compiler-Semantic.js 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942
  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,$3,$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. $recv($4)._scope_($self._methodScope());
  993. $3=$recv($4)._yourself();
  994. return $recv($2)._at_put_(each,$3);
  995. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  996. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  997. //>>excludeEnd("ctx");
  998. }));
  999. } else {
  1000. $1;
  1001. }
  1002. return $self.pseudoVars;
  1003. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1004. }, function($ctx1) {$ctx1.fill(self,"pseudoVars",{})});
  1005. //>>excludeEnd("ctx");
  1006. },
  1007. //>>excludeStart("ide", pragmas.excludeIdeData);
  1008. args: [],
  1009. source: "pseudoVars\x0a\x09pseudoVars ifNil: [\x0a\x09\x09pseudoVars := Dictionary new.\x0a\x09\x09Smalltalk pseudoVariableNames do: [ :each |\x0a\x09\x09\x09pseudoVars at: each put: ((PseudoVar on: each)\x0a\x09\x09\x09\x09scope: self methodScope;\x0a\x09\x09\x09\x09yourself) ]].\x0a\x09^ pseudoVars",
  1010. referencedClasses: ["Dictionary", "Smalltalk", "PseudoVar"],
  1011. //>>excludeEnd("ide");
  1012. pragmas: [],
  1013. messageSends: ["ifNil:", "new", "do:", "pseudoVariableNames", "at:put:", "scope:", "on:", "methodScope", "yourself"]
  1014. }),
  1015. $globals.MethodLexicalScope);
  1016. $core.addMethod(
  1017. $core.method({
  1018. selector: "removeNonLocalReturn:",
  1019. protocol: "adding",
  1020. fn: function (aScope){
  1021. var self=this,$self=this;
  1022. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1023. return $core.withContext(function($ctx1) {
  1024. //>>excludeEnd("ctx");
  1025. $recv($self._nonLocalReturns())._remove_ifAbsent_(aScope,(function(){
  1026. }));
  1027. return self;
  1028. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1029. }, function($ctx1) {$ctx1.fill(self,"removeNonLocalReturn:",{aScope:aScope})});
  1030. //>>excludeEnd("ctx");
  1031. },
  1032. //>>excludeStart("ide", pragmas.excludeIdeData);
  1033. args: ["aScope"],
  1034. source: "removeNonLocalReturn: aScope\x0a\x09self nonLocalReturns remove: aScope ifAbsent: []",
  1035. referencedClasses: [],
  1036. //>>excludeEnd("ide");
  1037. pragmas: [],
  1038. messageSends: ["remove:ifAbsent:", "nonLocalReturns"]
  1039. }),
  1040. $globals.MethodLexicalScope);
  1041. $core.addMethod(
  1042. $core.method({
  1043. selector: "unknownVariables",
  1044. protocol: "accessing",
  1045. fn: function (){
  1046. var self=this,$self=this;
  1047. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1048. return $core.withContext(function($ctx1) {
  1049. //>>excludeEnd("ctx");
  1050. var $1,$receiver;
  1051. $1=$self.unknownVariables;
  1052. if(($receiver = $1) == null || $receiver.a$nil){
  1053. $self.unknownVariables=$recv($globals.OrderedCollection)._new();
  1054. return $self.unknownVariables;
  1055. } else {
  1056. return $1;
  1057. }
  1058. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1059. }, function($ctx1) {$ctx1.fill(self,"unknownVariables",{})});
  1060. //>>excludeEnd("ctx");
  1061. },
  1062. //>>excludeStart("ide", pragmas.excludeIdeData);
  1063. args: [],
  1064. source: "unknownVariables\x0a\x09^ unknownVariables ifNil: [ unknownVariables := OrderedCollection new ]",
  1065. referencedClasses: ["OrderedCollection"],
  1066. //>>excludeEnd("ide");
  1067. pragmas: [],
  1068. messageSends: ["ifNil:", "new"]
  1069. }),
  1070. $globals.MethodLexicalScope);
  1071. $core.addClass("ScopeVar", $globals.Object, ["scope", "name"], "Compiler-Semantic");
  1072. //>>excludeStart("ide", pragmas.excludeIdeData);
  1073. $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.";
  1074. //>>excludeEnd("ide");
  1075. $core.addMethod(
  1076. $core.method({
  1077. selector: "alias",
  1078. protocol: "accessing",
  1079. fn: function (){
  1080. var self=this,$self=this;
  1081. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1082. return $core.withContext(function($ctx1) {
  1083. //>>excludeEnd("ctx");
  1084. return $recv($self._name())._asVariableName();
  1085. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1086. }, function($ctx1) {$ctx1.fill(self,"alias",{})});
  1087. //>>excludeEnd("ctx");
  1088. },
  1089. //>>excludeStart("ide", pragmas.excludeIdeData);
  1090. args: [],
  1091. source: "alias\x0a\x09^ self name asVariableName",
  1092. referencedClasses: [],
  1093. //>>excludeEnd("ide");
  1094. pragmas: [],
  1095. messageSends: ["asVariableName", "name"]
  1096. }),
  1097. $globals.ScopeVar);
  1098. $core.addMethod(
  1099. $core.method({
  1100. selector: "isArgVar",
  1101. protocol: "testing",
  1102. fn: function (){
  1103. var self=this,$self=this;
  1104. return false;
  1105. },
  1106. //>>excludeStart("ide", pragmas.excludeIdeData);
  1107. args: [],
  1108. source: "isArgVar\x0a\x09^ false",
  1109. referencedClasses: [],
  1110. //>>excludeEnd("ide");
  1111. pragmas: [],
  1112. messageSends: []
  1113. }),
  1114. $globals.ScopeVar);
  1115. $core.addMethod(
  1116. $core.method({
  1117. selector: "isClassRefVar",
  1118. protocol: "testing",
  1119. fn: function (){
  1120. var self=this,$self=this;
  1121. return false;
  1122. },
  1123. //>>excludeStart("ide", pragmas.excludeIdeData);
  1124. args: [],
  1125. source: "isClassRefVar\x0a\x09^ false",
  1126. referencedClasses: [],
  1127. //>>excludeEnd("ide");
  1128. pragmas: [],
  1129. messageSends: []
  1130. }),
  1131. $globals.ScopeVar);
  1132. $core.addMethod(
  1133. $core.method({
  1134. selector: "isImmutable",
  1135. protocol: "testing",
  1136. fn: function (){
  1137. var self=this,$self=this;
  1138. return false;
  1139. },
  1140. //>>excludeStart("ide", pragmas.excludeIdeData);
  1141. args: [],
  1142. source: "isImmutable\x0a\x09^ false",
  1143. referencedClasses: [],
  1144. //>>excludeEnd("ide");
  1145. pragmas: [],
  1146. messageSends: []
  1147. }),
  1148. $globals.ScopeVar);
  1149. $core.addMethod(
  1150. $core.method({
  1151. selector: "isInstanceVar",
  1152. protocol: "testing",
  1153. fn: function (){
  1154. var self=this,$self=this;
  1155. return false;
  1156. },
  1157. //>>excludeStart("ide", pragmas.excludeIdeData);
  1158. args: [],
  1159. source: "isInstanceVar\x0a\x09^ false",
  1160. referencedClasses: [],
  1161. //>>excludeEnd("ide");
  1162. pragmas: [],
  1163. messageSends: []
  1164. }),
  1165. $globals.ScopeVar);
  1166. $core.addMethod(
  1167. $core.method({
  1168. selector: "isPseudoVar",
  1169. protocol: "testing",
  1170. fn: function (){
  1171. var self=this,$self=this;
  1172. return false;
  1173. },
  1174. //>>excludeStart("ide", pragmas.excludeIdeData);
  1175. args: [],
  1176. source: "isPseudoVar\x0a\x09^ false",
  1177. referencedClasses: [],
  1178. //>>excludeEnd("ide");
  1179. pragmas: [],
  1180. messageSends: []
  1181. }),
  1182. $globals.ScopeVar);
  1183. $core.addMethod(
  1184. $core.method({
  1185. selector: "isSelf",
  1186. protocol: "testing",
  1187. fn: function (){
  1188. var self=this,$self=this;
  1189. return false;
  1190. },
  1191. //>>excludeStart("ide", pragmas.excludeIdeData);
  1192. args: [],
  1193. source: "isSelf\x0a\x09^ false",
  1194. referencedClasses: [],
  1195. //>>excludeEnd("ide");
  1196. pragmas: [],
  1197. messageSends: []
  1198. }),
  1199. $globals.ScopeVar);
  1200. $core.addMethod(
  1201. $core.method({
  1202. selector: "isSuper",
  1203. protocol: "testing",
  1204. fn: function (){
  1205. var self=this,$self=this;
  1206. return false;
  1207. },
  1208. //>>excludeStart("ide", pragmas.excludeIdeData);
  1209. args: [],
  1210. source: "isSuper\x0a\x09^ false",
  1211. referencedClasses: [],
  1212. //>>excludeEnd("ide");
  1213. pragmas: [],
  1214. messageSends: []
  1215. }),
  1216. $globals.ScopeVar);
  1217. $core.addMethod(
  1218. $core.method({
  1219. selector: "isTempVar",
  1220. protocol: "testing",
  1221. fn: function (){
  1222. var self=this,$self=this;
  1223. return false;
  1224. },
  1225. //>>excludeStart("ide", pragmas.excludeIdeData);
  1226. args: [],
  1227. source: "isTempVar\x0a\x09^ false",
  1228. referencedClasses: [],
  1229. //>>excludeEnd("ide");
  1230. pragmas: [],
  1231. messageSends: []
  1232. }),
  1233. $globals.ScopeVar);
  1234. $core.addMethod(
  1235. $core.method({
  1236. selector: "isUnknownVar",
  1237. protocol: "testing",
  1238. fn: function (){
  1239. var self=this,$self=this;
  1240. return false;
  1241. },
  1242. //>>excludeStart("ide", pragmas.excludeIdeData);
  1243. args: [],
  1244. source: "isUnknownVar\x0a\x09^ false",
  1245. referencedClasses: [],
  1246. //>>excludeEnd("ide");
  1247. pragmas: [],
  1248. messageSends: []
  1249. }),
  1250. $globals.ScopeVar);
  1251. $core.addMethod(
  1252. $core.method({
  1253. selector: "name",
  1254. protocol: "accessing",
  1255. fn: function (){
  1256. var self=this,$self=this;
  1257. return $self.name;
  1258. },
  1259. //>>excludeStart("ide", pragmas.excludeIdeData);
  1260. args: [],
  1261. source: "name\x0a\x09^ name",
  1262. referencedClasses: [],
  1263. //>>excludeEnd("ide");
  1264. pragmas: [],
  1265. messageSends: []
  1266. }),
  1267. $globals.ScopeVar);
  1268. $core.addMethod(
  1269. $core.method({
  1270. selector: "name:",
  1271. protocol: "accessing",
  1272. fn: function (aString){
  1273. var self=this,$self=this;
  1274. $self.name=aString;
  1275. return self;
  1276. },
  1277. //>>excludeStart("ide", pragmas.excludeIdeData);
  1278. args: ["aString"],
  1279. source: "name: aString\x0a\x09name := aString",
  1280. referencedClasses: [],
  1281. //>>excludeEnd("ide");
  1282. pragmas: [],
  1283. messageSends: []
  1284. }),
  1285. $globals.ScopeVar);
  1286. $core.addMethod(
  1287. $core.method({
  1288. selector: "scope",
  1289. protocol: "accessing",
  1290. fn: function (){
  1291. var self=this,$self=this;
  1292. return $self.scope;
  1293. },
  1294. //>>excludeStart("ide", pragmas.excludeIdeData);
  1295. args: [],
  1296. source: "scope\x0a\x09^ scope",
  1297. referencedClasses: [],
  1298. //>>excludeEnd("ide");
  1299. pragmas: [],
  1300. messageSends: []
  1301. }),
  1302. $globals.ScopeVar);
  1303. $core.addMethod(
  1304. $core.method({
  1305. selector: "scope:",
  1306. protocol: "accessing",
  1307. fn: function (aScope){
  1308. var self=this,$self=this;
  1309. $self.scope=aScope;
  1310. return self;
  1311. },
  1312. //>>excludeStart("ide", pragmas.excludeIdeData);
  1313. args: ["aScope"],
  1314. source: "scope: aScope\x0a\x09scope := aScope",
  1315. referencedClasses: [],
  1316. //>>excludeEnd("ide");
  1317. pragmas: [],
  1318. messageSends: []
  1319. }),
  1320. $globals.ScopeVar);
  1321. $core.addMethod(
  1322. $core.method({
  1323. selector: "validateAssignment",
  1324. protocol: "testing",
  1325. fn: function (){
  1326. var self=this,$self=this;
  1327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1328. return $core.withContext(function($ctx1) {
  1329. //>>excludeEnd("ctx");
  1330. var $1,$2;
  1331. $1=$recv($self._isArgVar())._or_((function(){
  1332. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1333. return $core.withContext(function($ctx2) {
  1334. //>>excludeEnd("ctx");
  1335. return $self._isPseudoVar();
  1336. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1337. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1338. //>>excludeEnd("ctx");
  1339. }));
  1340. if($core.assert($1)){
  1341. $2=$recv($globals.InvalidAssignmentError)._new();
  1342. $recv($2)._variableName_($self._name());
  1343. $recv($2)._signal();
  1344. }
  1345. return self;
  1346. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1347. }, function($ctx1) {$ctx1.fill(self,"validateAssignment",{})});
  1348. //>>excludeEnd("ctx");
  1349. },
  1350. //>>excludeStart("ide", pragmas.excludeIdeData);
  1351. args: [],
  1352. source: "validateAssignment\x0a\x09(self isArgVar or: [ self isPseudoVar ]) ifTrue: [\x0a\x09\x09InvalidAssignmentError new\x0a\x09\x09\x09variableName: self name;\x0a\x09\x09\x09signal]",
  1353. referencedClasses: ["InvalidAssignmentError"],
  1354. //>>excludeEnd("ide");
  1355. pragmas: [],
  1356. messageSends: ["ifTrue:", "or:", "isArgVar", "isPseudoVar", "variableName:", "new", "name", "signal"]
  1357. }),
  1358. $globals.ScopeVar);
  1359. $core.addMethod(
  1360. $core.method({
  1361. selector: "on:",
  1362. protocol: "instance creation",
  1363. fn: function (aString){
  1364. var self=this,$self=this;
  1365. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1366. return $core.withContext(function($ctx1) {
  1367. //>>excludeEnd("ctx");
  1368. var $1;
  1369. $1=$self._new();
  1370. $recv($1)._name_(aString);
  1371. return $recv($1)._yourself();
  1372. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1373. }, function($ctx1) {$ctx1.fill(self,"on:",{aString:aString})});
  1374. //>>excludeEnd("ctx");
  1375. },
  1376. //>>excludeStart("ide", pragmas.excludeIdeData);
  1377. args: ["aString"],
  1378. source: "on: aString\x0a\x09^ self new\x0a\x09\x09name: aString;\x0a\x09\x09yourself",
  1379. referencedClasses: [],
  1380. //>>excludeEnd("ide");
  1381. pragmas: [],
  1382. messageSends: ["name:", "new", "yourself"]
  1383. }),
  1384. $globals.ScopeVar.a$cls);
  1385. $core.addClass("AliasVar", $globals.ScopeVar, ["node"], "Compiler-Semantic");
  1386. //>>excludeStart("ide", pragmas.excludeIdeData);
  1387. $globals.AliasVar.comment="I am an internally defined variable by the compiler";
  1388. //>>excludeEnd("ide");
  1389. $core.addMethod(
  1390. $core.method({
  1391. selector: "isImmutable",
  1392. protocol: "testing",
  1393. fn: function (){
  1394. var self=this,$self=this;
  1395. return true;
  1396. },
  1397. //>>excludeStart("ide", pragmas.excludeIdeData);
  1398. args: [],
  1399. source: "isImmutable\x0a\x09^ true",
  1400. referencedClasses: [],
  1401. //>>excludeEnd("ide");
  1402. pragmas: [],
  1403. messageSends: []
  1404. }),
  1405. $globals.AliasVar);
  1406. $core.addMethod(
  1407. $core.method({
  1408. selector: "node",
  1409. protocol: "accessing",
  1410. fn: function (){
  1411. var self=this,$self=this;
  1412. return $self.node;
  1413. },
  1414. //>>excludeStart("ide", pragmas.excludeIdeData);
  1415. args: [],
  1416. source: "node\x0a\x09^ node",
  1417. referencedClasses: [],
  1418. //>>excludeEnd("ide");
  1419. pragmas: [],
  1420. messageSends: []
  1421. }),
  1422. $globals.AliasVar);
  1423. $core.addMethod(
  1424. $core.method({
  1425. selector: "node:",
  1426. protocol: "accessing",
  1427. fn: function (aNode){
  1428. var self=this,$self=this;
  1429. $self.node=aNode;
  1430. return self;
  1431. },
  1432. //>>excludeStart("ide", pragmas.excludeIdeData);
  1433. args: ["aNode"],
  1434. source: "node: aNode\x0a\x09node := aNode",
  1435. referencedClasses: [],
  1436. //>>excludeEnd("ide");
  1437. pragmas: [],
  1438. messageSends: []
  1439. }),
  1440. $globals.AliasVar);
  1441. $core.addClass("ArgVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1442. //>>excludeStart("ide", pragmas.excludeIdeData);
  1443. $globals.ArgVar.comment="I am an argument of a method or block.";
  1444. //>>excludeEnd("ide");
  1445. $core.addMethod(
  1446. $core.method({
  1447. selector: "isArgVar",
  1448. protocol: "testing",
  1449. fn: function (){
  1450. var self=this,$self=this;
  1451. return true;
  1452. },
  1453. //>>excludeStart("ide", pragmas.excludeIdeData);
  1454. args: [],
  1455. source: "isArgVar\x0a\x09^ true",
  1456. referencedClasses: [],
  1457. //>>excludeEnd("ide");
  1458. pragmas: [],
  1459. messageSends: []
  1460. }),
  1461. $globals.ArgVar);
  1462. $core.addMethod(
  1463. $core.method({
  1464. selector: "isImmutable",
  1465. protocol: "testing",
  1466. fn: function (){
  1467. var self=this,$self=this;
  1468. return true;
  1469. },
  1470. //>>excludeStart("ide", pragmas.excludeIdeData);
  1471. args: [],
  1472. source: "isImmutable\x0a\x09^ true",
  1473. referencedClasses: [],
  1474. //>>excludeEnd("ide");
  1475. pragmas: [],
  1476. messageSends: []
  1477. }),
  1478. $globals.ArgVar);
  1479. $core.addClass("ClassRefVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1480. //>>excludeStart("ide", pragmas.excludeIdeData);
  1481. $globals.ClassRefVar.comment="I am an class reference variable";
  1482. //>>excludeEnd("ide");
  1483. $core.addMethod(
  1484. $core.method({
  1485. selector: "alias",
  1486. protocol: "accessing",
  1487. fn: function (){
  1488. var self=this,$self=this;
  1489. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1490. return $core.withContext(function($ctx1) {
  1491. //>>excludeEnd("ctx");
  1492. return "$globals.".__comma($self._name());
  1493. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1494. }, function($ctx1) {$ctx1.fill(self,"alias",{})});
  1495. //>>excludeEnd("ctx");
  1496. },
  1497. //>>excludeStart("ide", pragmas.excludeIdeData);
  1498. args: [],
  1499. 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",
  1500. referencedClasses: [],
  1501. //>>excludeEnd("ide");
  1502. pragmas: [],
  1503. messageSends: [",", "name"]
  1504. }),
  1505. $globals.ClassRefVar);
  1506. $core.addMethod(
  1507. $core.method({
  1508. selector: "isClassRefVar",
  1509. protocol: "testing",
  1510. fn: function (){
  1511. var self=this,$self=this;
  1512. return true;
  1513. },
  1514. //>>excludeStart("ide", pragmas.excludeIdeData);
  1515. args: [],
  1516. source: "isClassRefVar\x0a\x09^ true",
  1517. referencedClasses: [],
  1518. //>>excludeEnd("ide");
  1519. pragmas: [],
  1520. messageSends: []
  1521. }),
  1522. $globals.ClassRefVar);
  1523. $core.addMethod(
  1524. $core.method({
  1525. selector: "isImmutable",
  1526. protocol: "testing",
  1527. fn: function (){
  1528. var self=this,$self=this;
  1529. return true;
  1530. },
  1531. //>>excludeStart("ide", pragmas.excludeIdeData);
  1532. args: [],
  1533. source: "isImmutable\x0a\x09^ true",
  1534. referencedClasses: [],
  1535. //>>excludeEnd("ide");
  1536. pragmas: [],
  1537. messageSends: []
  1538. }),
  1539. $globals.ClassRefVar);
  1540. $core.addClass("InstanceVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1541. //>>excludeStart("ide", pragmas.excludeIdeData);
  1542. $globals.InstanceVar.comment="I am an instance variable of a method or block.";
  1543. //>>excludeEnd("ide");
  1544. $core.addMethod(
  1545. $core.method({
  1546. selector: "alias",
  1547. protocol: "testing",
  1548. fn: function (){
  1549. var self=this,$self=this;
  1550. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1551. return $core.withContext(function($ctx1) {
  1552. //>>excludeEnd("ctx");
  1553. return "$self.".__comma($self._name());
  1554. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1555. }, function($ctx1) {$ctx1.fill(self,"alias",{})});
  1556. //>>excludeEnd("ctx");
  1557. },
  1558. //>>excludeStart("ide", pragmas.excludeIdeData);
  1559. args: [],
  1560. source: "alias\x0a\x09^ '$self.', self name",
  1561. referencedClasses: [],
  1562. //>>excludeEnd("ide");
  1563. pragmas: [],
  1564. messageSends: [",", "name"]
  1565. }),
  1566. $globals.InstanceVar);
  1567. $core.addMethod(
  1568. $core.method({
  1569. selector: "isInstanceVar",
  1570. protocol: "testing",
  1571. fn: function (){
  1572. var self=this,$self=this;
  1573. return true;
  1574. },
  1575. //>>excludeStart("ide", pragmas.excludeIdeData);
  1576. args: [],
  1577. source: "isInstanceVar\x0a\x09^ true",
  1578. referencedClasses: [],
  1579. //>>excludeEnd("ide");
  1580. pragmas: [],
  1581. messageSends: []
  1582. }),
  1583. $globals.InstanceVar);
  1584. $core.addClass("PseudoVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1585. //>>excludeStart("ide", pragmas.excludeIdeData);
  1586. $globals.PseudoVar.comment="I am an pseudo variable.\x0a\x0aThe five Smalltalk pseudo variables are: 'self', 'super', 'nil', 'true' and 'false'";
  1587. //>>excludeEnd("ide");
  1588. $core.addMethod(
  1589. $core.method({
  1590. selector: "alias",
  1591. protocol: "accessing",
  1592. fn: function (){
  1593. var self=this,$self=this;
  1594. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1595. return $core.withContext(function($ctx1) {
  1596. //>>excludeEnd("ctx");
  1597. return $self._name();
  1598. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1599. }, function($ctx1) {$ctx1.fill(self,"alias",{})});
  1600. //>>excludeEnd("ctx");
  1601. },
  1602. //>>excludeStart("ide", pragmas.excludeIdeData);
  1603. args: [],
  1604. source: "alias\x0a\x09^ self name",
  1605. referencedClasses: [],
  1606. //>>excludeEnd("ide");
  1607. pragmas: [],
  1608. messageSends: ["name"]
  1609. }),
  1610. $globals.PseudoVar);
  1611. $core.addMethod(
  1612. $core.method({
  1613. selector: "isImmutable",
  1614. protocol: "testing",
  1615. fn: function (){
  1616. var self=this,$self=this;
  1617. return true;
  1618. },
  1619. //>>excludeStart("ide", pragmas.excludeIdeData);
  1620. args: [],
  1621. source: "isImmutable\x0a\x09^ true",
  1622. referencedClasses: [],
  1623. //>>excludeEnd("ide");
  1624. pragmas: [],
  1625. messageSends: []
  1626. }),
  1627. $globals.PseudoVar);
  1628. $core.addMethod(
  1629. $core.method({
  1630. selector: "isPseudoVar",
  1631. protocol: "testing",
  1632. fn: function (){
  1633. var self=this,$self=this;
  1634. return true;
  1635. },
  1636. //>>excludeStart("ide", pragmas.excludeIdeData);
  1637. args: [],
  1638. source: "isPseudoVar\x0a\x09^ true",
  1639. referencedClasses: [],
  1640. //>>excludeEnd("ide");
  1641. pragmas: [],
  1642. messageSends: []
  1643. }),
  1644. $globals.PseudoVar);
  1645. $core.addMethod(
  1646. $core.method({
  1647. selector: "isSelf",
  1648. protocol: "testing",
  1649. fn: function (){
  1650. var self=this,$self=this;
  1651. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1652. return $core.withContext(function($ctx1) {
  1653. //>>excludeEnd("ctx");
  1654. return $recv($self.name).__eq("self");
  1655. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1656. }, function($ctx1) {$ctx1.fill(self,"isSelf",{})});
  1657. //>>excludeEnd("ctx");
  1658. },
  1659. //>>excludeStart("ide", pragmas.excludeIdeData);
  1660. args: [],
  1661. source: "isSelf\x0a\x09^ name = 'self'",
  1662. referencedClasses: [],
  1663. //>>excludeEnd("ide");
  1664. pragmas: [],
  1665. messageSends: ["="]
  1666. }),
  1667. $globals.PseudoVar);
  1668. $core.addMethod(
  1669. $core.method({
  1670. selector: "isSuper",
  1671. protocol: "testing",
  1672. fn: function (){
  1673. var self=this,$self=this;
  1674. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1675. return $core.withContext(function($ctx1) {
  1676. //>>excludeEnd("ctx");
  1677. return $recv($self.name).__eq("super");
  1678. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1679. }, function($ctx1) {$ctx1.fill(self,"isSuper",{})});
  1680. //>>excludeEnd("ctx");
  1681. },
  1682. //>>excludeStart("ide", pragmas.excludeIdeData);
  1683. args: [],
  1684. source: "isSuper\x0a\x09^ name = 'super'",
  1685. referencedClasses: [],
  1686. //>>excludeEnd("ide");
  1687. pragmas: [],
  1688. messageSends: ["="]
  1689. }),
  1690. $globals.PseudoVar);
  1691. $core.addClass("TempVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1692. //>>excludeStart("ide", pragmas.excludeIdeData);
  1693. $globals.TempVar.comment="I am an temporary variable of a method or block.";
  1694. //>>excludeEnd("ide");
  1695. $core.addMethod(
  1696. $core.method({
  1697. selector: "isTempVar",
  1698. protocol: "testing",
  1699. fn: function (){
  1700. var self=this,$self=this;
  1701. return true;
  1702. },
  1703. //>>excludeStart("ide", pragmas.excludeIdeData);
  1704. args: [],
  1705. source: "isTempVar\x0a\x09^ true",
  1706. referencedClasses: [],
  1707. //>>excludeEnd("ide");
  1708. pragmas: [],
  1709. messageSends: []
  1710. }),
  1711. $globals.TempVar);
  1712. $core.addClass("UnknownVar", $globals.ScopeVar, [], "Compiler-Semantic");
  1713. //>>excludeStart("ide", pragmas.excludeIdeData);
  1714. $globals.UnknownVar.comment="I am an unknown variable. Amber uses unknown variables as JavaScript globals";
  1715. //>>excludeEnd("ide");
  1716. $core.addMethod(
  1717. $core.method({
  1718. selector: "isUnknownVar",
  1719. protocol: "testing",
  1720. fn: function (){
  1721. var self=this,$self=this;
  1722. return true;
  1723. },
  1724. //>>excludeStart("ide", pragmas.excludeIdeData);
  1725. args: [],
  1726. source: "isUnknownVar\x0a\x09^ true",
  1727. referencedClasses: [],
  1728. //>>excludeEnd("ide");
  1729. pragmas: [],
  1730. messageSends: []
  1731. }),
  1732. $globals.UnknownVar);
  1733. $core.addClass("SemanticAnalyzer", $globals.NodeVisitor, ["currentScope", "blockIndex", "thePackage", "theClass", "classReferences", "messageSends"], "Compiler-Semantic");
  1734. //>>excludeStart("ide", pragmas.excludeIdeData);
  1735. $globals.SemanticAnalyzer.comment="I semantically analyze the abstract syntax tree and annotate it with informations such as non local returns and variable scopes.";
  1736. //>>excludeEnd("ide");
  1737. $core.addMethod(
  1738. $core.method({
  1739. selector: "classReferences",
  1740. protocol: "accessing",
  1741. fn: function (){
  1742. var self=this,$self=this;
  1743. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1744. return $core.withContext(function($ctx1) {
  1745. //>>excludeEnd("ctx");
  1746. var $1,$receiver;
  1747. $1=$self.classReferences;
  1748. if(($receiver = $1) == null || $receiver.a$nil){
  1749. $self.classReferences=$recv($globals.Set)._new();
  1750. return $self.classReferences;
  1751. } else {
  1752. return $1;
  1753. }
  1754. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1755. }, function($ctx1) {$ctx1.fill(self,"classReferences",{})});
  1756. //>>excludeEnd("ctx");
  1757. },
  1758. //>>excludeStart("ide", pragmas.excludeIdeData);
  1759. args: [],
  1760. source: "classReferences\x0a\x09^ classReferences ifNil: [ classReferences := Set new ]",
  1761. referencedClasses: ["Set"],
  1762. //>>excludeEnd("ide");
  1763. pragmas: [],
  1764. messageSends: ["ifNil:", "new"]
  1765. }),
  1766. $globals.SemanticAnalyzer);
  1767. $core.addMethod(
  1768. $core.method({
  1769. selector: "errorShadowingVariable:",
  1770. protocol: "error handling",
  1771. fn: function (aString){
  1772. var self=this,$self=this;
  1773. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1774. return $core.withContext(function($ctx1) {
  1775. //>>excludeEnd("ctx");
  1776. var $1;
  1777. $1=$recv($globals.ShadowingVariableError)._new();
  1778. $recv($1)._variableName_(aString);
  1779. $recv($1)._signal();
  1780. return self;
  1781. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1782. }, function($ctx1) {$ctx1.fill(self,"errorShadowingVariable:",{aString:aString})});
  1783. //>>excludeEnd("ctx");
  1784. },
  1785. //>>excludeStart("ide", pragmas.excludeIdeData);
  1786. args: ["aString"],
  1787. source: "errorShadowingVariable: aString\x0a\x09ShadowingVariableError new\x0a\x09\x09variableName: aString;\x0a\x09\x09signal",
  1788. referencedClasses: ["ShadowingVariableError"],
  1789. //>>excludeEnd("ide");
  1790. pragmas: [],
  1791. messageSends: ["variableName:", "new", "signal"]
  1792. }),
  1793. $globals.SemanticAnalyzer);
  1794. $core.addMethod(
  1795. $core.method({
  1796. selector: "errorUnknownVariable:",
  1797. protocol: "error handling",
  1798. fn: function (aNode){
  1799. var self=this,$self=this;
  1800. var identifier;
  1801. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1802. return $core.withContext(function($ctx1) {
  1803. //>>excludeEnd("ctx");
  1804. var $1,$2,$3;
  1805. identifier=$recv(aNode)._value();
  1806. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1807. $ctx1.sendIdx["value"]=1;
  1808. //>>excludeEnd("ctx");
  1809. $1=$recv($recv($recv($recv($globals.Smalltalk)._globalJsVariables())._includes_(identifier))._not())._and_((function(){
  1810. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1811. return $core.withContext(function($ctx2) {
  1812. //>>excludeEnd("ctx");
  1813. return $self._isVariableUndefined_inPackage_(identifier,$self._thePackage());
  1814. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1815. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1816. //>>excludeEnd("ctx");
  1817. }));
  1818. if($core.assert($1)){
  1819. $2=$recv($globals.UnknownVariableError)._new();
  1820. $3=$recv(aNode)._value();
  1821. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1822. $ctx1.sendIdx["value"]=2;
  1823. //>>excludeEnd("ctx");
  1824. $recv($2)._variableName_($3);
  1825. $recv($2)._signal();
  1826. } else {
  1827. $recv($recv($recv($self.currentScope)._methodScope())._unknownVariables())._add_($recv(aNode)._value());
  1828. }
  1829. return self;
  1830. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1831. }, function($ctx1) {$ctx1.fill(self,"errorUnknownVariable:",{aNode:aNode,identifier:identifier})});
  1832. //>>excludeEnd("ctx");
  1833. },
  1834. //>>excludeStart("ide", pragmas.excludeIdeData);
  1835. args: ["aNode"],
  1836. 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 ]",
  1837. referencedClasses: ["Smalltalk", "UnknownVariableError"],
  1838. //>>excludeEnd("ide");
  1839. pragmas: [],
  1840. messageSends: ["value", "ifTrue:ifFalse:", "and:", "not", "includes:", "globalJsVariables", "isVariableUndefined:inPackage:", "thePackage", "variableName:", "new", "signal", "add:", "unknownVariables", "methodScope"]
  1841. }),
  1842. $globals.SemanticAnalyzer);
  1843. $core.addMethod(
  1844. $core.method({
  1845. selector: "isVariableUndefined:inPackage:",
  1846. protocol: "testing",
  1847. fn: function (aString,aPackage){
  1848. var self=this,$self=this;
  1849. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1850. return $core.withContext(function($ctx1) {
  1851. //>>excludeEnd("ctx");
  1852. var $1,$2,$receiver;
  1853. if(($receiver = aPackage) == null || $receiver.a$nil){
  1854. aPackage;
  1855. } else {
  1856. var packageKnownVars;
  1857. packageKnownVars=$recv($recv($recv(aPackage)._imports())._reject_("isString"))._collect_("key");
  1858. $1=$recv(packageKnownVars)._includes_(aString);
  1859. if($core.assert($1)){
  1860. return false;
  1861. }
  1862. }
  1863. $2=$recv("typeof ".__comma(aString)).__comma(" === \x22undefined\x22");
  1864. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1865. $ctx1.sendIdx[","]=1;
  1866. //>>excludeEnd("ctx");
  1867. return $recv($globals.Compiler)._eval_($2);
  1868. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1869. }, function($ctx1) {$ctx1.fill(self,"isVariableUndefined:inPackage:",{aString:aString,aPackage:aPackage})});
  1870. //>>excludeEnd("ctx");
  1871. },
  1872. //>>excludeStart("ide", pragmas.excludeIdeData);
  1873. args: ["aString", "aPackage"],
  1874. 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'",
  1875. referencedClasses: ["Compiler"],
  1876. //>>excludeEnd("ide");
  1877. pragmas: [],
  1878. messageSends: ["ifNotNil:", "collect:", "reject:", "imports", "ifTrue:", "includes:", "eval:", ","]
  1879. }),
  1880. $globals.SemanticAnalyzer);
  1881. $core.addMethod(
  1882. $core.method({
  1883. selector: "messageSends",
  1884. protocol: "accessing",
  1885. fn: function (){
  1886. var self=this,$self=this;
  1887. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1888. return $core.withContext(function($ctx1) {
  1889. //>>excludeEnd("ctx");
  1890. var $1,$receiver;
  1891. $1=$self.messageSends;
  1892. if(($receiver = $1) == null || $receiver.a$nil){
  1893. $self.messageSends=$recv($globals.Dictionary)._new();
  1894. return $self.messageSends;
  1895. } else {
  1896. return $1;
  1897. }
  1898. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1899. }, function($ctx1) {$ctx1.fill(self,"messageSends",{})});
  1900. //>>excludeEnd("ctx");
  1901. },
  1902. //>>excludeStart("ide", pragmas.excludeIdeData);
  1903. args: [],
  1904. source: "messageSends\x0a\x09^ messageSends ifNil: [ messageSends := Dictionary new ]",
  1905. referencedClasses: ["Dictionary"],
  1906. //>>excludeEnd("ide");
  1907. pragmas: [],
  1908. messageSends: ["ifNil:", "new"]
  1909. }),
  1910. $globals.SemanticAnalyzer);
  1911. $core.addMethod(
  1912. $core.method({
  1913. selector: "newBlockScope",
  1914. protocol: "factory",
  1915. fn: function (){
  1916. var self=this,$self=this;
  1917. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1918. return $core.withContext(function($ctx1) {
  1919. //>>excludeEnd("ctx");
  1920. return $self._newScopeOfClass_($globals.LexicalScope);
  1921. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1922. }, function($ctx1) {$ctx1.fill(self,"newBlockScope",{})});
  1923. //>>excludeEnd("ctx");
  1924. },
  1925. //>>excludeStart("ide", pragmas.excludeIdeData);
  1926. args: [],
  1927. source: "newBlockScope\x0a\x09^ self newScopeOfClass: LexicalScope",
  1928. referencedClasses: ["LexicalScope"],
  1929. //>>excludeEnd("ide");
  1930. pragmas: [],
  1931. messageSends: ["newScopeOfClass:"]
  1932. }),
  1933. $globals.SemanticAnalyzer);
  1934. $core.addMethod(
  1935. $core.method({
  1936. selector: "newMethodScope",
  1937. protocol: "factory",
  1938. fn: function (){
  1939. var self=this,$self=this;
  1940. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1941. return $core.withContext(function($ctx1) {
  1942. //>>excludeEnd("ctx");
  1943. return $self._newScopeOfClass_($globals.MethodLexicalScope);
  1944. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1945. }, function($ctx1) {$ctx1.fill(self,"newMethodScope",{})});
  1946. //>>excludeEnd("ctx");
  1947. },
  1948. //>>excludeStart("ide", pragmas.excludeIdeData);
  1949. args: [],
  1950. source: "newMethodScope\x0a\x09^ self newScopeOfClass: MethodLexicalScope",
  1951. referencedClasses: ["MethodLexicalScope"],
  1952. //>>excludeEnd("ide");
  1953. pragmas: [],
  1954. messageSends: ["newScopeOfClass:"]
  1955. }),
  1956. $globals.SemanticAnalyzer);
  1957. $core.addMethod(
  1958. $core.method({
  1959. selector: "newScopeOfClass:",
  1960. protocol: "factory",
  1961. fn: function (aLexicalScopeClass){
  1962. var self=this,$self=this;
  1963. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1964. return $core.withContext(function($ctx1) {
  1965. //>>excludeEnd("ctx");
  1966. var $1;
  1967. $1=$recv(aLexicalScopeClass)._new();
  1968. $recv($1)._outerScope_($self.currentScope);
  1969. return $recv($1)._yourself();
  1970. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1971. }, function($ctx1) {$ctx1.fill(self,"newScopeOfClass:",{aLexicalScopeClass:aLexicalScopeClass})});
  1972. //>>excludeEnd("ctx");
  1973. },
  1974. //>>excludeStart("ide", pragmas.excludeIdeData);
  1975. args: ["aLexicalScopeClass"],
  1976. source: "newScopeOfClass: aLexicalScopeClass\x0a\x09^ aLexicalScopeClass new\x0a\x09\x09outerScope: currentScope;\x0a\x09\x09yourself",
  1977. referencedClasses: [],
  1978. //>>excludeEnd("ide");
  1979. pragmas: [],
  1980. messageSends: ["outerScope:", "new", "yourself"]
  1981. }),
  1982. $globals.SemanticAnalyzer);
  1983. $core.addMethod(
  1984. $core.method({
  1985. selector: "nextBlockIndex",
  1986. protocol: "private",
  1987. fn: function (){
  1988. var self=this,$self=this;
  1989. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1990. return $core.withContext(function($ctx1) {
  1991. //>>excludeEnd("ctx");
  1992. var $1,$receiver;
  1993. $1=$self.blockIndex;
  1994. if(($receiver = $1) == null || $receiver.a$nil){
  1995. $self.blockIndex=(0);
  1996. $self.blockIndex;
  1997. } else {
  1998. $1;
  1999. }
  2000. $self.blockIndex=$recv($self.blockIndex).__plus((1));
  2001. return $self.blockIndex;
  2002. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2003. }, function($ctx1) {$ctx1.fill(self,"nextBlockIndex",{})});
  2004. //>>excludeEnd("ctx");
  2005. },
  2006. //>>excludeStart("ide", pragmas.excludeIdeData);
  2007. args: [],
  2008. source: "nextBlockIndex\x0a\x09blockIndex ifNil: [ blockIndex := 0 ].\x0a\x09\x0a\x09blockIndex := blockIndex + 1.\x0a\x09^ blockIndex",
  2009. referencedClasses: [],
  2010. //>>excludeEnd("ide");
  2011. pragmas: [],
  2012. messageSends: ["ifNil:", "+"]
  2013. }),
  2014. $globals.SemanticAnalyzer);
  2015. $core.addMethod(
  2016. $core.method({
  2017. selector: "popScope",
  2018. protocol: "scope",
  2019. fn: function (){
  2020. var self=this,$self=this;
  2021. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2022. return $core.withContext(function($ctx1) {
  2023. //>>excludeEnd("ctx");
  2024. var $1,$receiver;
  2025. $1=$self.currentScope;
  2026. if(($receiver = $1) == null || $receiver.a$nil){
  2027. $1;
  2028. } else {
  2029. $self.currentScope=$recv($self.currentScope)._outerScope();
  2030. $self.currentScope;
  2031. }
  2032. return self;
  2033. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2034. }, function($ctx1) {$ctx1.fill(self,"popScope",{})});
  2035. //>>excludeEnd("ctx");
  2036. },
  2037. //>>excludeStart("ide", pragmas.excludeIdeData);
  2038. args: [],
  2039. source: "popScope\x0a\x09currentScope ifNotNil: [\x0a\x09\x09currentScope := currentScope outerScope ]",
  2040. referencedClasses: [],
  2041. //>>excludeEnd("ide");
  2042. pragmas: [],
  2043. messageSends: ["ifNotNil:", "outerScope"]
  2044. }),
  2045. $globals.SemanticAnalyzer);
  2046. $core.addMethod(
  2047. $core.method({
  2048. selector: "pushScope:",
  2049. protocol: "scope",
  2050. fn: function (aScope){
  2051. var self=this,$self=this;
  2052. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2053. return $core.withContext(function($ctx1) {
  2054. //>>excludeEnd("ctx");
  2055. $recv(aScope)._outerScope_($self.currentScope);
  2056. $self.currentScope=aScope;
  2057. return self;
  2058. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2059. }, function($ctx1) {$ctx1.fill(self,"pushScope:",{aScope:aScope})});
  2060. //>>excludeEnd("ctx");
  2061. },
  2062. //>>excludeStart("ide", pragmas.excludeIdeData);
  2063. args: ["aScope"],
  2064. source: "pushScope: aScope\x0a\x09aScope outerScope: currentScope.\x0a\x09currentScope := aScope",
  2065. referencedClasses: [],
  2066. //>>excludeEnd("ide");
  2067. pragmas: [],
  2068. messageSends: ["outerScope:"]
  2069. }),
  2070. $globals.SemanticAnalyzer);
  2071. $core.addMethod(
  2072. $core.method({
  2073. selector: "theClass",
  2074. protocol: "accessing",
  2075. fn: function (){
  2076. var self=this,$self=this;
  2077. return $self.theClass;
  2078. },
  2079. //>>excludeStart("ide", pragmas.excludeIdeData);
  2080. args: [],
  2081. source: "theClass\x0a\x09^ theClass",
  2082. referencedClasses: [],
  2083. //>>excludeEnd("ide");
  2084. pragmas: [],
  2085. messageSends: []
  2086. }),
  2087. $globals.SemanticAnalyzer);
  2088. $core.addMethod(
  2089. $core.method({
  2090. selector: "theClass:",
  2091. protocol: "accessing",
  2092. fn: function (aClass){
  2093. var self=this,$self=this;
  2094. $self.theClass=aClass;
  2095. return self;
  2096. },
  2097. //>>excludeStart("ide", pragmas.excludeIdeData);
  2098. args: ["aClass"],
  2099. source: "theClass: aClass\x0a\x09theClass := aClass",
  2100. referencedClasses: [],
  2101. //>>excludeEnd("ide");
  2102. pragmas: [],
  2103. messageSends: []
  2104. }),
  2105. $globals.SemanticAnalyzer);
  2106. $core.addMethod(
  2107. $core.method({
  2108. selector: "thePackage",
  2109. protocol: "accessing",
  2110. fn: function (){
  2111. var self=this,$self=this;
  2112. return $self.thePackage;
  2113. },
  2114. //>>excludeStart("ide", pragmas.excludeIdeData);
  2115. args: [],
  2116. source: "thePackage\x0a\x09^ thePackage",
  2117. referencedClasses: [],
  2118. //>>excludeEnd("ide");
  2119. pragmas: [],
  2120. messageSends: []
  2121. }),
  2122. $globals.SemanticAnalyzer);
  2123. $core.addMethod(
  2124. $core.method({
  2125. selector: "thePackage:",
  2126. protocol: "accessing",
  2127. fn: function (aPackage){
  2128. var self=this,$self=this;
  2129. $self.thePackage=aPackage;
  2130. return self;
  2131. },
  2132. //>>excludeStart("ide", pragmas.excludeIdeData);
  2133. args: ["aPackage"],
  2134. source: "thePackage: aPackage\x0a\x09thePackage := aPackage",
  2135. referencedClasses: [],
  2136. //>>excludeEnd("ide");
  2137. pragmas: [],
  2138. messageSends: []
  2139. }),
  2140. $globals.SemanticAnalyzer);
  2141. $core.addMethod(
  2142. $core.method({
  2143. selector: "validateVariableScope:",
  2144. protocol: "scope",
  2145. fn: function (aString){
  2146. var self=this,$self=this;
  2147. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2148. return $core.withContext(function($ctx1) {
  2149. //>>excludeEnd("ctx");
  2150. var $1,$receiver;
  2151. $1=$recv($self.currentScope)._lookupVariable_(aString);
  2152. if(($receiver = $1) == null || $receiver.a$nil){
  2153. $1;
  2154. } else {
  2155. $self._errorShadowingVariable_(aString);
  2156. }
  2157. return self;
  2158. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2159. }, function($ctx1) {$ctx1.fill(self,"validateVariableScope:",{aString:aString})});
  2160. //>>excludeEnd("ctx");
  2161. },
  2162. //>>excludeStart("ide", pragmas.excludeIdeData);
  2163. args: ["aString"],
  2164. 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 ]",
  2165. referencedClasses: [],
  2166. //>>excludeEnd("ide");
  2167. pragmas: [],
  2168. messageSends: ["ifNotNil:", "lookupVariable:", "errorShadowingVariable:"]
  2169. }),
  2170. $globals.SemanticAnalyzer);
  2171. $core.addMethod(
  2172. $core.method({
  2173. selector: "visitAssignmentNode:",
  2174. protocol: "visiting",
  2175. fn: function (aNode){
  2176. var self=this,$self=this;
  2177. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2178. return $core.withContext(function($ctx1) {
  2179. //>>excludeEnd("ctx");
  2180. (
  2181. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2182. $ctx1.supercall = true,
  2183. //>>excludeEnd("ctx");
  2184. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitAssignmentNode_.apply($self, [aNode]));
  2185. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2186. $ctx1.supercall = false;
  2187. //>>excludeEnd("ctx");;
  2188. $recv($recv(aNode)._left())._beAssigned();
  2189. return self;
  2190. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2191. }, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode})});
  2192. //>>excludeEnd("ctx");
  2193. },
  2194. //>>excludeStart("ide", pragmas.excludeIdeData);
  2195. args: ["aNode"],
  2196. source: "visitAssignmentNode: aNode\x0a\x09super visitAssignmentNode: aNode.\x0a\x09aNode left beAssigned",
  2197. referencedClasses: [],
  2198. //>>excludeEnd("ide");
  2199. pragmas: [],
  2200. messageSends: ["visitAssignmentNode:", "beAssigned", "left"]
  2201. }),
  2202. $globals.SemanticAnalyzer);
  2203. $core.addMethod(
  2204. $core.method({
  2205. selector: "visitBlockNode:",
  2206. protocol: "visiting",
  2207. fn: function (aNode){
  2208. var self=this,$self=this;
  2209. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2210. return $core.withContext(function($ctx1) {
  2211. //>>excludeEnd("ctx");
  2212. $self._pushScope_($self._newBlockScope());
  2213. $recv(aNode)._scope_($self.currentScope);
  2214. $recv($self.currentScope)._node_(aNode);
  2215. $recv($self.currentScope)._blockIndex_($self._nextBlockIndex());
  2216. $recv($recv(aNode)._parameters())._do_((function(each){
  2217. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2218. return $core.withContext(function($ctx2) {
  2219. //>>excludeEnd("ctx");
  2220. $self._validateVariableScope_(each);
  2221. return $recv($self.currentScope)._addArg_(each);
  2222. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2223. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2224. //>>excludeEnd("ctx");
  2225. }));
  2226. (
  2227. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2228. $ctx1.supercall = true,
  2229. //>>excludeEnd("ctx");
  2230. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitBlockNode_.apply($self, [aNode]));
  2231. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2232. $ctx1.supercall = false;
  2233. //>>excludeEnd("ctx");;
  2234. $self._popScope();
  2235. return self;
  2236. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2237. }, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode})});
  2238. //>>excludeEnd("ctx");
  2239. },
  2240. //>>excludeStart("ide", pragmas.excludeIdeData);
  2241. args: ["aNode"],
  2242. 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",
  2243. referencedClasses: [],
  2244. //>>excludeEnd("ide");
  2245. pragmas: [],
  2246. messageSends: ["pushScope:", "newBlockScope", "scope:", "node:", "blockIndex:", "nextBlockIndex", "do:", "parameters", "validateVariableScope:", "addArg:", "visitBlockNode:", "popScope"]
  2247. }),
  2248. $globals.SemanticAnalyzer);
  2249. $core.addMethod(
  2250. $core.method({
  2251. selector: "visitCascadeNode:",
  2252. protocol: "visiting",
  2253. fn: function (aNode){
  2254. var self=this,$self=this;
  2255. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2256. return $core.withContext(function($ctx1) {
  2257. //>>excludeEnd("ctx");
  2258. $recv(aNode)._receiver_($recv($recv($recv(aNode)._dagChildren())._first())._receiver());
  2259. (
  2260. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2261. $ctx1.supercall = true,
  2262. //>>excludeEnd("ctx");
  2263. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitCascadeNode_.apply($self, [aNode]));
  2264. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2265. $ctx1.supercall = false;
  2266. //>>excludeEnd("ctx");;
  2267. return self;
  2268. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2269. }, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode})});
  2270. //>>excludeEnd("ctx");
  2271. },
  2272. //>>excludeStart("ide", pragmas.excludeIdeData);
  2273. args: ["aNode"],
  2274. source: "visitCascadeNode: aNode\x0a\x09aNode receiver: aNode dagChildren first receiver.\x0a\x09super visitCascadeNode: aNode",
  2275. referencedClasses: [],
  2276. //>>excludeEnd("ide");
  2277. pragmas: [],
  2278. messageSends: ["receiver:", "receiver", "first", "dagChildren", "visitCascadeNode:"]
  2279. }),
  2280. $globals.SemanticAnalyzer);
  2281. $core.addMethod(
  2282. $core.method({
  2283. selector: "visitMethodNode:",
  2284. protocol: "visiting",
  2285. fn: function (aNode){
  2286. var self=this,$self=this;
  2287. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2288. return $core.withContext(function($ctx1) {
  2289. //>>excludeEnd("ctx");
  2290. $self._pushScope_($self._newMethodScope());
  2291. $recv(aNode)._scope_($self.currentScope);
  2292. $recv($self.currentScope)._node_(aNode);
  2293. $recv($recv($self._theClass())._allInstanceVariableNames())._do_((function(each){
  2294. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2295. return $core.withContext(function($ctx2) {
  2296. //>>excludeEnd("ctx");
  2297. return $recv($self.currentScope)._addIVar_(each);
  2298. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2299. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2300. //>>excludeEnd("ctx");
  2301. }));
  2302. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2303. $ctx1.sendIdx["do:"]=1;
  2304. //>>excludeEnd("ctx");
  2305. $recv($recv(aNode)._arguments())._do_((function(each){
  2306. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2307. return $core.withContext(function($ctx2) {
  2308. //>>excludeEnd("ctx");
  2309. $self._validateVariableScope_(each);
  2310. return $recv($self.currentScope)._addArg_(each);
  2311. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2312. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  2313. //>>excludeEnd("ctx");
  2314. }));
  2315. (
  2316. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2317. $ctx1.supercall = true,
  2318. //>>excludeEnd("ctx");
  2319. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitMethodNode_.apply($self, [aNode]));
  2320. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2321. $ctx1.supercall = false;
  2322. //>>excludeEnd("ctx");;
  2323. $recv(aNode)._classReferences_($self._classReferences());
  2324. $recv(aNode)._sendIndexes_($self._messageSends());
  2325. $self._popScope();
  2326. return aNode;
  2327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2328. }, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode})});
  2329. //>>excludeEnd("ctx");
  2330. },
  2331. //>>excludeStart("ide", pragmas.excludeIdeData);
  2332. args: ["aNode"],
  2333. 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",
  2334. referencedClasses: [],
  2335. //>>excludeEnd("ide");
  2336. pragmas: [],
  2337. messageSends: ["pushScope:", "newMethodScope", "scope:", "node:", "do:", "allInstanceVariableNames", "theClass", "addIVar:", "arguments", "validateVariableScope:", "addArg:", "visitMethodNode:", "classReferences:", "classReferences", "sendIndexes:", "messageSends", "popScope"]
  2338. }),
  2339. $globals.SemanticAnalyzer);
  2340. $core.addMethod(
  2341. $core.method({
  2342. selector: "visitReturnNode:",
  2343. protocol: "visiting",
  2344. fn: function (aNode){
  2345. var self=this,$self=this;
  2346. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2347. return $core.withContext(function($ctx1) {
  2348. //>>excludeEnd("ctx");
  2349. var $1;
  2350. $recv(aNode)._scope_($self.currentScope);
  2351. $1=$recv($self.currentScope)._isMethodScope();
  2352. if($core.assert($1)){
  2353. $recv($self.currentScope)._localReturn_(true);
  2354. } else {
  2355. $recv($recv($self.currentScope)._methodScope())._addNonLocalReturn_($self.currentScope);
  2356. }
  2357. (
  2358. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2359. $ctx1.supercall = true,
  2360. //>>excludeEnd("ctx");
  2361. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitReturnNode_.apply($self, [aNode]));
  2362. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2363. $ctx1.supercall = false;
  2364. //>>excludeEnd("ctx");;
  2365. return self;
  2366. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2367. }, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode})});
  2368. //>>excludeEnd("ctx");
  2369. },
  2370. //>>excludeStart("ide", pragmas.excludeIdeData);
  2371. args: ["aNode"],
  2372. 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",
  2373. referencedClasses: [],
  2374. //>>excludeEnd("ide");
  2375. pragmas: [],
  2376. messageSends: ["scope:", "ifTrue:ifFalse:", "isMethodScope", "localReturn:", "addNonLocalReturn:", "methodScope", "visitReturnNode:"]
  2377. }),
  2378. $globals.SemanticAnalyzer);
  2379. $core.addMethod(
  2380. $core.method({
  2381. selector: "visitSendNode:",
  2382. protocol: "visiting",
  2383. fn: function (aNode){
  2384. var self=this,$self=this;
  2385. var sends;
  2386. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2387. return $core.withContext(function($ctx1) {
  2388. //>>excludeEnd("ctx");
  2389. sends=$recv($self._messageSends())._at_ifAbsentPut_($recv(aNode)._selector(),(function(){
  2390. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2391. return $core.withContext(function($ctx2) {
  2392. //>>excludeEnd("ctx");
  2393. return $recv($globals.OrderedCollection)._new();
  2394. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2395. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2396. //>>excludeEnd("ctx");
  2397. }));
  2398. $recv(sends)._add_(aNode);
  2399. $recv(aNode)._index_($recv(sends)._size());
  2400. (
  2401. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2402. $ctx1.supercall = true,
  2403. //>>excludeEnd("ctx");
  2404. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitSendNode_.apply($self, [aNode]));
  2405. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2406. $ctx1.supercall = false;
  2407. //>>excludeEnd("ctx");;
  2408. return self;
  2409. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2410. }, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode,sends:sends})});
  2411. //>>excludeEnd("ctx");
  2412. },
  2413. //>>excludeStart("ide", pragmas.excludeIdeData);
  2414. args: ["aNode"],
  2415. 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",
  2416. referencedClasses: ["OrderedCollection"],
  2417. //>>excludeEnd("ide");
  2418. pragmas: [],
  2419. messageSends: ["at:ifAbsentPut:", "messageSends", "selector", "new", "add:", "index:", "size", "visitSendNode:"]
  2420. }),
  2421. $globals.SemanticAnalyzer);
  2422. $core.addMethod(
  2423. $core.method({
  2424. selector: "visitSequenceNode:",
  2425. protocol: "visiting",
  2426. fn: function (aNode){
  2427. var self=this,$self=this;
  2428. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2429. return $core.withContext(function($ctx1) {
  2430. //>>excludeEnd("ctx");
  2431. $recv($recv(aNode)._temps())._do_((function(each){
  2432. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2433. return $core.withContext(function($ctx2) {
  2434. //>>excludeEnd("ctx");
  2435. $self._validateVariableScope_(each);
  2436. return $recv($self.currentScope)._addTemp_(each);
  2437. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2438. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2439. //>>excludeEnd("ctx");
  2440. }));
  2441. (
  2442. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2443. $ctx1.supercall = true,
  2444. //>>excludeEnd("ctx");
  2445. ($globals.SemanticAnalyzer.superclass||$boot.nilAsClass).fn.prototype._visitSequenceNode_.apply($self, [aNode]));
  2446. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2447. $ctx1.supercall = false;
  2448. //>>excludeEnd("ctx");;
  2449. return self;
  2450. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2451. }, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode})});
  2452. //>>excludeEnd("ctx");
  2453. },
  2454. //>>excludeStart("ide", pragmas.excludeIdeData);
  2455. args: ["aNode"],
  2456. source: "visitSequenceNode: aNode\x0a\x09aNode temps do: [ :each |\x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addTemp: each ].\x0a\x0a\x09super visitSequenceNode: aNode",
  2457. referencedClasses: [],
  2458. //>>excludeEnd("ide");
  2459. pragmas: [],
  2460. messageSends: ["do:", "temps", "validateVariableScope:", "addTemp:", "visitSequenceNode:"]
  2461. }),
  2462. $globals.SemanticAnalyzer);
  2463. $core.addMethod(
  2464. $core.method({
  2465. selector: "visitVariableNode:",
  2466. protocol: "visiting",
  2467. fn: function (aNode){
  2468. var self=this,$self=this;
  2469. var binding;
  2470. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2471. return $core.withContext(function($ctx1) {
  2472. //>>excludeEnd("ctx");
  2473. var $1,$3,$2,$4,$5,$6,$7,$8,$receiver;
  2474. binding=$recv($self.currentScope)._lookupVariable_(aNode);
  2475. $1=binding;
  2476. if(($receiver = $1) == null || $receiver.a$nil){
  2477. $3=$recv(aNode)._value();
  2478. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2479. $ctx1.sendIdx["value"]=1;
  2480. //>>excludeEnd("ctx");
  2481. $2=$recv($3)._isCapitalized();
  2482. if($core.assert($2)){
  2483. $4=$recv($globals.ClassRefVar)._new();
  2484. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2485. $ctx1.sendIdx["new"]=1;
  2486. //>>excludeEnd("ctx");
  2487. $5=$recv(aNode)._value();
  2488. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2489. $ctx1.sendIdx["value"]=2;
  2490. //>>excludeEnd("ctx");
  2491. $recv($4)._name_($5);
  2492. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2493. $ctx1.sendIdx["name:"]=1;
  2494. //>>excludeEnd("ctx");
  2495. binding=$recv($4)._yourself();
  2496. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2497. $ctx1.sendIdx["yourself"]=1;
  2498. //>>excludeEnd("ctx");
  2499. $6=$self._classReferences();
  2500. $7=$recv(aNode)._value();
  2501. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2502. $ctx1.sendIdx["value"]=3;
  2503. //>>excludeEnd("ctx");
  2504. $recv($6)._add_($7);
  2505. } else {
  2506. $self._errorUnknownVariable_(aNode);
  2507. $8=$recv($globals.UnknownVar)._new();
  2508. $recv($8)._name_($recv(aNode)._value());
  2509. binding=$recv($8)._yourself();
  2510. binding;
  2511. }
  2512. } else {
  2513. $1;
  2514. }
  2515. $recv(aNode)._binding_(binding);
  2516. return self;
  2517. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2518. }, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode,binding:binding})});
  2519. //>>excludeEnd("ctx");
  2520. },
  2521. //>>excludeStart("ide", pragmas.excludeIdeData);
  2522. args: ["aNode"],
  2523. 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.",
  2524. referencedClasses: ["ClassRefVar", "UnknownVar"],
  2525. //>>excludeEnd("ide");
  2526. pragmas: [],
  2527. messageSends: ["lookupVariable:", "ifNil:", "ifTrue:ifFalse:", "isCapitalized", "value", "name:", "new", "yourself", "add:", "classReferences", "errorUnknownVariable:", "binding:"]
  2528. }),
  2529. $globals.SemanticAnalyzer);
  2530. $core.addMethod(
  2531. $core.method({
  2532. selector: "on:",
  2533. protocol: "instance creation",
  2534. fn: function (aClass){
  2535. var self=this,$self=this;
  2536. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2537. return $core.withContext(function($ctx1) {
  2538. //>>excludeEnd("ctx");
  2539. var $1;
  2540. $1=$self._new();
  2541. $recv($1)._theClass_(aClass);
  2542. return $recv($1)._yourself();
  2543. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2544. }, function($ctx1) {$ctx1.fill(self,"on:",{aClass:aClass})});
  2545. //>>excludeEnd("ctx");
  2546. },
  2547. //>>excludeStart("ide", pragmas.excludeIdeData);
  2548. args: ["aClass"],
  2549. source: "on: aClass\x0a\x09^ self new\x0a\x09\x09theClass: aClass;\x0a\x09\x09yourself",
  2550. referencedClasses: [],
  2551. //>>excludeEnd("ide");
  2552. pragmas: [],
  2553. messageSends: ["theClass:", "new", "yourself"]
  2554. }),
  2555. $globals.SemanticAnalyzer.a$cls);
  2556. $core.addClass("SemanticError", $globals.CompilerError, [], "Compiler-Semantic");
  2557. //>>excludeStart("ide", pragmas.excludeIdeData);
  2558. $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";
  2559. //>>excludeEnd("ide");
  2560. $core.addClass("InvalidAssignmentError", $globals.SemanticError, ["variableName"], "Compiler-Semantic");
  2561. //>>excludeStart("ide", pragmas.excludeIdeData);
  2562. $globals.InvalidAssignmentError.comment="I get signaled when a pseudo variable gets assigned.";
  2563. //>>excludeEnd("ide");
  2564. $core.addMethod(
  2565. $core.method({
  2566. selector: "messageText",
  2567. protocol: "accessing",
  2568. fn: function (){
  2569. var self=this,$self=this;
  2570. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2571. return $core.withContext(function($ctx1) {
  2572. //>>excludeEnd("ctx");
  2573. return " Invalid assignment to variable: ".__comma($self._variableName());
  2574. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2575. }, function($ctx1) {$ctx1.fill(self,"messageText",{})});
  2576. //>>excludeEnd("ctx");
  2577. },
  2578. //>>excludeStart("ide", pragmas.excludeIdeData);
  2579. args: [],
  2580. source: "messageText\x0a\x09^ ' Invalid assignment to variable: ', self variableName",
  2581. referencedClasses: [],
  2582. //>>excludeEnd("ide");
  2583. pragmas: [],
  2584. messageSends: [",", "variableName"]
  2585. }),
  2586. $globals.InvalidAssignmentError);
  2587. $core.addMethod(
  2588. $core.method({
  2589. selector: "variableName",
  2590. protocol: "accessing",
  2591. fn: function (){
  2592. var self=this,$self=this;
  2593. return $self.variableName;
  2594. },
  2595. //>>excludeStart("ide", pragmas.excludeIdeData);
  2596. args: [],
  2597. source: "variableName\x0a\x09^ variableName",
  2598. referencedClasses: [],
  2599. //>>excludeEnd("ide");
  2600. pragmas: [],
  2601. messageSends: []
  2602. }),
  2603. $globals.InvalidAssignmentError);
  2604. $core.addMethod(
  2605. $core.method({
  2606. selector: "variableName:",
  2607. protocol: "accessing",
  2608. fn: function (aString){
  2609. var self=this,$self=this;
  2610. $self.variableName=aString;
  2611. return self;
  2612. },
  2613. //>>excludeStart("ide", pragmas.excludeIdeData);
  2614. args: ["aString"],
  2615. source: "variableName: aString\x0a\x09variableName := aString",
  2616. referencedClasses: [],
  2617. //>>excludeEnd("ide");
  2618. pragmas: [],
  2619. messageSends: []
  2620. }),
  2621. $globals.InvalidAssignmentError);
  2622. $core.addClass("ShadowingVariableError", $globals.SemanticError, ["variableName"], "Compiler-Semantic");
  2623. //>>excludeStart("ide", pragmas.excludeIdeData);
  2624. $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.";
  2625. //>>excludeEnd("ide");
  2626. $core.addMethod(
  2627. $core.method({
  2628. selector: "messageText",
  2629. protocol: "accessing",
  2630. fn: function (){
  2631. var self=this,$self=this;
  2632. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2633. return $core.withContext(function($ctx1) {
  2634. //>>excludeEnd("ctx");
  2635. var $1;
  2636. $1=$recv("Variable shadowing error: ".__comma($self._variableName())).__comma(" is already defined");
  2637. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2638. $ctx1.sendIdx[","]=1;
  2639. //>>excludeEnd("ctx");
  2640. return $1;
  2641. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2642. }, function($ctx1) {$ctx1.fill(self,"messageText",{})});
  2643. //>>excludeEnd("ctx");
  2644. },
  2645. //>>excludeStart("ide", pragmas.excludeIdeData);
  2646. args: [],
  2647. source: "messageText\x0a\x09^ 'Variable shadowing error: ', self variableName, ' is already defined'",
  2648. referencedClasses: [],
  2649. //>>excludeEnd("ide");
  2650. pragmas: [],
  2651. messageSends: [",", "variableName"]
  2652. }),
  2653. $globals.ShadowingVariableError);
  2654. $core.addMethod(
  2655. $core.method({
  2656. selector: "variableName",
  2657. protocol: "accessing",
  2658. fn: function (){
  2659. var self=this,$self=this;
  2660. return $self.variableName;
  2661. },
  2662. //>>excludeStart("ide", pragmas.excludeIdeData);
  2663. args: [],
  2664. source: "variableName\x0a\x09^ variableName",
  2665. referencedClasses: [],
  2666. //>>excludeEnd("ide");
  2667. pragmas: [],
  2668. messageSends: []
  2669. }),
  2670. $globals.ShadowingVariableError);
  2671. $core.addMethod(
  2672. $core.method({
  2673. selector: "variableName:",
  2674. protocol: "accessing",
  2675. fn: function (aString){
  2676. var self=this,$self=this;
  2677. $self.variableName=aString;
  2678. return self;
  2679. },
  2680. //>>excludeStart("ide", pragmas.excludeIdeData);
  2681. args: ["aString"],
  2682. source: "variableName: aString\x0a\x09variableName := aString",
  2683. referencedClasses: [],
  2684. //>>excludeEnd("ide");
  2685. pragmas: [],
  2686. messageSends: []
  2687. }),
  2688. $globals.ShadowingVariableError);
  2689. $core.addClass("UnknownVariableError", $globals.SemanticError, ["variableName"], "Compiler-Semantic");
  2690. //>>excludeStart("ide", pragmas.excludeIdeData);
  2691. $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.";
  2692. //>>excludeEnd("ide");
  2693. $core.addMethod(
  2694. $core.method({
  2695. selector: "messageText",
  2696. protocol: "accessing",
  2697. fn: function (){
  2698. var self=this,$self=this;
  2699. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2700. return $core.withContext(function($ctx1) {
  2701. //>>excludeEnd("ctx");
  2702. var $1;
  2703. $1=$recv("Unknown Variable error: ".__comma($self._variableName())).__comma(" is not defined");
  2704. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2705. $ctx1.sendIdx[","]=1;
  2706. //>>excludeEnd("ctx");
  2707. return $1;
  2708. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2709. }, function($ctx1) {$ctx1.fill(self,"messageText",{})});
  2710. //>>excludeEnd("ctx");
  2711. },
  2712. //>>excludeStart("ide", pragmas.excludeIdeData);
  2713. args: [],
  2714. source: "messageText\x0a\x09^ 'Unknown Variable error: ', self variableName, ' is not defined'",
  2715. referencedClasses: [],
  2716. //>>excludeEnd("ide");
  2717. pragmas: [],
  2718. messageSends: [",", "variableName"]
  2719. }),
  2720. $globals.UnknownVariableError);
  2721. $core.addMethod(
  2722. $core.method({
  2723. selector: "variableName",
  2724. protocol: "accessing",
  2725. fn: function (){
  2726. var self=this,$self=this;
  2727. return $self.variableName;
  2728. },
  2729. //>>excludeStart("ide", pragmas.excludeIdeData);
  2730. args: [],
  2731. source: "variableName\x0a\x09^ variableName",
  2732. referencedClasses: [],
  2733. //>>excludeEnd("ide");
  2734. pragmas: [],
  2735. messageSends: []
  2736. }),
  2737. $globals.UnknownVariableError);
  2738. $core.addMethod(
  2739. $core.method({
  2740. selector: "variableName:",
  2741. protocol: "accessing",
  2742. fn: function (aString){
  2743. var self=this,$self=this;
  2744. $self.variableName=aString;
  2745. return self;
  2746. },
  2747. //>>excludeStart("ide", pragmas.excludeIdeData);
  2748. args: ["aString"],
  2749. source: "variableName: aString\x0a\x09variableName := aString",
  2750. referencedClasses: [],
  2751. //>>excludeEnd("ide");
  2752. pragmas: [],
  2753. messageSends: []
  2754. }),
  2755. $globals.UnknownVariableError);
  2756. });