1
0

Compiler-Semantic.js 91 KB

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