Compiler-Semantic.js 60 KB

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