Compiler-Semantic.js 82 KB

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