1
0

Compiler-Semantic.js 56 KB

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