Compiler-Semantic.js 85 KB

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