Compiler-Semantic.js 87 KB

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