Compiler-Semantic.js 84 KB

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