Compiler-Semantic.js 84 KB

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