1
0

Compiler-Semantic.js 85 KB

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