1
0

Compiler-Semantic.js 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974
  1. define("amber_core/Compiler-Semantic", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects", "amber_core/Compiler-Core"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Compiler-Semantic');
  3. smalltalk.packages["Compiler-Semantic"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('LexicalScope', smalltalk.Object, ['node', 'instruction', 'temps', 'args', 'outerScope', 'blockIndex'], 'Compiler-Semantic');
  5. smalltalk.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.";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "addArg:",
  9. category: 'adding',
  10. fn: function (aString){
  11. var self=this;
  12. function $ArgVar(){return smalltalk.ArgVar||(typeof ArgVar=="undefined"?nil:ArgVar)}
  13. return smalltalk.withContext(function($ctx1) {
  14. var $1,$3,$2;
  15. $1=self._args();
  16. $ctx1.sendIdx["args"]=1;
  17. _st($1)._at_put_(aString,_st($ArgVar())._on_(aString));
  18. $3=self._args();
  19. $2=_st($3)._at_(aString);
  20. _st($2)._scope_(self);
  21. return self}, function($ctx1) {$ctx1.fill(self,"addArg:",{aString:aString},smalltalk.LexicalScope)})},
  22. args: ["aString"],
  23. source: "addArg: aString\x0a\x09self args at: aString put: (ArgVar on: aString).\x0a\x09(self args at: aString) scope: self",
  24. messageSends: ["at:put:", "args", "on:", "scope:", "at:"],
  25. referencedClasses: ["ArgVar"]
  26. }),
  27. smalltalk.LexicalScope);
  28. smalltalk.addMethod(
  29. smalltalk.method({
  30. selector: "addTemp:",
  31. category: 'adding',
  32. fn: function (aString){
  33. var self=this;
  34. function $TempVar(){return smalltalk.TempVar||(typeof TempVar=="undefined"?nil:TempVar)}
  35. return smalltalk.withContext(function($ctx1) {
  36. var $1,$3,$2;
  37. $1=self._temps();
  38. $ctx1.sendIdx["temps"]=1;
  39. _st($1)._at_put_(aString,_st($TempVar())._on_(aString));
  40. $3=self._temps();
  41. $2=_st($3)._at_(aString);
  42. _st($2)._scope_(self);
  43. return self}, function($ctx1) {$ctx1.fill(self,"addTemp:",{aString:aString},smalltalk.LexicalScope)})},
  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. messageSends: ["at:put:", "temps", "on:", "scope:", "at:"],
  47. referencedClasses: ["TempVar"]
  48. }),
  49. smalltalk.LexicalScope);
  50. smalltalk.addMethod(
  51. smalltalk.method({
  52. selector: "alias",
  53. category: 'accessing',
  54. fn: function (){
  55. var self=this;
  56. return smalltalk.withContext(function($ctx1) {
  57. var $1;
  58. $1="$ctx".__comma(_st(self._scopeLevel())._asString());
  59. return $1;
  60. }, function($ctx1) {$ctx1.fill(self,"alias",{},smalltalk.LexicalScope)})},
  61. args: [],
  62. source: "alias\x0a\x09^ '$ctx', self scopeLevel asString",
  63. messageSends: [",", "asString", "scopeLevel"],
  64. referencedClasses: []
  65. }),
  66. smalltalk.LexicalScope);
  67. smalltalk.addMethod(
  68. smalltalk.method({
  69. selector: "allVariableNames",
  70. category: 'accessing',
  71. fn: function (){
  72. var self=this;
  73. return smalltalk.withContext(function($ctx1) {
  74. var $2,$3,$1;
  75. $2=_st(self._args())._keys();
  76. $ctx1.sendIdx["keys"]=1;
  77. $3=_st(self._temps())._keys();
  78. $1=_st($2).__comma($3);
  79. return $1;
  80. }, function($ctx1) {$ctx1.fill(self,"allVariableNames",{},smalltalk.LexicalScope)})},
  81. args: [],
  82. source: "allVariableNames\x0a\x09^ self args keys, self temps keys",
  83. messageSends: [",", "keys", "args", "temps"],
  84. referencedClasses: []
  85. }),
  86. smalltalk.LexicalScope);
  87. smalltalk.addMethod(
  88. smalltalk.method({
  89. selector: "args",
  90. category: 'accessing',
  91. fn: function (){
  92. var self=this;
  93. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  94. return smalltalk.withContext(function($ctx1) {
  95. var $1;
  96. if(($receiver = self["@args"]) == nil || $receiver == null){
  97. self["@args"]=_st($Dictionary())._new();
  98. $1=self["@args"];
  99. } else {
  100. $1=self["@args"];
  101. };
  102. return $1;
  103. }, function($ctx1) {$ctx1.fill(self,"args",{},smalltalk.LexicalScope)})},
  104. args: [],
  105. source: "args\x0a\x09^ args ifNil: [ args := Dictionary new ]",
  106. messageSends: ["ifNil:", "new"],
  107. referencedClasses: ["Dictionary"]
  108. }),
  109. smalltalk.LexicalScope);
  110. smalltalk.addMethod(
  111. smalltalk.method({
  112. selector: "bindingFor:",
  113. category: 'accessing',
  114. fn: function (aStringOrNode){
  115. var self=this;
  116. return smalltalk.withContext(function($ctx1) {
  117. var $2,$3,$4,$5,$6,$7,$1;
  118. $2=self._pseudoVars();
  119. $3=_st(aStringOrNode)._value();
  120. $ctx1.sendIdx["value"]=1;
  121. $1=_st($2)._at_ifAbsent_($3,(function(){
  122. return smalltalk.withContext(function($ctx2) {
  123. $4=self._args();
  124. $5=_st(aStringOrNode)._value();
  125. $ctx2.sendIdx["value"]=2;
  126. return _st($4)._at_ifAbsent_($5,(function(){
  127. return smalltalk.withContext(function($ctx3) {
  128. $6=self._temps();
  129. $7=_st(aStringOrNode)._value();
  130. return _st($6)._at_ifAbsent_($7,(function(){
  131. return smalltalk.withContext(function($ctx4) {
  132. return nil;
  133. }, function($ctx4) {$ctx4.fillBlock({},$ctx3,3)})}));
  134. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  135. $ctx2.sendIdx["at:ifAbsent:"]=2;
  136. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  137. $ctx1.sendIdx["at:ifAbsent:"]=1;
  138. return $1;
  139. }, function($ctx1) {$ctx1.fill(self,"bindingFor:",{aStringOrNode:aStringOrNode},smalltalk.LexicalScope)})},
  140. args: ["aStringOrNode"],
  141. 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 ]]]",
  142. messageSends: ["at:ifAbsent:", "pseudoVars", "value", "args", "temps"],
  143. referencedClasses: []
  144. }),
  145. smalltalk.LexicalScope);
  146. smalltalk.addMethod(
  147. smalltalk.method({
  148. selector: "blockIndex",
  149. category: 'accessing',
  150. fn: function (){
  151. var self=this;
  152. return smalltalk.withContext(function($ctx1) {
  153. var $1;
  154. if(($receiver = self["@blockIndex"]) == nil || $receiver == null){
  155. $1=(0);
  156. } else {
  157. $1=self["@blockIndex"];
  158. };
  159. return $1;
  160. }, function($ctx1) {$ctx1.fill(self,"blockIndex",{},smalltalk.LexicalScope)})},
  161. args: [],
  162. source: "blockIndex\x0a\x09^ blockIndex ifNil: [ 0 ]",
  163. messageSends: ["ifNil:"],
  164. referencedClasses: []
  165. }),
  166. smalltalk.LexicalScope);
  167. smalltalk.addMethod(
  168. smalltalk.method({
  169. selector: "blockIndex:",
  170. category: 'accessing',
  171. fn: function (anInteger){
  172. var self=this;
  173. return smalltalk.withContext(function($ctx1) {
  174. self["@blockIndex"]=anInteger;
  175. return self}, function($ctx1) {$ctx1.fill(self,"blockIndex:",{anInteger:anInteger},smalltalk.LexicalScope)})},
  176. args: ["anInteger"],
  177. source: "blockIndex: anInteger \x0a\x09blockIndex := anInteger",
  178. messageSends: [],
  179. referencedClasses: []
  180. }),
  181. smalltalk.LexicalScope);
  182. smalltalk.addMethod(
  183. smalltalk.method({
  184. selector: "canInlineNonLocalReturns",
  185. category: 'testing',
  186. fn: function (){
  187. var self=this;
  188. return smalltalk.withContext(function($ctx1) {
  189. var $1;
  190. $1=_st(self._isInlined())._and_((function(){
  191. return smalltalk.withContext(function($ctx2) {
  192. return _st(self._outerScope())._canInlineNonLocalReturns();
  193. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  194. return $1;
  195. }, function($ctx1) {$ctx1.fill(self,"canInlineNonLocalReturns",{},smalltalk.LexicalScope)})},
  196. args: [],
  197. source: "canInlineNonLocalReturns\x0a\x09^ self isInlined and: [ self outerScope canInlineNonLocalReturns ]",
  198. messageSends: ["and:", "isInlined", "canInlineNonLocalReturns", "outerScope"],
  199. referencedClasses: []
  200. }),
  201. smalltalk.LexicalScope);
  202. smalltalk.addMethod(
  203. smalltalk.method({
  204. selector: "instruction",
  205. category: 'accessing',
  206. fn: function (){
  207. var self=this;
  208. return smalltalk.withContext(function($ctx1) {
  209. var $1;
  210. $1=self["@instruction"];
  211. return $1;
  212. }, function($ctx1) {$ctx1.fill(self,"instruction",{},smalltalk.LexicalScope)})},
  213. args: [],
  214. source: "instruction\x0a\x09^ instruction",
  215. messageSends: [],
  216. referencedClasses: []
  217. }),
  218. smalltalk.LexicalScope);
  219. smalltalk.addMethod(
  220. smalltalk.method({
  221. selector: "instruction:",
  222. category: 'accessing',
  223. fn: function (anIRInstruction){
  224. var self=this;
  225. return smalltalk.withContext(function($ctx1) {
  226. self["@instruction"]=anIRInstruction;
  227. return self}, function($ctx1) {$ctx1.fill(self,"instruction:",{anIRInstruction:anIRInstruction},smalltalk.LexicalScope)})},
  228. args: ["anIRInstruction"],
  229. source: "instruction: anIRInstruction\x0a\x09instruction := anIRInstruction",
  230. messageSends: [],
  231. referencedClasses: []
  232. }),
  233. smalltalk.LexicalScope);
  234. smalltalk.addMethod(
  235. smalltalk.method({
  236. selector: "isBlockScope",
  237. category: 'testing',
  238. fn: function (){
  239. var self=this;
  240. return smalltalk.withContext(function($ctx1) {
  241. var $1;
  242. $1=_st(self._isMethodScope())._not();
  243. return $1;
  244. }, function($ctx1) {$ctx1.fill(self,"isBlockScope",{},smalltalk.LexicalScope)})},
  245. args: [],
  246. source: "isBlockScope\x0a\x09^ self isMethodScope not",
  247. messageSends: ["not", "isMethodScope"],
  248. referencedClasses: []
  249. }),
  250. smalltalk.LexicalScope);
  251. smalltalk.addMethod(
  252. smalltalk.method({
  253. selector: "isInlined",
  254. category: 'testing',
  255. fn: function (){
  256. var self=this;
  257. return smalltalk.withContext(function($ctx1) {
  258. var $3,$2,$4,$1;
  259. $3=self._instruction();
  260. $ctx1.sendIdx["instruction"]=1;
  261. $2=_st($3)._notNil();
  262. $1=_st($2)._and_((function(){
  263. return smalltalk.withContext(function($ctx2) {
  264. $4=self._instruction();
  265. return _st($4)._isInlined();
  266. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  267. return $1;
  268. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},smalltalk.LexicalScope)})},
  269. args: [],
  270. source: "isInlined\x0a\x09^ self instruction notNil and: [\x0a\x09\x09self instruction isInlined ]",
  271. messageSends: ["and:", "notNil", "instruction", "isInlined"],
  272. referencedClasses: []
  273. }),
  274. smalltalk.LexicalScope);
  275. smalltalk.addMethod(
  276. smalltalk.method({
  277. selector: "isMethodScope",
  278. category: 'testing',
  279. fn: function (){
  280. var self=this;
  281. return smalltalk.withContext(function($ctx1) {
  282. return false;
  283. }, function($ctx1) {$ctx1.fill(self,"isMethodScope",{},smalltalk.LexicalScope)})},
  284. args: [],
  285. source: "isMethodScope\x0a\x09^ false",
  286. messageSends: [],
  287. referencedClasses: []
  288. }),
  289. smalltalk.LexicalScope);
  290. smalltalk.addMethod(
  291. smalltalk.method({
  292. selector: "lookupVariable:",
  293. category: 'accessing',
  294. fn: function (aNode){
  295. var self=this;
  296. var lookup;
  297. return smalltalk.withContext(function($ctx1) {
  298. var $1,$2,$3;
  299. lookup=self._bindingFor_(aNode);
  300. if(($receiver = lookup) == nil || $receiver == null){
  301. $1=self._outerScope();
  302. $ctx1.sendIdx["outerScope"]=1;
  303. if(($receiver = $1) == nil || $receiver == null){
  304. lookup=$1;
  305. } else {
  306. $2=self._outerScope();
  307. lookup=_st($2)._lookupVariable_(aNode);
  308. };
  309. lookup;
  310. } else {
  311. lookup;
  312. };
  313. $3=lookup;
  314. return $3;
  315. }, function($ctx1) {$ctx1.fill(self,"lookupVariable:",{aNode:aNode,lookup:lookup},smalltalk.LexicalScope)})},
  316. args: ["aNode"],
  317. 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",
  318. messageSends: ["bindingFor:", "ifNil:", "ifNotNil:", "outerScope", "lookupVariable:"],
  319. referencedClasses: []
  320. }),
  321. smalltalk.LexicalScope);
  322. smalltalk.addMethod(
  323. smalltalk.method({
  324. selector: "methodScope",
  325. category: 'accessing',
  326. fn: function (){
  327. var self=this;
  328. return smalltalk.withContext(function($ctx1) {
  329. var $2,$3,$1;
  330. $2=self._outerScope();
  331. $ctx1.sendIdx["outerScope"]=1;
  332. if(($receiver = $2) == nil || $receiver == null){
  333. $1=$2;
  334. } else {
  335. $3=self._outerScope();
  336. $1=_st($3)._methodScope();
  337. };
  338. return $1;
  339. }, function($ctx1) {$ctx1.fill(self,"methodScope",{},smalltalk.LexicalScope)})},
  340. args: [],
  341. source: "methodScope\x0a\x09^ self outerScope ifNotNil: [\x0a\x09\x09self outerScope methodScope ]",
  342. messageSends: ["ifNotNil:", "outerScope", "methodScope"],
  343. referencedClasses: []
  344. }),
  345. smalltalk.LexicalScope);
  346. smalltalk.addMethod(
  347. smalltalk.method({
  348. selector: "node",
  349. category: 'accessing',
  350. fn: function (){
  351. var self=this;
  352. return smalltalk.withContext(function($ctx1) {
  353. var $1;
  354. $1=self["@node"];
  355. return $1;
  356. }, function($ctx1) {$ctx1.fill(self,"node",{},smalltalk.LexicalScope)})},
  357. args: [],
  358. source: "node\x0a\x09\x22Answer the node in which I am defined\x22\x0a\x09\x0a\x09^ node",
  359. messageSends: [],
  360. referencedClasses: []
  361. }),
  362. smalltalk.LexicalScope);
  363. smalltalk.addMethod(
  364. smalltalk.method({
  365. selector: "node:",
  366. category: 'accessing',
  367. fn: function (aNode){
  368. var self=this;
  369. return smalltalk.withContext(function($ctx1) {
  370. self["@node"]=aNode;
  371. return self}, function($ctx1) {$ctx1.fill(self,"node:",{aNode:aNode},smalltalk.LexicalScope)})},
  372. args: ["aNode"],
  373. source: "node: aNode\x0a\x09node := aNode",
  374. messageSends: [],
  375. referencedClasses: []
  376. }),
  377. smalltalk.LexicalScope);
  378. smalltalk.addMethod(
  379. smalltalk.method({
  380. selector: "outerScope",
  381. category: 'accessing',
  382. fn: function (){
  383. var self=this;
  384. return smalltalk.withContext(function($ctx1) {
  385. var $1;
  386. $1=self["@outerScope"];
  387. return $1;
  388. }, function($ctx1) {$ctx1.fill(self,"outerScope",{},smalltalk.LexicalScope)})},
  389. args: [],
  390. source: "outerScope\x0a\x09^ outerScope",
  391. messageSends: [],
  392. referencedClasses: []
  393. }),
  394. smalltalk.LexicalScope);
  395. smalltalk.addMethod(
  396. smalltalk.method({
  397. selector: "outerScope:",
  398. category: 'accessing',
  399. fn: function (aLexicalScope){
  400. var self=this;
  401. return smalltalk.withContext(function($ctx1) {
  402. self["@outerScope"]=aLexicalScope;
  403. return self}, function($ctx1) {$ctx1.fill(self,"outerScope:",{aLexicalScope:aLexicalScope},smalltalk.LexicalScope)})},
  404. args: ["aLexicalScope"],
  405. source: "outerScope: aLexicalScope\x0a\x09outerScope := aLexicalScope",
  406. messageSends: [],
  407. referencedClasses: []
  408. }),
  409. smalltalk.LexicalScope);
  410. smalltalk.addMethod(
  411. smalltalk.method({
  412. selector: "pseudoVars",
  413. category: 'accessing',
  414. fn: function (){
  415. var self=this;
  416. return smalltalk.withContext(function($ctx1) {
  417. var $1;
  418. $1=_st(self._methodScope())._pseudoVars();
  419. return $1;
  420. }, function($ctx1) {$ctx1.fill(self,"pseudoVars",{},smalltalk.LexicalScope)})},
  421. args: [],
  422. source: "pseudoVars\x0a\x09^ self methodScope pseudoVars",
  423. messageSends: ["pseudoVars", "methodScope"],
  424. referencedClasses: []
  425. }),
  426. smalltalk.LexicalScope);
  427. smalltalk.addMethod(
  428. smalltalk.method({
  429. selector: "scopeLevel",
  430. category: 'accessing',
  431. fn: function (){
  432. var self=this;
  433. return smalltalk.withContext(function($ctx1) {
  434. var $1,$3,$2,$6,$5,$4;
  435. $1=self._outerScope();
  436. $ctx1.sendIdx["outerScope"]=1;
  437. if(($receiver = $1) == nil || $receiver == null){
  438. return (1);
  439. } else {
  440. $1;
  441. };
  442. if(smalltalk.assert(self._isInlined())){
  443. $3=self._outerScope();
  444. $ctx1.sendIdx["outerScope"]=2;
  445. $2=_st($3)._scopeLevel();
  446. $ctx1.sendIdx["scopeLevel"]=1;
  447. return $2;
  448. };
  449. $6=self._outerScope();
  450. $5=_st($6)._scopeLevel();
  451. $4=_st($5).__plus((1));
  452. return $4;
  453. }, function($ctx1) {$ctx1.fill(self,"scopeLevel",{},smalltalk.LexicalScope)})},
  454. args: [],
  455. source: "scopeLevel\x0a\x09self outerScope ifNil: [ ^ 1 ].\x0a\x09self isInlined ifTrue: [ ^ self outerScope scopeLevel ].\x0a\x09\x0a\x09^ self outerScope scopeLevel + 1",
  456. messageSends: ["ifNil:", "outerScope", "ifTrue:", "isInlined", "scopeLevel", "+"],
  457. referencedClasses: []
  458. }),
  459. smalltalk.LexicalScope);
  460. smalltalk.addMethod(
  461. smalltalk.method({
  462. selector: "temps",
  463. category: 'accessing',
  464. fn: function (){
  465. var self=this;
  466. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  467. return smalltalk.withContext(function($ctx1) {
  468. var $1;
  469. if(($receiver = self["@temps"]) == nil || $receiver == null){
  470. self["@temps"]=_st($Dictionary())._new();
  471. $1=self["@temps"];
  472. } else {
  473. $1=self["@temps"];
  474. };
  475. return $1;
  476. }, function($ctx1) {$ctx1.fill(self,"temps",{},smalltalk.LexicalScope)})},
  477. args: [],
  478. source: "temps\x0a\x09^ temps ifNil: [ temps := Dictionary new ]",
  479. messageSends: ["ifNil:", "new"],
  480. referencedClasses: ["Dictionary"]
  481. }),
  482. smalltalk.LexicalScope);
  483. smalltalk.addClass('MethodLexicalScope', smalltalk.LexicalScope, ['iVars', 'pseudoVars', 'unknownVariables', 'localReturn', 'nonLocalReturns'], 'Compiler-Semantic');
  484. smalltalk.MethodLexicalScope.comment="I represent a method scope.";
  485. smalltalk.addMethod(
  486. smalltalk.method({
  487. selector: "addIVar:",
  488. category: 'adding',
  489. fn: function (aString){
  490. var self=this;
  491. function $InstanceVar(){return smalltalk.InstanceVar||(typeof InstanceVar=="undefined"?nil:InstanceVar)}
  492. return smalltalk.withContext(function($ctx1) {
  493. var $1,$3,$2;
  494. $1=self._iVars();
  495. $ctx1.sendIdx["iVars"]=1;
  496. _st($1)._at_put_(aString,_st($InstanceVar())._on_(aString));
  497. $3=self._iVars();
  498. $2=_st($3)._at_(aString);
  499. _st($2)._scope_(self);
  500. return self}, function($ctx1) {$ctx1.fill(self,"addIVar:",{aString:aString},smalltalk.MethodLexicalScope)})},
  501. args: ["aString"],
  502. source: "addIVar: aString\x0a\x09self iVars at: aString put: (InstanceVar on: aString).\x0a\x09(self iVars at: aString) scope: self",
  503. messageSends: ["at:put:", "iVars", "on:", "scope:", "at:"],
  504. referencedClasses: ["InstanceVar"]
  505. }),
  506. smalltalk.MethodLexicalScope);
  507. smalltalk.addMethod(
  508. smalltalk.method({
  509. selector: "addNonLocalReturn:",
  510. category: 'adding',
  511. fn: function (aScope){
  512. var self=this;
  513. return smalltalk.withContext(function($ctx1) {
  514. _st(self._nonLocalReturns())._add_(aScope);
  515. return self}, function($ctx1) {$ctx1.fill(self,"addNonLocalReturn:",{aScope:aScope},smalltalk.MethodLexicalScope)})},
  516. args: ["aScope"],
  517. source: "addNonLocalReturn: aScope\x0a\x09self nonLocalReturns add: aScope",
  518. messageSends: ["add:", "nonLocalReturns"],
  519. referencedClasses: []
  520. }),
  521. smalltalk.MethodLexicalScope);
  522. smalltalk.addMethod(
  523. smalltalk.method({
  524. selector: "allVariableNames",
  525. category: 'accessing',
  526. fn: function (){
  527. var self=this;
  528. return smalltalk.withContext(function($ctx1) {
  529. var $1;
  530. $1=_st(smalltalk.MethodLexicalScope.superclass.fn.prototype._allVariableNames.apply(_st(self), [])).__comma(_st(self._iVars())._keys());
  531. return $1;
  532. }, function($ctx1) {$ctx1.fill(self,"allVariableNames",{},smalltalk.MethodLexicalScope)})},
  533. args: [],
  534. source: "allVariableNames\x0a\x09^ super allVariableNames, self iVars keys",
  535. messageSends: [",", "allVariableNames", "keys", "iVars"],
  536. referencedClasses: []
  537. }),
  538. smalltalk.MethodLexicalScope);
  539. smalltalk.addMethod(
  540. smalltalk.method({
  541. selector: "bindingFor:",
  542. category: 'accessing',
  543. fn: function (aNode){
  544. var self=this;
  545. return smalltalk.withContext(function($ctx1) {
  546. var $1;
  547. if(($receiver = smalltalk.MethodLexicalScope.superclass.fn.prototype._bindingFor_.apply(_st(self), [aNode])) == nil || $receiver == null){
  548. $1=_st(self._iVars())._at_ifAbsent_(_st(aNode)._value(),(function(){
  549. return smalltalk.withContext(function($ctx2) {
  550. return nil;
  551. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  552. } else {
  553. $1=smalltalk.MethodLexicalScope.superclass.fn.prototype._bindingFor_.apply(_st(self), [aNode]);
  554. };
  555. return $1;
  556. }, function($ctx1) {$ctx1.fill(self,"bindingFor:",{aNode:aNode},smalltalk.MethodLexicalScope)})},
  557. args: ["aNode"],
  558. source: "bindingFor: aNode\x0a\x09^ (super bindingFor: aNode) ifNil: [\x0a\x09\x09self iVars at: aNode value ifAbsent: [ nil ]]",
  559. messageSends: ["ifNil:", "bindingFor:", "at:ifAbsent:", "iVars", "value"],
  560. referencedClasses: []
  561. }),
  562. smalltalk.MethodLexicalScope);
  563. smalltalk.addMethod(
  564. smalltalk.method({
  565. selector: "canInlineNonLocalReturns",
  566. category: 'testing',
  567. fn: function (){
  568. var self=this;
  569. return smalltalk.withContext(function($ctx1) {
  570. return true;
  571. }, function($ctx1) {$ctx1.fill(self,"canInlineNonLocalReturns",{},smalltalk.MethodLexicalScope)})},
  572. args: [],
  573. source: "canInlineNonLocalReturns\x0a\x09^ true",
  574. messageSends: [],
  575. referencedClasses: []
  576. }),
  577. smalltalk.MethodLexicalScope);
  578. smalltalk.addMethod(
  579. smalltalk.method({
  580. selector: "hasLocalReturn",
  581. category: 'testing',
  582. fn: function (){
  583. var self=this;
  584. return smalltalk.withContext(function($ctx1) {
  585. var $1;
  586. $1=self._localReturn();
  587. return $1;
  588. }, function($ctx1) {$ctx1.fill(self,"hasLocalReturn",{},smalltalk.MethodLexicalScope)})},
  589. args: [],
  590. source: "hasLocalReturn\x0a\x09^ self localReturn",
  591. messageSends: ["localReturn"],
  592. referencedClasses: []
  593. }),
  594. smalltalk.MethodLexicalScope);
  595. smalltalk.addMethod(
  596. smalltalk.method({
  597. selector: "hasNonLocalReturn",
  598. category: 'testing',
  599. fn: function (){
  600. var self=this;
  601. return smalltalk.withContext(function($ctx1) {
  602. var $1;
  603. $1=_st(self._nonLocalReturns())._notEmpty();
  604. return $1;
  605. }, function($ctx1) {$ctx1.fill(self,"hasNonLocalReturn",{},smalltalk.MethodLexicalScope)})},
  606. args: [],
  607. source: "hasNonLocalReturn\x0a\x09^ self nonLocalReturns notEmpty",
  608. messageSends: ["notEmpty", "nonLocalReturns"],
  609. referencedClasses: []
  610. }),
  611. smalltalk.MethodLexicalScope);
  612. smalltalk.addMethod(
  613. smalltalk.method({
  614. selector: "iVars",
  615. category: 'accessing',
  616. fn: function (){
  617. var self=this;
  618. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  619. return smalltalk.withContext(function($ctx1) {
  620. var $1;
  621. if(($receiver = self["@iVars"]) == nil || $receiver == null){
  622. self["@iVars"]=_st($Dictionary())._new();
  623. $1=self["@iVars"];
  624. } else {
  625. $1=self["@iVars"];
  626. };
  627. return $1;
  628. }, function($ctx1) {$ctx1.fill(self,"iVars",{},smalltalk.MethodLexicalScope)})},
  629. args: [],
  630. source: "iVars\x0a\x09^ iVars ifNil: [ iVars := Dictionary new ]",
  631. messageSends: ["ifNil:", "new"],
  632. referencedClasses: ["Dictionary"]
  633. }),
  634. smalltalk.MethodLexicalScope);
  635. smalltalk.addMethod(
  636. smalltalk.method({
  637. selector: "isMethodScope",
  638. category: 'testing',
  639. fn: function (){
  640. var self=this;
  641. return smalltalk.withContext(function($ctx1) {
  642. return true;
  643. }, function($ctx1) {$ctx1.fill(self,"isMethodScope",{},smalltalk.MethodLexicalScope)})},
  644. args: [],
  645. source: "isMethodScope\x0a\x09^ true",
  646. messageSends: [],
  647. referencedClasses: []
  648. }),
  649. smalltalk.MethodLexicalScope);
  650. smalltalk.addMethod(
  651. smalltalk.method({
  652. selector: "localReturn",
  653. category: 'accessing',
  654. fn: function (){
  655. var self=this;
  656. return smalltalk.withContext(function($ctx1) {
  657. var $1;
  658. if(($receiver = self["@localReturn"]) == nil || $receiver == null){
  659. $1=false;
  660. } else {
  661. $1=self["@localReturn"];
  662. };
  663. return $1;
  664. }, function($ctx1) {$ctx1.fill(self,"localReturn",{},smalltalk.MethodLexicalScope)})},
  665. args: [],
  666. source: "localReturn\x0a\x09^ localReturn ifNil: [ false ]",
  667. messageSends: ["ifNil:"],
  668. referencedClasses: []
  669. }),
  670. smalltalk.MethodLexicalScope);
  671. smalltalk.addMethod(
  672. smalltalk.method({
  673. selector: "localReturn:",
  674. category: 'accessing',
  675. fn: function (aBoolean){
  676. var self=this;
  677. return smalltalk.withContext(function($ctx1) {
  678. self["@localReturn"]=aBoolean;
  679. return self}, function($ctx1) {$ctx1.fill(self,"localReturn:",{aBoolean:aBoolean},smalltalk.MethodLexicalScope)})},
  680. args: ["aBoolean"],
  681. source: "localReturn: aBoolean\x0a\x09localReturn := aBoolean",
  682. messageSends: [],
  683. referencedClasses: []
  684. }),
  685. smalltalk.MethodLexicalScope);
  686. smalltalk.addMethod(
  687. smalltalk.method({
  688. selector: "methodScope",
  689. category: 'accessing',
  690. fn: function (){
  691. var self=this;
  692. return smalltalk.withContext(function($ctx1) {
  693. return self;
  694. }, function($ctx1) {$ctx1.fill(self,"methodScope",{},smalltalk.MethodLexicalScope)})},
  695. args: [],
  696. source: "methodScope\x0a\x09^ self",
  697. messageSends: [],
  698. referencedClasses: []
  699. }),
  700. smalltalk.MethodLexicalScope);
  701. smalltalk.addMethod(
  702. smalltalk.method({
  703. selector: "nonLocalReturns",
  704. category: 'accessing',
  705. fn: function (){
  706. var self=this;
  707. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  708. return smalltalk.withContext(function($ctx1) {
  709. var $1;
  710. if(($receiver = self["@nonLocalReturns"]) == nil || $receiver == null){
  711. self["@nonLocalReturns"]=_st($OrderedCollection())._new();
  712. $1=self["@nonLocalReturns"];
  713. } else {
  714. $1=self["@nonLocalReturns"];
  715. };
  716. return $1;
  717. }, function($ctx1) {$ctx1.fill(self,"nonLocalReturns",{},smalltalk.MethodLexicalScope)})},
  718. args: [],
  719. source: "nonLocalReturns\x0a\x09^ nonLocalReturns ifNil: [ nonLocalReturns := OrderedCollection new ]",
  720. messageSends: ["ifNil:", "new"],
  721. referencedClasses: ["OrderedCollection"]
  722. }),
  723. smalltalk.MethodLexicalScope);
  724. smalltalk.addMethod(
  725. smalltalk.method({
  726. selector: "pseudoVars",
  727. category: 'accessing',
  728. fn: function (){
  729. var self=this;
  730. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  731. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  732. function $PseudoVar(){return smalltalk.PseudoVar||(typeof PseudoVar=="undefined"?nil:PseudoVar)}
  733. return smalltalk.withContext(function($ctx1) {
  734. var $1,$2,$3;
  735. if(($receiver = self["@pseudoVars"]) == nil || $receiver == null){
  736. self["@pseudoVars"]=_st($Dictionary())._new();
  737. self["@pseudoVars"];
  738. _st(_st(_st($Smalltalk())._current())._pseudoVariableNames())._do_((function(each){
  739. return smalltalk.withContext(function($ctx2) {
  740. $1=_st($PseudoVar())._on_(each);
  741. _st($1)._scope_(self._methodScope());
  742. $2=_st($1)._yourself();
  743. return _st(self["@pseudoVars"])._at_put_(each,$2);
  744. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  745. } else {
  746. self["@pseudoVars"];
  747. };
  748. $3=self["@pseudoVars"];
  749. return $3;
  750. }, function($ctx1) {$ctx1.fill(self,"pseudoVars",{},smalltalk.MethodLexicalScope)})},
  751. args: [],
  752. source: "pseudoVars\x0a\x09pseudoVars ifNil: [\x0a\x09\x09pseudoVars := Dictionary new.\x0a\x09\x09Smalltalk current pseudoVariableNames do: [ :each |\x0a\x09\x09\x09pseudoVars at: each put: ((PseudoVar on: each)\x0a\x09\x09\x09\x09scope: self methodScope;\x0a\x09\x09\x09\x09yourself) ]].\x0a\x09^ pseudoVars",
  753. messageSends: ["ifNil:", "new", "do:", "pseudoVariableNames", "current", "at:put:", "scope:", "on:", "methodScope", "yourself"],
  754. referencedClasses: ["Dictionary", "Smalltalk", "PseudoVar"]
  755. }),
  756. smalltalk.MethodLexicalScope);
  757. smalltalk.addMethod(
  758. smalltalk.method({
  759. selector: "removeNonLocalReturn:",
  760. category: 'adding',
  761. fn: function (aScope){
  762. var self=this;
  763. return smalltalk.withContext(function($ctx1) {
  764. _st(self._nonLocalReturns())._remove_ifAbsent_(aScope,(function(){
  765. return smalltalk.withContext(function($ctx2) {
  766. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  767. return self}, function($ctx1) {$ctx1.fill(self,"removeNonLocalReturn:",{aScope:aScope},smalltalk.MethodLexicalScope)})},
  768. args: ["aScope"],
  769. source: "removeNonLocalReturn: aScope\x0a\x09self nonLocalReturns remove: aScope ifAbsent: []",
  770. messageSends: ["remove:ifAbsent:", "nonLocalReturns"],
  771. referencedClasses: []
  772. }),
  773. smalltalk.MethodLexicalScope);
  774. smalltalk.addMethod(
  775. smalltalk.method({
  776. selector: "unknownVariables",
  777. category: 'accessing',
  778. fn: function (){
  779. var self=this;
  780. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  781. return smalltalk.withContext(function($ctx1) {
  782. var $1;
  783. if(($receiver = self["@unknownVariables"]) == nil || $receiver == null){
  784. self["@unknownVariables"]=_st($OrderedCollection())._new();
  785. $1=self["@unknownVariables"];
  786. } else {
  787. $1=self["@unknownVariables"];
  788. };
  789. return $1;
  790. }, function($ctx1) {$ctx1.fill(self,"unknownVariables",{},smalltalk.MethodLexicalScope)})},
  791. args: [],
  792. source: "unknownVariables\x0a\x09^ unknownVariables ifNil: [ unknownVariables := OrderedCollection new ]",
  793. messageSends: ["ifNil:", "new"],
  794. referencedClasses: ["OrderedCollection"]
  795. }),
  796. smalltalk.MethodLexicalScope);
  797. smalltalk.addClass('ScopeVar', smalltalk.Object, ['scope', 'name'], 'Compiler-Semantic');
  798. smalltalk.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.";
  799. smalltalk.addMethod(
  800. smalltalk.method({
  801. selector: "alias",
  802. category: 'accessing',
  803. fn: function (){
  804. var self=this;
  805. return smalltalk.withContext(function($ctx1) {
  806. var $1;
  807. $1=_st(self._name())._asVariableName();
  808. return $1;
  809. }, function($ctx1) {$ctx1.fill(self,"alias",{},smalltalk.ScopeVar)})},
  810. args: [],
  811. source: "alias\x0a\x09^ self name asVariableName",
  812. messageSends: ["asVariableName", "name"],
  813. referencedClasses: []
  814. }),
  815. smalltalk.ScopeVar);
  816. smalltalk.addMethod(
  817. smalltalk.method({
  818. selector: "isArgVar",
  819. category: 'testing',
  820. fn: function (){
  821. var self=this;
  822. return smalltalk.withContext(function($ctx1) {
  823. return false;
  824. }, function($ctx1) {$ctx1.fill(self,"isArgVar",{},smalltalk.ScopeVar)})},
  825. args: [],
  826. source: "isArgVar\x0a\x09^ false",
  827. messageSends: [],
  828. referencedClasses: []
  829. }),
  830. smalltalk.ScopeVar);
  831. smalltalk.addMethod(
  832. smalltalk.method({
  833. selector: "isClassRefVar",
  834. category: 'testing',
  835. fn: function (){
  836. var self=this;
  837. return smalltalk.withContext(function($ctx1) {
  838. return false;
  839. }, function($ctx1) {$ctx1.fill(self,"isClassRefVar",{},smalltalk.ScopeVar)})},
  840. args: [],
  841. source: "isClassRefVar\x0a\x09^ false",
  842. messageSends: [],
  843. referencedClasses: []
  844. }),
  845. smalltalk.ScopeVar);
  846. smalltalk.addMethod(
  847. smalltalk.method({
  848. selector: "isImmutable",
  849. category: 'testing',
  850. fn: function (){
  851. var self=this;
  852. return smalltalk.withContext(function($ctx1) {
  853. return false;
  854. }, function($ctx1) {$ctx1.fill(self,"isImmutable",{},smalltalk.ScopeVar)})},
  855. args: [],
  856. source: "isImmutable\x0a\x09^ false",
  857. messageSends: [],
  858. referencedClasses: []
  859. }),
  860. smalltalk.ScopeVar);
  861. smalltalk.addMethod(
  862. smalltalk.method({
  863. selector: "isInstanceVar",
  864. category: 'testing',
  865. fn: function (){
  866. var self=this;
  867. return smalltalk.withContext(function($ctx1) {
  868. return false;
  869. }, function($ctx1) {$ctx1.fill(self,"isInstanceVar",{},smalltalk.ScopeVar)})},
  870. args: [],
  871. source: "isInstanceVar\x0a\x09^ false",
  872. messageSends: [],
  873. referencedClasses: []
  874. }),
  875. smalltalk.ScopeVar);
  876. smalltalk.addMethod(
  877. smalltalk.method({
  878. selector: "isPseudoVar",
  879. category: 'testing',
  880. fn: function (){
  881. var self=this;
  882. return smalltalk.withContext(function($ctx1) {
  883. return false;
  884. }, function($ctx1) {$ctx1.fill(self,"isPseudoVar",{},smalltalk.ScopeVar)})},
  885. args: [],
  886. source: "isPseudoVar\x0a\x09^ false",
  887. messageSends: [],
  888. referencedClasses: []
  889. }),
  890. smalltalk.ScopeVar);
  891. smalltalk.addMethod(
  892. smalltalk.method({
  893. selector: "isTempVar",
  894. category: 'testing',
  895. fn: function (){
  896. var self=this;
  897. return smalltalk.withContext(function($ctx1) {
  898. return false;
  899. }, function($ctx1) {$ctx1.fill(self,"isTempVar",{},smalltalk.ScopeVar)})},
  900. args: [],
  901. source: "isTempVar\x0a\x09^ false",
  902. messageSends: [],
  903. referencedClasses: []
  904. }),
  905. smalltalk.ScopeVar);
  906. smalltalk.addMethod(
  907. smalltalk.method({
  908. selector: "isUnknownVar",
  909. category: 'testing',
  910. fn: function (){
  911. var self=this;
  912. return smalltalk.withContext(function($ctx1) {
  913. return false;
  914. }, function($ctx1) {$ctx1.fill(self,"isUnknownVar",{},smalltalk.ScopeVar)})},
  915. args: [],
  916. source: "isUnknownVar\x0a\x09^ false",
  917. messageSends: [],
  918. referencedClasses: []
  919. }),
  920. smalltalk.ScopeVar);
  921. smalltalk.addMethod(
  922. smalltalk.method({
  923. selector: "name",
  924. category: 'accessing',
  925. fn: function (){
  926. var self=this;
  927. return smalltalk.withContext(function($ctx1) {
  928. var $1;
  929. $1=self["@name"];
  930. return $1;
  931. }, function($ctx1) {$ctx1.fill(self,"name",{},smalltalk.ScopeVar)})},
  932. args: [],
  933. source: "name\x0a\x09^ name",
  934. messageSends: [],
  935. referencedClasses: []
  936. }),
  937. smalltalk.ScopeVar);
  938. smalltalk.addMethod(
  939. smalltalk.method({
  940. selector: "name:",
  941. category: 'accessing',
  942. fn: function (aString){
  943. var self=this;
  944. return smalltalk.withContext(function($ctx1) {
  945. self["@name"]=aString;
  946. return self}, function($ctx1) {$ctx1.fill(self,"name:",{aString:aString},smalltalk.ScopeVar)})},
  947. args: ["aString"],
  948. source: "name: aString\x0a\x09name := aString",
  949. messageSends: [],
  950. referencedClasses: []
  951. }),
  952. smalltalk.ScopeVar);
  953. smalltalk.addMethod(
  954. smalltalk.method({
  955. selector: "scope",
  956. category: 'accessing',
  957. fn: function (){
  958. var self=this;
  959. return smalltalk.withContext(function($ctx1) {
  960. var $1;
  961. $1=self["@scope"];
  962. return $1;
  963. }, function($ctx1) {$ctx1.fill(self,"scope",{},smalltalk.ScopeVar)})},
  964. args: [],
  965. source: "scope\x0a\x09^ scope",
  966. messageSends: [],
  967. referencedClasses: []
  968. }),
  969. smalltalk.ScopeVar);
  970. smalltalk.addMethod(
  971. smalltalk.method({
  972. selector: "scope:",
  973. category: 'accessing',
  974. fn: function (aScope){
  975. var self=this;
  976. return smalltalk.withContext(function($ctx1) {
  977. self["@scope"]=aScope;
  978. return self}, function($ctx1) {$ctx1.fill(self,"scope:",{aScope:aScope},smalltalk.ScopeVar)})},
  979. args: ["aScope"],
  980. source: "scope: aScope\x0a\x09scope := aScope",
  981. messageSends: [],
  982. referencedClasses: []
  983. }),
  984. smalltalk.ScopeVar);
  985. smalltalk.addMethod(
  986. smalltalk.method({
  987. selector: "validateAssignment",
  988. category: 'testing',
  989. fn: function (){
  990. var self=this;
  991. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  992. return smalltalk.withContext(function($ctx1) {
  993. var $1,$2;
  994. if(smalltalk.assert(_st(self._isArgVar())._or_((function(){
  995. return smalltalk.withContext(function($ctx2) {
  996. return self._isPseudoVar();
  997. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})))){
  998. $1=_st($InvalidAssignmentError())._new();
  999. _st($1)._variableName_(self._name());
  1000. $2=_st($1)._signal();
  1001. $2;
  1002. };
  1003. return self}, function($ctx1) {$ctx1.fill(self,"validateAssignment",{},smalltalk.ScopeVar)})},
  1004. args: [],
  1005. source: "validateAssignment\x0a\x09(self isArgVar or: [ self isPseudoVar ]) ifTrue: [\x0a\x09\x09InvalidAssignmentError new\x0a\x09\x09\x09variableName: self name;\x0a\x09\x09\x09signal]",
  1006. messageSends: ["ifTrue:", "or:", "isArgVar", "isPseudoVar", "variableName:", "new", "name", "signal"],
  1007. referencedClasses: ["InvalidAssignmentError"]
  1008. }),
  1009. smalltalk.ScopeVar);
  1010. smalltalk.addMethod(
  1011. smalltalk.method({
  1012. selector: "on:",
  1013. category: 'instance creation',
  1014. fn: function (aString){
  1015. var self=this;
  1016. return smalltalk.withContext(function($ctx1) {
  1017. var $2,$3,$1;
  1018. $2=self._new();
  1019. _st($2)._name_(aString);
  1020. $3=_st($2)._yourself();
  1021. $1=$3;
  1022. return $1;
  1023. }, function($ctx1) {$ctx1.fill(self,"on:",{aString:aString},smalltalk.ScopeVar.klass)})},
  1024. args: ["aString"],
  1025. source: "on: aString\x0a\x09^ self new\x0a\x09\x09name: aString;\x0a\x09\x09yourself",
  1026. messageSends: ["name:", "new", "yourself"],
  1027. referencedClasses: []
  1028. }),
  1029. smalltalk.ScopeVar.klass);
  1030. smalltalk.addClass('AliasVar', smalltalk.ScopeVar, ['node'], 'Compiler-Semantic');
  1031. smalltalk.AliasVar.comment="I am an internally defined variable by the compiler";
  1032. smalltalk.addMethod(
  1033. smalltalk.method({
  1034. selector: "node",
  1035. category: 'accessing',
  1036. fn: function (){
  1037. var self=this;
  1038. return smalltalk.withContext(function($ctx1) {
  1039. var $1;
  1040. $1=self["@node"];
  1041. return $1;
  1042. }, function($ctx1) {$ctx1.fill(self,"node",{},smalltalk.AliasVar)})},
  1043. args: [],
  1044. source: "node\x0a\x09^ node",
  1045. messageSends: [],
  1046. referencedClasses: []
  1047. }),
  1048. smalltalk.AliasVar);
  1049. smalltalk.addMethod(
  1050. smalltalk.method({
  1051. selector: "node:",
  1052. category: 'accessing',
  1053. fn: function (aNode){
  1054. var self=this;
  1055. return smalltalk.withContext(function($ctx1) {
  1056. self["@node"]=aNode;
  1057. return self}, function($ctx1) {$ctx1.fill(self,"node:",{aNode:aNode},smalltalk.AliasVar)})},
  1058. args: ["aNode"],
  1059. source: "node: aNode\x0a\x09node := aNode",
  1060. messageSends: [],
  1061. referencedClasses: []
  1062. }),
  1063. smalltalk.AliasVar);
  1064. smalltalk.addClass('ArgVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1065. smalltalk.ArgVar.comment="I am an argument of a method or block.";
  1066. smalltalk.addMethod(
  1067. smalltalk.method({
  1068. selector: "isArgVar",
  1069. category: 'testing',
  1070. fn: function (){
  1071. var self=this;
  1072. return smalltalk.withContext(function($ctx1) {
  1073. return true;
  1074. }, function($ctx1) {$ctx1.fill(self,"isArgVar",{},smalltalk.ArgVar)})},
  1075. args: [],
  1076. source: "isArgVar\x0a\x09^ true",
  1077. messageSends: [],
  1078. referencedClasses: []
  1079. }),
  1080. smalltalk.ArgVar);
  1081. smalltalk.addMethod(
  1082. smalltalk.method({
  1083. selector: "isImmutable",
  1084. category: 'testing',
  1085. fn: function (){
  1086. var self=this;
  1087. return smalltalk.withContext(function($ctx1) {
  1088. return true;
  1089. }, function($ctx1) {$ctx1.fill(self,"isImmutable",{},smalltalk.ArgVar)})},
  1090. args: [],
  1091. source: "isImmutable\x0a\x09^ true",
  1092. messageSends: [],
  1093. referencedClasses: []
  1094. }),
  1095. smalltalk.ArgVar);
  1096. smalltalk.addClass('ClassRefVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1097. smalltalk.ClassRefVar.comment="I am an class reference variable";
  1098. smalltalk.addMethod(
  1099. smalltalk.method({
  1100. selector: "alias",
  1101. category: 'accessing',
  1102. fn: function (){
  1103. var self=this;
  1104. return smalltalk.withContext(function($ctx1) {
  1105. var $2,$1;
  1106. $2="$".__comma(self._name());
  1107. $1=_st($2).__comma("()");
  1108. $ctx1.sendIdx[","]=1;
  1109. return $1;
  1110. }, function($ctx1) {$ctx1.fill(self,"alias",{},smalltalk.ClassRefVar)})},
  1111. args: [],
  1112. source: "alias\x0a\x09\x22Fixes issue #190.\x0a\x09A function is created in the method definition, answering the class or nil.\x0a\x09See JSStream >> #nextPutClassRefFunction:\x22\x0a\x09\x0a\x09^ '$', self name, '()'",
  1113. messageSends: [",", "name"],
  1114. referencedClasses: []
  1115. }),
  1116. smalltalk.ClassRefVar);
  1117. smalltalk.addMethod(
  1118. smalltalk.method({
  1119. selector: "isClassRefVar",
  1120. category: 'testing',
  1121. fn: function (){
  1122. var self=this;
  1123. return smalltalk.withContext(function($ctx1) {
  1124. return true;
  1125. }, function($ctx1) {$ctx1.fill(self,"isClassRefVar",{},smalltalk.ClassRefVar)})},
  1126. args: [],
  1127. source: "isClassRefVar\x0a\x09^ true",
  1128. messageSends: [],
  1129. referencedClasses: []
  1130. }),
  1131. smalltalk.ClassRefVar);
  1132. smalltalk.addMethod(
  1133. smalltalk.method({
  1134. selector: "isImmutable",
  1135. category: 'testing',
  1136. fn: function (){
  1137. var self=this;
  1138. return smalltalk.withContext(function($ctx1) {
  1139. return true;
  1140. }, function($ctx1) {$ctx1.fill(self,"isImmutable",{},smalltalk.ClassRefVar)})},
  1141. args: [],
  1142. source: "isImmutable\x0a\x09^ true",
  1143. messageSends: [],
  1144. referencedClasses: []
  1145. }),
  1146. smalltalk.ClassRefVar);
  1147. smalltalk.addClass('InstanceVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1148. smalltalk.InstanceVar.comment="I am an instance variable of a method or block.";
  1149. smalltalk.addMethod(
  1150. smalltalk.method({
  1151. selector: "alias",
  1152. category: 'testing',
  1153. fn: function (){
  1154. var self=this;
  1155. return smalltalk.withContext(function($ctx1) {
  1156. var $2,$1;
  1157. $2="self[\x22@".__comma(self._name());
  1158. $1=_st($2).__comma("\x22]");
  1159. $ctx1.sendIdx[","]=1;
  1160. return $1;
  1161. }, function($ctx1) {$ctx1.fill(self,"alias",{},smalltalk.InstanceVar)})},
  1162. args: [],
  1163. source: "alias\x0a\x09^ 'self[\x22@', self name, '\x22]'",
  1164. messageSends: [",", "name"],
  1165. referencedClasses: []
  1166. }),
  1167. smalltalk.InstanceVar);
  1168. smalltalk.addMethod(
  1169. smalltalk.method({
  1170. selector: "isInstanceVar",
  1171. category: 'testing',
  1172. fn: function (){
  1173. var self=this;
  1174. return smalltalk.withContext(function($ctx1) {
  1175. return true;
  1176. }, function($ctx1) {$ctx1.fill(self,"isInstanceVar",{},smalltalk.InstanceVar)})},
  1177. args: [],
  1178. source: "isInstanceVar\x0a\x09^ true",
  1179. messageSends: [],
  1180. referencedClasses: []
  1181. }),
  1182. smalltalk.InstanceVar);
  1183. smalltalk.addClass('PseudoVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1184. smalltalk.PseudoVar.comment="I am an pseudo variable.\x0a\x0aThe five Smalltalk pseudo variables are: 'self', 'super', 'nil', 'true' and 'false'";
  1185. smalltalk.addMethod(
  1186. smalltalk.method({
  1187. selector: "alias",
  1188. category: 'accessing',
  1189. fn: function (){
  1190. var self=this;
  1191. return smalltalk.withContext(function($ctx1) {
  1192. var $1;
  1193. $1=self._name();
  1194. return $1;
  1195. }, function($ctx1) {$ctx1.fill(self,"alias",{},smalltalk.PseudoVar)})},
  1196. args: [],
  1197. source: "alias\x0a\x09^ self name",
  1198. messageSends: ["name"],
  1199. referencedClasses: []
  1200. }),
  1201. smalltalk.PseudoVar);
  1202. smalltalk.addMethod(
  1203. smalltalk.method({
  1204. selector: "isImmutable",
  1205. category: 'testing',
  1206. fn: function (){
  1207. var self=this;
  1208. return smalltalk.withContext(function($ctx1) {
  1209. return true;
  1210. }, function($ctx1) {$ctx1.fill(self,"isImmutable",{},smalltalk.PseudoVar)})},
  1211. args: [],
  1212. source: "isImmutable\x0a\x09^ true",
  1213. messageSends: [],
  1214. referencedClasses: []
  1215. }),
  1216. smalltalk.PseudoVar);
  1217. smalltalk.addMethod(
  1218. smalltalk.method({
  1219. selector: "isPseudoVar",
  1220. category: 'testing',
  1221. fn: function (){
  1222. var self=this;
  1223. return smalltalk.withContext(function($ctx1) {
  1224. return true;
  1225. }, function($ctx1) {$ctx1.fill(self,"isPseudoVar",{},smalltalk.PseudoVar)})},
  1226. args: [],
  1227. source: "isPseudoVar\x0a\x09^ true",
  1228. messageSends: [],
  1229. referencedClasses: []
  1230. }),
  1231. smalltalk.PseudoVar);
  1232. smalltalk.addClass('TempVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1233. smalltalk.TempVar.comment="I am an temporary variable of a method or block.";
  1234. smalltalk.addMethod(
  1235. smalltalk.method({
  1236. selector: "isTempVar",
  1237. category: 'testing',
  1238. fn: function (){
  1239. var self=this;
  1240. return smalltalk.withContext(function($ctx1) {
  1241. return true;
  1242. }, function($ctx1) {$ctx1.fill(self,"isTempVar",{},smalltalk.TempVar)})},
  1243. args: [],
  1244. source: "isTempVar\x0a\x09^ true",
  1245. messageSends: [],
  1246. referencedClasses: []
  1247. }),
  1248. smalltalk.TempVar);
  1249. smalltalk.addClass('UnknownVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1250. smalltalk.UnknownVar.comment="I am an unknown variable. Amber uses unknown variables as JavaScript globals";
  1251. smalltalk.addMethod(
  1252. smalltalk.method({
  1253. selector: "isUnknownVar",
  1254. category: 'testing',
  1255. fn: function (){
  1256. var self=this;
  1257. return smalltalk.withContext(function($ctx1) {
  1258. return true;
  1259. }, function($ctx1) {$ctx1.fill(self,"isUnknownVar",{},smalltalk.UnknownVar)})},
  1260. args: [],
  1261. source: "isUnknownVar\x0a\x09^ true",
  1262. messageSends: [],
  1263. referencedClasses: []
  1264. }),
  1265. smalltalk.UnknownVar);
  1266. smalltalk.addClass('SemanticAnalyzer', smalltalk.NodeVisitor, ['currentScope', 'blockIndex', 'theClass', 'classReferences', 'messageSends', 'superSends'], 'Compiler-Semantic');
  1267. smalltalk.SemanticAnalyzer.comment="I semantically analyze the abstract syntax tree and annotate it with informations such as non local returns and variable scopes.";
  1268. smalltalk.addMethod(
  1269. smalltalk.method({
  1270. selector: "classReferences",
  1271. category: 'accessing',
  1272. fn: function (){
  1273. var self=this;
  1274. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  1275. return smalltalk.withContext(function($ctx1) {
  1276. var $1;
  1277. if(($receiver = self["@classReferences"]) == nil || $receiver == null){
  1278. self["@classReferences"]=_st($Set())._new();
  1279. $1=self["@classReferences"];
  1280. } else {
  1281. $1=self["@classReferences"];
  1282. };
  1283. return $1;
  1284. }, function($ctx1) {$ctx1.fill(self,"classReferences",{},smalltalk.SemanticAnalyzer)})},
  1285. args: [],
  1286. source: "classReferences\x0a\x09^ classReferences ifNil: [ classReferences := Set new ]",
  1287. messageSends: ["ifNil:", "new"],
  1288. referencedClasses: ["Set"]
  1289. }),
  1290. smalltalk.SemanticAnalyzer);
  1291. smalltalk.addMethod(
  1292. smalltalk.method({
  1293. selector: "errorShadowingVariable:",
  1294. category: 'error handling',
  1295. fn: function (aString){
  1296. var self=this;
  1297. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1298. return smalltalk.withContext(function($ctx1) {
  1299. var $1,$2;
  1300. $1=_st($ShadowingVariableError())._new();
  1301. _st($1)._variableName_(aString);
  1302. $2=_st($1)._signal();
  1303. return self}, function($ctx1) {$ctx1.fill(self,"errorShadowingVariable:",{aString:aString},smalltalk.SemanticAnalyzer)})},
  1304. args: ["aString"],
  1305. source: "errorShadowingVariable: aString\x0a\x09ShadowingVariableError new\x0a\x09\x09variableName: aString;\x0a\x09\x09signal",
  1306. messageSends: ["variableName:", "new", "signal"],
  1307. referencedClasses: ["ShadowingVariableError"]
  1308. }),
  1309. smalltalk.SemanticAnalyzer);
  1310. smalltalk.addMethod(
  1311. smalltalk.method({
  1312. selector: "errorUnknownVariable:",
  1313. category: 'error handling',
  1314. fn: function (aNode){
  1315. var self=this;
  1316. var identifier;
  1317. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  1318. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1319. return smalltalk.withContext(function($ctx1) {
  1320. var $1,$2,$3,$4,$5,$6;
  1321. identifier=_st(aNode)._value();
  1322. $ctx1.sendIdx["value"]=1;
  1323. if(smalltalk.assert(_st(_st(_st(_st(_st($Smalltalk())._current())._globalJsVariables())._includes_(identifier))._not())._and_((function(){
  1324. return smalltalk.withContext(function($ctx2) {
  1325. return self._isVariableGloballyUndefined_(identifier);
  1326. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})})))){
  1327. $1=_st($UnknownVariableError())._new();
  1328. $2=$1;
  1329. $3=_st(aNode)._value();
  1330. $ctx1.sendIdx["value"]=2;
  1331. _st($2)._variableName_($3);
  1332. $4=_st($1)._signal();
  1333. $4;
  1334. } else {
  1335. $5=_st(_st(self["@currentScope"])._methodScope())._unknownVariables();
  1336. $6=_st(aNode)._value();
  1337. _st($5)._add_($6);
  1338. };
  1339. return self}, function($ctx1) {$ctx1.fill(self,"errorUnknownVariable:",{aNode:aNode,identifier:identifier},smalltalk.SemanticAnalyzer)})},
  1340. args: ["aNode"],
  1341. 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: `jQuery`, `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 current globalJsVariables includes: identifier) not\x0a\x09\x09and: [ self isVariableGloballyUndefined: identifier ])\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 ]",
  1342. messageSends: ["value", "ifTrue:ifFalse:", "and:", "not", "includes:", "globalJsVariables", "current", "isVariableGloballyUndefined:", "variableName:", "new", "signal", "add:", "unknownVariables", "methodScope"],
  1343. referencedClasses: ["Smalltalk", "UnknownVariableError"]
  1344. }),
  1345. smalltalk.SemanticAnalyzer);
  1346. smalltalk.addMethod(
  1347. smalltalk.method({
  1348. selector: "isVariableGloballyUndefined:",
  1349. category: 'testing',
  1350. fn: function (aString){
  1351. var self=this;
  1352. return smalltalk.withContext(function($ctx1) {
  1353. return eval('typeof ' + aString + ' == "undefined"');
  1354. return self}, function($ctx1) {$ctx1.fill(self,"isVariableGloballyUndefined:",{aString:aString},smalltalk.SemanticAnalyzer)})},
  1355. args: ["aString"],
  1356. source: "isVariableGloballyUndefined: aString\x0a\x09<return eval('typeof ' + aString + ' == \x22undefined\x22')>",
  1357. messageSends: [],
  1358. referencedClasses: []
  1359. }),
  1360. smalltalk.SemanticAnalyzer);
  1361. smalltalk.addMethod(
  1362. smalltalk.method({
  1363. selector: "messageSends",
  1364. category: 'accessing',
  1365. fn: function (){
  1366. var self=this;
  1367. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1368. return smalltalk.withContext(function($ctx1) {
  1369. var $1;
  1370. if(($receiver = self["@messageSends"]) == nil || $receiver == null){
  1371. self["@messageSends"]=_st($Dictionary())._new();
  1372. $1=self["@messageSends"];
  1373. } else {
  1374. $1=self["@messageSends"];
  1375. };
  1376. return $1;
  1377. }, function($ctx1) {$ctx1.fill(self,"messageSends",{},smalltalk.SemanticAnalyzer)})},
  1378. args: [],
  1379. source: "messageSends\x0a\x09^ messageSends ifNil: [ messageSends := Dictionary new ]",
  1380. messageSends: ["ifNil:", "new"],
  1381. referencedClasses: ["Dictionary"]
  1382. }),
  1383. smalltalk.SemanticAnalyzer);
  1384. smalltalk.addMethod(
  1385. smalltalk.method({
  1386. selector: "newBlockScope",
  1387. category: 'factory',
  1388. fn: function (){
  1389. var self=this;
  1390. function $LexicalScope(){return smalltalk.LexicalScope||(typeof LexicalScope=="undefined"?nil:LexicalScope)}
  1391. return smalltalk.withContext(function($ctx1) {
  1392. var $1;
  1393. $1=self._newScopeOfClass_($LexicalScope());
  1394. return $1;
  1395. }, function($ctx1) {$ctx1.fill(self,"newBlockScope",{},smalltalk.SemanticAnalyzer)})},
  1396. args: [],
  1397. source: "newBlockScope\x0a\x09^ self newScopeOfClass: LexicalScope",
  1398. messageSends: ["newScopeOfClass:"],
  1399. referencedClasses: ["LexicalScope"]
  1400. }),
  1401. smalltalk.SemanticAnalyzer);
  1402. smalltalk.addMethod(
  1403. smalltalk.method({
  1404. selector: "newMethodScope",
  1405. category: 'factory',
  1406. fn: function (){
  1407. var self=this;
  1408. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1409. return smalltalk.withContext(function($ctx1) {
  1410. var $1;
  1411. $1=self._newScopeOfClass_($MethodLexicalScope());
  1412. return $1;
  1413. }, function($ctx1) {$ctx1.fill(self,"newMethodScope",{},smalltalk.SemanticAnalyzer)})},
  1414. args: [],
  1415. source: "newMethodScope\x0a\x09^ self newScopeOfClass: MethodLexicalScope",
  1416. messageSends: ["newScopeOfClass:"],
  1417. referencedClasses: ["MethodLexicalScope"]
  1418. }),
  1419. smalltalk.SemanticAnalyzer);
  1420. smalltalk.addMethod(
  1421. smalltalk.method({
  1422. selector: "newScopeOfClass:",
  1423. category: 'factory',
  1424. fn: function (aLexicalScopeClass){
  1425. var self=this;
  1426. return smalltalk.withContext(function($ctx1) {
  1427. var $2,$3,$1;
  1428. $2=_st(aLexicalScopeClass)._new();
  1429. _st($2)._outerScope_(self["@currentScope"]);
  1430. $3=_st($2)._yourself();
  1431. $1=$3;
  1432. return $1;
  1433. }, function($ctx1) {$ctx1.fill(self,"newScopeOfClass:",{aLexicalScopeClass:aLexicalScopeClass},smalltalk.SemanticAnalyzer)})},
  1434. args: ["aLexicalScopeClass"],
  1435. source: "newScopeOfClass: aLexicalScopeClass\x0a\x09^ aLexicalScopeClass new\x0a\x09\x09outerScope: currentScope;\x0a\x09\x09yourself",
  1436. messageSends: ["outerScope:", "new", "yourself"],
  1437. referencedClasses: []
  1438. }),
  1439. smalltalk.SemanticAnalyzer);
  1440. smalltalk.addMethod(
  1441. smalltalk.method({
  1442. selector: "nextBlockIndex",
  1443. category: 'private',
  1444. fn: function (){
  1445. var self=this;
  1446. return smalltalk.withContext(function($ctx1) {
  1447. var $1;
  1448. if(($receiver = self["@blockIndex"]) == nil || $receiver == null){
  1449. self["@blockIndex"]=(0);
  1450. self["@blockIndex"];
  1451. } else {
  1452. self["@blockIndex"];
  1453. };
  1454. self["@blockIndex"]=_st(self["@blockIndex"]).__plus((1));
  1455. $1=self["@blockIndex"];
  1456. return $1;
  1457. }, function($ctx1) {$ctx1.fill(self,"nextBlockIndex",{},smalltalk.SemanticAnalyzer)})},
  1458. args: [],
  1459. source: "nextBlockIndex\x0a\x09blockIndex ifNil: [ blockIndex := 0 ].\x0a\x09\x0a\x09blockIndex := blockIndex + 1.\x0a\x09^ blockIndex",
  1460. messageSends: ["ifNil:", "+"],
  1461. referencedClasses: []
  1462. }),
  1463. smalltalk.SemanticAnalyzer);
  1464. smalltalk.addMethod(
  1465. smalltalk.method({
  1466. selector: "popScope",
  1467. category: 'scope',
  1468. fn: function (){
  1469. var self=this;
  1470. return smalltalk.withContext(function($ctx1) {
  1471. if(($receiver = self["@currentScope"]) == nil || $receiver == null){
  1472. self["@currentScope"];
  1473. } else {
  1474. self["@currentScope"]=_st(self["@currentScope"])._outerScope();
  1475. self["@currentScope"];
  1476. };
  1477. return self}, function($ctx1) {$ctx1.fill(self,"popScope",{},smalltalk.SemanticAnalyzer)})},
  1478. args: [],
  1479. source: "popScope\x0a\x09currentScope ifNotNil: [\x0a\x09\x09currentScope := currentScope outerScope ]",
  1480. messageSends: ["ifNotNil:", "outerScope"],
  1481. referencedClasses: []
  1482. }),
  1483. smalltalk.SemanticAnalyzer);
  1484. smalltalk.addMethod(
  1485. smalltalk.method({
  1486. selector: "pushScope:",
  1487. category: 'scope',
  1488. fn: function (aScope){
  1489. var self=this;
  1490. return smalltalk.withContext(function($ctx1) {
  1491. _st(aScope)._outerScope_(self["@currentScope"]);
  1492. self["@currentScope"]=aScope;
  1493. return self}, function($ctx1) {$ctx1.fill(self,"pushScope:",{aScope:aScope},smalltalk.SemanticAnalyzer)})},
  1494. args: ["aScope"],
  1495. source: "pushScope: aScope\x0a\x09aScope outerScope: currentScope.\x0a\x09currentScope := aScope",
  1496. messageSends: ["outerScope:"],
  1497. referencedClasses: []
  1498. }),
  1499. smalltalk.SemanticAnalyzer);
  1500. smalltalk.addMethod(
  1501. smalltalk.method({
  1502. selector: "superSends",
  1503. category: 'accessing',
  1504. fn: function (){
  1505. var self=this;
  1506. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  1507. return smalltalk.withContext(function($ctx1) {
  1508. var $1;
  1509. if(($receiver = self["@superSends"]) == nil || $receiver == null){
  1510. self["@superSends"]=_st($Dictionary())._new();
  1511. $1=self["@superSends"];
  1512. } else {
  1513. $1=self["@superSends"];
  1514. };
  1515. return $1;
  1516. }, function($ctx1) {$ctx1.fill(self,"superSends",{},smalltalk.SemanticAnalyzer)})},
  1517. args: [],
  1518. source: "superSends\x0a\x09^ superSends ifNil: [ superSends := Dictionary new ]",
  1519. messageSends: ["ifNil:", "new"],
  1520. referencedClasses: ["Dictionary"]
  1521. }),
  1522. smalltalk.SemanticAnalyzer);
  1523. smalltalk.addMethod(
  1524. smalltalk.method({
  1525. selector: "theClass",
  1526. category: 'accessing',
  1527. fn: function (){
  1528. var self=this;
  1529. return smalltalk.withContext(function($ctx1) {
  1530. var $1;
  1531. $1=self["@theClass"];
  1532. return $1;
  1533. }, function($ctx1) {$ctx1.fill(self,"theClass",{},smalltalk.SemanticAnalyzer)})},
  1534. args: [],
  1535. source: "theClass\x0a\x09^ theClass",
  1536. messageSends: [],
  1537. referencedClasses: []
  1538. }),
  1539. smalltalk.SemanticAnalyzer);
  1540. smalltalk.addMethod(
  1541. smalltalk.method({
  1542. selector: "theClass:",
  1543. category: 'accessing',
  1544. fn: function (aClass){
  1545. var self=this;
  1546. return smalltalk.withContext(function($ctx1) {
  1547. self["@theClass"]=aClass;
  1548. return self}, function($ctx1) {$ctx1.fill(self,"theClass:",{aClass:aClass},smalltalk.SemanticAnalyzer)})},
  1549. args: ["aClass"],
  1550. source: "theClass: aClass\x0a\x09theClass := aClass",
  1551. messageSends: [],
  1552. referencedClasses: []
  1553. }),
  1554. smalltalk.SemanticAnalyzer);
  1555. smalltalk.addMethod(
  1556. smalltalk.method({
  1557. selector: "validateVariableScope:",
  1558. category: 'scope',
  1559. fn: function (aString){
  1560. var self=this;
  1561. return smalltalk.withContext(function($ctx1) {
  1562. if(($receiver = _st(self["@currentScope"])._lookupVariable_(aString)) == nil || $receiver == null){
  1563. _st(self["@currentScope"])._lookupVariable_(aString);
  1564. } else {
  1565. self._errorShadowingVariable_(aString);
  1566. };
  1567. return self}, function($ctx1) {$ctx1.fill(self,"validateVariableScope:",{aString:aString},smalltalk.SemanticAnalyzer)})},
  1568. args: ["aString"],
  1569. 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 ]",
  1570. messageSends: ["ifNotNil:", "lookupVariable:", "errorShadowingVariable:"],
  1571. referencedClasses: []
  1572. }),
  1573. smalltalk.SemanticAnalyzer);
  1574. smalltalk.addMethod(
  1575. smalltalk.method({
  1576. selector: "visitAssignmentNode:",
  1577. category: 'visiting',
  1578. fn: function (aNode){
  1579. var self=this;
  1580. return smalltalk.withContext(function($ctx1) {
  1581. smalltalk.SemanticAnalyzer.superclass.fn.prototype._visitAssignmentNode_.apply(_st(self), [aNode]);
  1582. _st(_st(aNode)._left())._beAssigned();
  1583. return self}, function($ctx1) {$ctx1.fill(self,"visitAssignmentNode:",{aNode:aNode},smalltalk.SemanticAnalyzer)})},
  1584. args: ["aNode"],
  1585. source: "visitAssignmentNode: aNode\x0a\x09super visitAssignmentNode: aNode.\x0a\x09aNode left beAssigned",
  1586. messageSends: ["visitAssignmentNode:", "beAssigned", "left"],
  1587. referencedClasses: []
  1588. }),
  1589. smalltalk.SemanticAnalyzer);
  1590. smalltalk.addMethod(
  1591. smalltalk.method({
  1592. selector: "visitBlockNode:",
  1593. category: 'visiting',
  1594. fn: function (aNode){
  1595. var self=this;
  1596. return smalltalk.withContext(function($ctx1) {
  1597. self._pushScope_(self._newBlockScope());
  1598. _st(aNode)._scope_(self["@currentScope"]);
  1599. _st(self["@currentScope"])._node_(aNode);
  1600. _st(self["@currentScope"])._blockIndex_(self._nextBlockIndex());
  1601. _st(_st(aNode)._parameters())._do_((function(each){
  1602. return smalltalk.withContext(function($ctx2) {
  1603. self._validateVariableScope_(each);
  1604. return _st(self["@currentScope"])._addArg_(each);
  1605. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1606. smalltalk.SemanticAnalyzer.superclass.fn.prototype._visitBlockNode_.apply(_st(self), [aNode]);
  1607. self._popScope();
  1608. return self}, function($ctx1) {$ctx1.fill(self,"visitBlockNode:",{aNode:aNode},smalltalk.SemanticAnalyzer)})},
  1609. args: ["aNode"],
  1610. 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",
  1611. messageSends: ["pushScope:", "newBlockScope", "scope:", "node:", "blockIndex:", "nextBlockIndex", "do:", "parameters", "validateVariableScope:", "addArg:", "visitBlockNode:", "popScope"],
  1612. referencedClasses: []
  1613. }),
  1614. smalltalk.SemanticAnalyzer);
  1615. smalltalk.addMethod(
  1616. smalltalk.method({
  1617. selector: "visitCascadeNode:",
  1618. category: 'visiting',
  1619. fn: function (aNode){
  1620. var self=this;
  1621. return smalltalk.withContext(function($ctx1) {
  1622. var $3,$2,$1,$4;
  1623. smalltalk.SemanticAnalyzer.superclass.fn.prototype._visitCascadeNode_.apply(_st(self), [aNode]);
  1624. $3=_st(aNode)._nodes();
  1625. $ctx1.sendIdx["nodes"]=1;
  1626. $2=_st($3)._first();
  1627. $1=_st($2)._superSend();
  1628. if(smalltalk.assert($1)){
  1629. $4=_st(aNode)._nodes();
  1630. _st($4)._do_((function(each){
  1631. return smalltalk.withContext(function($ctx2) {
  1632. return _st(each)._superSend_(true);
  1633. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  1634. };
  1635. return self}, function($ctx1) {$ctx1.fill(self,"visitCascadeNode:",{aNode:aNode},smalltalk.SemanticAnalyzer)})},
  1636. args: ["aNode"],
  1637. source: "visitCascadeNode: aNode\x0a\x09super visitCascadeNode: aNode.\x0a\x09aNode nodes first superSend ifTrue: [\x0a\x09\x09aNode nodes do: [ :each | each superSend: true ] ]",
  1638. messageSends: ["visitCascadeNode:", "ifTrue:", "superSend", "first", "nodes", "do:", "superSend:"],
  1639. referencedClasses: []
  1640. }),
  1641. smalltalk.SemanticAnalyzer);
  1642. smalltalk.addMethod(
  1643. smalltalk.method({
  1644. selector: "visitMethodNode:",
  1645. category: 'visiting',
  1646. fn: function (aNode){
  1647. var self=this;
  1648. return smalltalk.withContext(function($ctx1) {
  1649. var $1;
  1650. self._pushScope_(self._newMethodScope());
  1651. _st(aNode)._scope_(self["@currentScope"]);
  1652. _st(self["@currentScope"])._node_(aNode);
  1653. _st(_st(self._theClass())._allInstanceVariableNames())._do_((function(each){
  1654. return smalltalk.withContext(function($ctx2) {
  1655. return _st(self["@currentScope"])._addIVar_(each);
  1656. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1657. $ctx1.sendIdx["do:"]=1;
  1658. _st(_st(aNode)._arguments())._do_((function(each){
  1659. return smalltalk.withContext(function($ctx2) {
  1660. self._validateVariableScope_(each);
  1661. return _st(self["@currentScope"])._addArg_(each);
  1662. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  1663. smalltalk.SemanticAnalyzer.superclass.fn.prototype._visitMethodNode_.apply(_st(self), [aNode]);
  1664. _st(aNode)._classReferences_(self._classReferences());
  1665. _st(aNode)._sendIndexes_(self._messageSends());
  1666. $1=_st(aNode)._superSends_(_st(self._superSends())._keys());
  1667. self._popScope();
  1668. return self}, function($ctx1) {$ctx1.fill(self,"visitMethodNode:",{aNode:aNode},smalltalk.SemanticAnalyzer)})},
  1669. args: ["aNode"],
  1670. 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\x09\x09superSends: self superSends keys.\x0a\x09self popScope",
  1671. messageSends: ["pushScope:", "newMethodScope", "scope:", "node:", "do:", "allInstanceVariableNames", "theClass", "addIVar:", "arguments", "validateVariableScope:", "addArg:", "visitMethodNode:", "classReferences:", "classReferences", "sendIndexes:", "messageSends", "superSends:", "keys", "superSends", "popScope"],
  1672. referencedClasses: []
  1673. }),
  1674. smalltalk.SemanticAnalyzer);
  1675. smalltalk.addMethod(
  1676. smalltalk.method({
  1677. selector: "visitReturnNode:",
  1678. category: 'visiting',
  1679. fn: function (aNode){
  1680. var self=this;
  1681. return smalltalk.withContext(function($ctx1) {
  1682. _st(aNode)._scope_(self["@currentScope"]);
  1683. if(smalltalk.assert(_st(self["@currentScope"])._isMethodScope())){
  1684. _st(self["@currentScope"])._localReturn_(true);
  1685. } else {
  1686. _st(_st(self["@currentScope"])._methodScope())._addNonLocalReturn_(self["@currentScope"]);
  1687. };
  1688. smalltalk.SemanticAnalyzer.superclass.fn.prototype._visitReturnNode_.apply(_st(self), [aNode]);
  1689. return self}, function($ctx1) {$ctx1.fill(self,"visitReturnNode:",{aNode:aNode},smalltalk.SemanticAnalyzer)})},
  1690. args: ["aNode"],
  1691. 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",
  1692. messageSends: ["scope:", "ifTrue:ifFalse:", "isMethodScope", "localReturn:", "addNonLocalReturn:", "methodScope", "visitReturnNode:"],
  1693. referencedClasses: []
  1694. }),
  1695. smalltalk.SemanticAnalyzer);
  1696. smalltalk.addMethod(
  1697. smalltalk.method({
  1698. selector: "visitSendNode:",
  1699. category: 'visiting',
  1700. fn: function (aNode){
  1701. var self=this;
  1702. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  1703. function $IRSendInliner(){return smalltalk.IRSendInliner||(typeof IRSendInliner=="undefined"?nil:IRSendInliner)}
  1704. return smalltalk.withContext(function($ctx1) {
  1705. var $3,$2,$1,$4,$5,$6,$8,$9,$7,$11,$12,$10,$13,$14,$16,$17,$15,$20,$21,$19,$18;
  1706. $3=_st(aNode)._receiver();
  1707. $ctx1.sendIdx["receiver"]=1;
  1708. $2=_st($3)._value();
  1709. $1=_st($2).__eq("super");
  1710. if(smalltalk.assert($1)){
  1711. _st(aNode)._superSend_(true);
  1712. $4=_st(aNode)._receiver();
  1713. _st($4)._value_("self");
  1714. $5=self._superSends();
  1715. $ctx1.sendIdx["superSends"]=1;
  1716. $6=_st(aNode)._selector();
  1717. $ctx1.sendIdx["selector"]=1;
  1718. _st($5)._at_ifAbsentPut_($6,(function(){
  1719. return smalltalk.withContext(function($ctx2) {
  1720. return _st($Set())._new();
  1721. $ctx2.sendIdx["new"]=1;
  1722. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  1723. $ctx1.sendIdx["at:ifAbsentPut:"]=1;
  1724. $8=self._superSends();
  1725. $9=_st(aNode)._selector();
  1726. $ctx1.sendIdx["selector"]=2;
  1727. $7=_st($8)._at_($9);
  1728. $ctx1.sendIdx["at:"]=1;
  1729. _st($7)._add_(aNode);
  1730. $ctx1.sendIdx["add:"]=1;
  1731. } else {
  1732. $11=_st($IRSendInliner())._inlinedSelectors();
  1733. $12=_st(aNode)._selector();
  1734. $ctx1.sendIdx["selector"]=3;
  1735. $10=_st($11)._includes_($12);
  1736. if(smalltalk.assert($10)){
  1737. _st(aNode)._shouldBeInlined_(true);
  1738. };
  1739. };
  1740. $13=self._messageSends();
  1741. $ctx1.sendIdx["messageSends"]=1;
  1742. $14=_st(aNode)._selector();
  1743. $ctx1.sendIdx["selector"]=4;
  1744. _st($13)._at_ifAbsentPut_($14,(function(){
  1745. return smalltalk.withContext(function($ctx2) {
  1746. return _st($Set())._new();
  1747. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,5)})}));
  1748. $16=self._messageSends();
  1749. $ctx1.sendIdx["messageSends"]=2;
  1750. $17=_st(aNode)._selector();
  1751. $ctx1.sendIdx["selector"]=5;
  1752. $15=_st($16)._at_($17);
  1753. $ctx1.sendIdx["at:"]=2;
  1754. _st($15)._add_(aNode);
  1755. $20=self._messageSends();
  1756. $21=_st(aNode)._selector();
  1757. $19=_st($20)._at_($21);
  1758. $18=_st($19)._size();
  1759. _st(aNode)._index_($18);
  1760. smalltalk.SemanticAnalyzer.superclass.fn.prototype._visitSendNode_.apply(_st(self), [aNode]);
  1761. return self}, function($ctx1) {$ctx1.fill(self,"visitSendNode:",{aNode:aNode},smalltalk.SemanticAnalyzer)})},
  1762. args: ["aNode"],
  1763. source: "visitSendNode: aNode\x0a\x0a\x09aNode receiver value = 'super'\x0a\x09\x09ifTrue: [\x0a\x09\x09\x09aNode superSend: true.\x0a\x09\x09\x09aNode receiver value: 'self'.\x0a\x09\x09\x09self superSends at: aNode selector ifAbsentPut: [ Set new ].\x0a\x09\x09\x09(self superSends at: aNode selector) add: aNode ]\x0a\x09\x09\x0a\x09\x09ifFalse: [ (IRSendInliner inlinedSelectors includes: aNode selector) ifTrue: [\x0a\x09\x09\x09aNode shouldBeInlined: true ] ].\x0a\x0a\x09self messageSends at: aNode selector ifAbsentPut: [ Set new ].\x0a\x09(self messageSends at: aNode selector) add: aNode.\x0a\x0a\x09aNode index: (self messageSends at: aNode selector) size.\x0a\x0a\x09super visitSendNode: aNode",
  1764. messageSends: ["ifTrue:ifFalse:", "=", "value", "receiver", "superSend:", "value:", "at:ifAbsentPut:", "superSends", "selector", "new", "add:", "at:", "ifTrue:", "includes:", "inlinedSelectors", "shouldBeInlined:", "messageSends", "index:", "size", "visitSendNode:"],
  1765. referencedClasses: ["Set", "IRSendInliner"]
  1766. }),
  1767. smalltalk.SemanticAnalyzer);
  1768. smalltalk.addMethod(
  1769. smalltalk.method({
  1770. selector: "visitSequenceNode:",
  1771. category: 'visiting',
  1772. fn: function (aNode){
  1773. var self=this;
  1774. return smalltalk.withContext(function($ctx1) {
  1775. _st(_st(aNode)._temps())._do_((function(each){
  1776. return smalltalk.withContext(function($ctx2) {
  1777. self._validateVariableScope_(each);
  1778. return _st(self["@currentScope"])._addTemp_(each);
  1779. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1780. smalltalk.SemanticAnalyzer.superclass.fn.prototype._visitSequenceNode_.apply(_st(self), [aNode]);
  1781. return self}, function($ctx1) {$ctx1.fill(self,"visitSequenceNode:",{aNode:aNode},smalltalk.SemanticAnalyzer)})},
  1782. args: ["aNode"],
  1783. source: "visitSequenceNode: aNode\x0a\x09aNode temps do: [ :each |\x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addTemp: each ].\x0a\x0a\x09super visitSequenceNode: aNode",
  1784. messageSends: ["do:", "temps", "validateVariableScope:", "addTemp:", "visitSequenceNode:"],
  1785. referencedClasses: []
  1786. }),
  1787. smalltalk.SemanticAnalyzer);
  1788. smalltalk.addMethod(
  1789. smalltalk.method({
  1790. selector: "visitVariableNode:",
  1791. category: 'visiting',
  1792. fn: function (aNode){
  1793. var self=this;
  1794. var binding;
  1795. function $ClassRefVar(){return smalltalk.ClassRefVar||(typeof ClassRefVar=="undefined"?nil:ClassRefVar)}
  1796. function $UnknownVar(){return smalltalk.UnknownVar||(typeof UnknownVar=="undefined"?nil:UnknownVar)}
  1797. return smalltalk.withContext(function($ctx1) {
  1798. var $2,$1,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12;
  1799. binding=_st(self["@currentScope"])._lookupVariable_(aNode);
  1800. if(($receiver = binding) == nil || $receiver == null){
  1801. $2=_st(aNode)._value();
  1802. $ctx1.sendIdx["value"]=1;
  1803. $1=_st($2)._isCapitalized();
  1804. if(smalltalk.assert($1)){
  1805. $3=_st($ClassRefVar())._new();
  1806. $ctx1.sendIdx["new"]=1;
  1807. $4=$3;
  1808. $5=_st(aNode)._value();
  1809. $ctx1.sendIdx["value"]=2;
  1810. _st($4)._name_($5);
  1811. $ctx1.sendIdx["name:"]=1;
  1812. $6=_st($3)._yourself();
  1813. $ctx1.sendIdx["yourself"]=1;
  1814. binding=$6;
  1815. binding;
  1816. $7=self._classReferences();
  1817. $8=_st(aNode)._value();
  1818. $ctx1.sendIdx["value"]=3;
  1819. _st($7)._add_($8);
  1820. } else {
  1821. self._errorUnknownVariable_(aNode);
  1822. $9=_st($UnknownVar())._new();
  1823. $10=$9;
  1824. $11=_st(aNode)._value();
  1825. _st($10)._name_($11);
  1826. $12=_st($9)._yourself();
  1827. binding=$12;
  1828. binding;
  1829. };
  1830. } else {
  1831. binding;
  1832. };
  1833. _st(aNode)._binding_(binding);
  1834. return self}, function($ctx1) {$ctx1.fill(self,"visitVariableNode:",{aNode:aNode,binding:binding},smalltalk.SemanticAnalyzer)})},
  1835. args: ["aNode"],
  1836. 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.",
  1837. messageSends: ["lookupVariable:", "ifNil:", "ifTrue:ifFalse:", "isCapitalized", "value", "name:", "new", "yourself", "add:", "classReferences", "errorUnknownVariable:", "binding:"],
  1838. referencedClasses: ["ClassRefVar", "UnknownVar"]
  1839. }),
  1840. smalltalk.SemanticAnalyzer);
  1841. smalltalk.addMethod(
  1842. smalltalk.method({
  1843. selector: "on:",
  1844. category: 'instance creation',
  1845. fn: function (aClass){
  1846. var self=this;
  1847. return smalltalk.withContext(function($ctx1) {
  1848. var $2,$3,$1;
  1849. $2=self._new();
  1850. _st($2)._theClass_(aClass);
  1851. $3=_st($2)._yourself();
  1852. $1=$3;
  1853. return $1;
  1854. }, function($ctx1) {$ctx1.fill(self,"on:",{aClass:aClass},smalltalk.SemanticAnalyzer.klass)})},
  1855. args: ["aClass"],
  1856. source: "on: aClass\x0a\x09^ self new\x0a\x09\x09theClass: aClass;\x0a\x09\x09yourself",
  1857. messageSends: ["theClass:", "new", "yourself"],
  1858. referencedClasses: []
  1859. }),
  1860. smalltalk.SemanticAnalyzer.klass);
  1861. });