2
0

Compiler-Semantic.js 65 KB

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