1
0

Compiler-Semantic.js 86 KB

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