1
0

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(_st(self)._args())._at_put_(aString,_st($ArgVar())._on_(aString));
  13. _st(_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(_st(self)._temps())._at_put_(aString,_st($TempVar())._on_(aString));
  30. _st(_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=_st("$ctx").__comma(_st(_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(_st(self)._args())._keys()).__comma(_st(_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(_st(self)._pseudoVars())._at_ifAbsent_(_st(aStringOrNode)._value(),(function(){
  105. return smalltalk.withContext(function($ctx2) {
  106. return _st(_st(self)._args())._at_ifAbsent_(_st(aStringOrNode)._value(),(function(){
  107. return smalltalk.withContext(function($ctx3) {
  108. return _st(_st(self)._temps())._at_ifAbsent_(_st(aStringOrNode)._value(),(function(){
  109. return smalltalk.withContext(function($ctx4) {
  110. return nil;
  111. }, function($ctx4) {$ctx4.fillBlock({},$ctx1)})}));
  112. }, function($ctx3) {$ctx3.fillBlock({},$ctx1)})}));
  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(_st(self)._isInlined())._and_((function(){
  131. return smalltalk.withContext(function($ctx2) {
  132. return _st(_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(_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(_st(self)._instruction())._notNil())._and_((function(){
  200. return smalltalk.withContext(function($ctx2) {
  201. return _st(_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=_st(self)._bindingFor_(aNode);
  236. $1=lookup;
  237. if(($receiver = $1) == nil || $receiver == undefined){
  238. $2=_st(self)._outerScope();
  239. if(($receiver = $2) == nil || $receiver == undefined){
  240. lookup=$2;
  241. } else {
  242. lookup=_st(_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=_st(self)._outerScope();
  266. if(($receiver = $2) == nil || $receiver == undefined){
  267. $1=$2;
  268. } else {
  269. $1=_st(_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(_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,$5;
  368. $1=_st(self)._outerScope();
  369. if(($receiver = $1) == nil || $receiver == undefined){
  370. $2=(1);
  371. return $2;
  372. } else {
  373. $1;
  374. };
  375. $3=_st(self)._isInlined();
  376. if(smalltalk.assert($3)){
  377. $4=_st(_st(self)._outerScope())._scopeLevel();
  378. return $4;
  379. };
  380. $5=_st(_st(_st(self)._outerScope())._scopeLevel()).__plus((1));
  381. return $5;
  382. }, function($ctx1) {$ctx1.fill(self,"scopeLevel",{},smalltalk.LexicalScope)})},
  383. args: [],
  384. source: "scopeLevel\x0a\x09self outerScope ifNil: [ ^ 1 ].\x0a\x09self isInlined ifTrue: [ ^ self outerScope scopeLevel ].\x0a\x09\x0a\x09^ self outerScope scopeLevel + 1",
  385. messageSends: ["ifNil:", "outerScope", "ifTrue:", "scopeLevel", "isInlined", "+"],
  386. referencedClasses: []
  387. }),
  388. smalltalk.LexicalScope);
  389. smalltalk.addMethod(
  390. smalltalk.method({
  391. selector: "temps",
  392. category: 'accessing',
  393. fn: function (){
  394. var self=this;
  395. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  396. return smalltalk.withContext(function($ctx1) {
  397. var $2,$1;
  398. $2=self["@temps"];
  399. if(($receiver = $2) == nil || $receiver == undefined){
  400. self["@temps"]=_st($Dictionary())._new();
  401. $1=self["@temps"];
  402. } else {
  403. $1=$2;
  404. };
  405. return $1;
  406. }, function($ctx1) {$ctx1.fill(self,"temps",{},smalltalk.LexicalScope)})},
  407. args: [],
  408. source: "temps\x0a\x09^ temps ifNil: [ temps := Dictionary new ]",
  409. messageSends: ["ifNil:", "new"],
  410. referencedClasses: ["Dictionary"]
  411. }),
  412. smalltalk.LexicalScope);
  413. smalltalk.addClass('MethodLexicalScope', smalltalk.LexicalScope, ['iVars', 'pseudoVars', 'unknownVariables', 'localReturn', 'nonLocalReturns'], 'Compiler-Semantic');
  414. smalltalk.MethodLexicalScope.comment="I represent a method scope."
  415. smalltalk.addMethod(
  416. smalltalk.method({
  417. selector: "addIVar:",
  418. category: 'adding',
  419. fn: function (aString){
  420. var self=this;
  421. function $InstanceVar(){return smalltalk.InstanceVar||(typeof InstanceVar=="undefined"?nil:InstanceVar)}
  422. return smalltalk.withContext(function($ctx1) {
  423. _st(_st(self)._iVars())._at_put_(aString,_st($InstanceVar())._on_(aString));
  424. _st(_st(_st(self)._iVars())._at_(aString))._scope_(self);
  425. return self}, function($ctx1) {$ctx1.fill(self,"addIVar:",{aString:aString},smalltalk.MethodLexicalScope)})},
  426. args: ["aString"],
  427. source: "addIVar: aString\x0a\x09self iVars at: aString put: (InstanceVar on: aString).\x0a\x09(self iVars at: aString) scope: self",
  428. messageSends: ["at:put:", "on:", "iVars", "scope:", "at:"],
  429. referencedClasses: ["InstanceVar"]
  430. }),
  431. smalltalk.MethodLexicalScope);
  432. smalltalk.addMethod(
  433. smalltalk.method({
  434. selector: "addNonLocalReturn:",
  435. category: 'adding',
  436. fn: function (aScope){
  437. var self=this;
  438. return smalltalk.withContext(function($ctx1) {
  439. _st(_st(self)._nonLocalReturns())._add_(aScope);
  440. return self}, function($ctx1) {$ctx1.fill(self,"addNonLocalReturn:",{aScope:aScope},smalltalk.MethodLexicalScope)})},
  441. args: ["aScope"],
  442. source: "addNonLocalReturn: aScope\x0a\x09self nonLocalReturns add: aScope",
  443. messageSends: ["add:", "nonLocalReturns"],
  444. referencedClasses: []
  445. }),
  446. smalltalk.MethodLexicalScope);
  447. smalltalk.addMethod(
  448. smalltalk.method({
  449. selector: "allVariableNames",
  450. category: 'accessing',
  451. fn: function (){
  452. var self=this;
  453. return smalltalk.withContext(function($ctx1) {
  454. var $1;
  455. $1=_st(smalltalk.LexicalScope.fn.prototype._allVariableNames.apply(_st(self), [])).__comma(_st(_st(self)._iVars())._keys());
  456. return $1;
  457. }, function($ctx1) {$ctx1.fill(self,"allVariableNames",{},smalltalk.MethodLexicalScope)})},
  458. args: [],
  459. source: "allVariableNames\x0a\x09^ super allVariableNames, self iVars keys",
  460. messageSends: [",", "keys", "iVars", "allVariableNames"],
  461. referencedClasses: []
  462. }),
  463. smalltalk.MethodLexicalScope);
  464. smalltalk.addMethod(
  465. smalltalk.method({
  466. selector: "bindingFor:",
  467. category: 'accessing',
  468. fn: function (aNode){
  469. var self=this;
  470. return smalltalk.withContext(function($ctx1) {
  471. var $2,$1;
  472. $2=smalltalk.LexicalScope.fn.prototype._bindingFor_.apply(_st(self), [aNode]);
  473. if(($receiver = $2) == nil || $receiver == undefined){
  474. $1=_st(_st(self)._iVars())._at_ifAbsent_(_st(aNode)._value(),(function(){
  475. return smalltalk.withContext(function($ctx2) {
  476. return nil;
  477. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  478. } else {
  479. $1=$2;
  480. };
  481. return $1;
  482. }, function($ctx1) {$ctx1.fill(self,"bindingFor:",{aNode:aNode},smalltalk.MethodLexicalScope)})},
  483. args: ["aNode"],
  484. source: "bindingFor: aNode\x0a\x09^ (super bindingFor: aNode) ifNil: [\x0a\x09\x09self iVars at: aNode value ifAbsent: [ nil ]]",
  485. messageSends: ["ifNil:", "at:ifAbsent:", "value", "iVars", "bindingFor:"],
  486. referencedClasses: []
  487. }),
  488. smalltalk.MethodLexicalScope);
  489. smalltalk.addMethod(
  490. smalltalk.method({
  491. selector: "canInlineNonLocalReturns",
  492. category: 'testing',
  493. fn: function (){
  494. var self=this;
  495. return smalltalk.withContext(function($ctx1) {
  496. return true;
  497. }, function($ctx1) {$ctx1.fill(self,"canInlineNonLocalReturns",{},smalltalk.MethodLexicalScope)})},
  498. args: [],
  499. source: "canInlineNonLocalReturns\x0a\x09^ true",
  500. messageSends: [],
  501. referencedClasses: []
  502. }),
  503. smalltalk.MethodLexicalScope);
  504. smalltalk.addMethod(
  505. smalltalk.method({
  506. selector: "hasLocalReturn",
  507. category: 'testing',
  508. fn: function (){
  509. var self=this;
  510. return smalltalk.withContext(function($ctx1) {
  511. var $1;
  512. $1=_st(self)._localReturn();
  513. return $1;
  514. }, function($ctx1) {$ctx1.fill(self,"hasLocalReturn",{},smalltalk.MethodLexicalScope)})},
  515. args: [],
  516. source: "hasLocalReturn\x0a\x09^ self localReturn",
  517. messageSends: ["localReturn"],
  518. referencedClasses: []
  519. }),
  520. smalltalk.MethodLexicalScope);
  521. smalltalk.addMethod(
  522. smalltalk.method({
  523. selector: "hasNonLocalReturn",
  524. category: 'testing',
  525. fn: function (){
  526. var self=this;
  527. return smalltalk.withContext(function($ctx1) {
  528. var $1;
  529. $1=_st(_st(self)._nonLocalReturns())._notEmpty();
  530. return $1;
  531. }, function($ctx1) {$ctx1.fill(self,"hasNonLocalReturn",{},smalltalk.MethodLexicalScope)})},
  532. args: [],
  533. source: "hasNonLocalReturn\x0a\x09^ self nonLocalReturns notEmpty",
  534. messageSends: ["notEmpty", "nonLocalReturns"],
  535. referencedClasses: []
  536. }),
  537. smalltalk.MethodLexicalScope);
  538. smalltalk.addMethod(
  539. smalltalk.method({
  540. selector: "iVars",
  541. category: 'accessing',
  542. fn: function (){
  543. var self=this;
  544. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  545. return smalltalk.withContext(function($ctx1) {
  546. var $2,$1;
  547. $2=self["@iVars"];
  548. if(($receiver = $2) == nil || $receiver == undefined){
  549. self["@iVars"]=_st($Dictionary())._new();
  550. $1=self["@iVars"];
  551. } else {
  552. $1=$2;
  553. };
  554. return $1;
  555. }, function($ctx1) {$ctx1.fill(self,"iVars",{},smalltalk.MethodLexicalScope)})},
  556. args: [],
  557. source: "iVars\x0a\x09^ iVars ifNil: [ iVars := Dictionary new ]",
  558. messageSends: ["ifNil:", "new"],
  559. referencedClasses: ["Dictionary"]
  560. }),
  561. smalltalk.MethodLexicalScope);
  562. smalltalk.addMethod(
  563. smalltalk.method({
  564. selector: "isMethodScope",
  565. category: 'testing',
  566. fn: function (){
  567. var self=this;
  568. return smalltalk.withContext(function($ctx1) {
  569. return true;
  570. }, function($ctx1) {$ctx1.fill(self,"isMethodScope",{},smalltalk.MethodLexicalScope)})},
  571. args: [],
  572. source: "isMethodScope\x0a\x09^ true",
  573. messageSends: [],
  574. referencedClasses: []
  575. }),
  576. smalltalk.MethodLexicalScope);
  577. smalltalk.addMethod(
  578. smalltalk.method({
  579. selector: "localReturn",
  580. category: 'accessing',
  581. fn: function (){
  582. var self=this;
  583. return smalltalk.withContext(function($ctx1) {
  584. var $2,$1;
  585. $2=self["@localReturn"];
  586. if(($receiver = $2) == nil || $receiver == undefined){
  587. $1=false;
  588. } else {
  589. $1=$2;
  590. };
  591. return $1;
  592. }, function($ctx1) {$ctx1.fill(self,"localReturn",{},smalltalk.MethodLexicalScope)})},
  593. args: [],
  594. source: "localReturn\x0a\x09^ localReturn ifNil: [ false ]",
  595. messageSends: ["ifNil:"],
  596. referencedClasses: []
  597. }),
  598. smalltalk.MethodLexicalScope);
  599. smalltalk.addMethod(
  600. smalltalk.method({
  601. selector: "localReturn:",
  602. category: 'accessing',
  603. fn: function (aBoolean){
  604. var self=this;
  605. return smalltalk.withContext(function($ctx1) {
  606. self["@localReturn"]=aBoolean;
  607. return self}, function($ctx1) {$ctx1.fill(self,"localReturn:",{aBoolean:aBoolean},smalltalk.MethodLexicalScope)})},
  608. args: ["aBoolean"],
  609. source: "localReturn: aBoolean\x0a\x09localReturn := aBoolean",
  610. messageSends: [],
  611. referencedClasses: []
  612. }),
  613. smalltalk.MethodLexicalScope);
  614. smalltalk.addMethod(
  615. smalltalk.method({
  616. selector: "methodScope",
  617. category: 'accessing',
  618. fn: function (){
  619. var self=this;
  620. return smalltalk.withContext(function($ctx1) {
  621. var $1;
  622. $1=self;
  623. return $1;
  624. }, function($ctx1) {$ctx1.fill(self,"methodScope",{},smalltalk.MethodLexicalScope)})},
  625. args: [],
  626. source: "methodScope\x0a\x09^ self",
  627. messageSends: [],
  628. referencedClasses: []
  629. }),
  630. smalltalk.MethodLexicalScope);
  631. smalltalk.addMethod(
  632. smalltalk.method({
  633. selector: "nonLocalReturns",
  634. category: 'accessing',
  635. fn: function (){
  636. var self=this;
  637. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  638. return smalltalk.withContext(function($ctx1) {
  639. var $2,$1;
  640. $2=self["@nonLocalReturns"];
  641. if(($receiver = $2) == nil || $receiver == undefined){
  642. self["@nonLocalReturns"]=_st($OrderedCollection())._new();
  643. $1=self["@nonLocalReturns"];
  644. } else {
  645. $1=$2;
  646. };
  647. return $1;
  648. }, function($ctx1) {$ctx1.fill(self,"nonLocalReturns",{},smalltalk.MethodLexicalScope)})},
  649. args: [],
  650. source: "nonLocalReturns\x0a\x09^ nonLocalReturns ifNil: [ nonLocalReturns := OrderedCollection new ]",
  651. messageSends: ["ifNil:", "new"],
  652. referencedClasses: ["OrderedCollection"]
  653. }),
  654. smalltalk.MethodLexicalScope);
  655. smalltalk.addMethod(
  656. smalltalk.method({
  657. selector: "pseudoVars",
  658. category: 'accessing',
  659. fn: function (){
  660. var self=this;
  661. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  662. function $PseudoVar(){return smalltalk.PseudoVar||(typeof PseudoVar=="undefined"?nil:PseudoVar)}
  663. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  664. return smalltalk.withContext(function($ctx1) {
  665. var $1,$2,$3,$4;
  666. $1=self["@pseudoVars"];
  667. if(($receiver = $1) == nil || $receiver == undefined){
  668. self["@pseudoVars"]=_st($Dictionary())._new();
  669. self["@pseudoVars"];
  670. _st(_st(_st($Smalltalk())._current())._pseudoVariableNames())._do_((function(each){
  671. return smalltalk.withContext(function($ctx2) {
  672. $2=_st($PseudoVar())._on_(each);
  673. _st($2)._scope_(_st(self)._methodScope());
  674. $3=_st($2)._yourself();
  675. return _st(self["@pseudoVars"])._at_put_(each,$3);
  676. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  677. } else {
  678. $1;
  679. };
  680. $4=self["@pseudoVars"];
  681. return $4;
  682. }, function($ctx1) {$ctx1.fill(self,"pseudoVars",{},smalltalk.MethodLexicalScope)})},
  683. args: [],
  684. 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",
  685. messageSends: ["ifNil:", "new", "do:", "at:put:", "scope:", "methodScope", "on:", "yourself", "pseudoVariableNames", "current"],
  686. referencedClasses: ["Dictionary", "PseudoVar", "Smalltalk"]
  687. }),
  688. smalltalk.MethodLexicalScope);
  689. smalltalk.addMethod(
  690. smalltalk.method({
  691. selector: "removeNonLocalReturn:",
  692. category: 'adding',
  693. fn: function (aScope){
  694. var self=this;
  695. return smalltalk.withContext(function($ctx1) {
  696. _st(_st(self)._nonLocalReturns())._remove_ifAbsent_(aScope,(function(){
  697. return smalltalk.withContext(function($ctx2) {
  698. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  699. return self}, function($ctx1) {$ctx1.fill(self,"removeNonLocalReturn:",{aScope:aScope},smalltalk.MethodLexicalScope)})},
  700. args: ["aScope"],
  701. source: "removeNonLocalReturn: aScope\x0a\x09self nonLocalReturns remove: aScope ifAbsent: []",
  702. messageSends: ["remove:ifAbsent:", "nonLocalReturns"],
  703. referencedClasses: []
  704. }),
  705. smalltalk.MethodLexicalScope);
  706. smalltalk.addMethod(
  707. smalltalk.method({
  708. selector: "unknownVariables",
  709. category: 'accessing',
  710. fn: function (){
  711. var self=this;
  712. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  713. return smalltalk.withContext(function($ctx1) {
  714. var $2,$1;
  715. $2=self["@unknownVariables"];
  716. if(($receiver = $2) == nil || $receiver == undefined){
  717. self["@unknownVariables"]=_st($OrderedCollection())._new();
  718. $1=self["@unknownVariables"];
  719. } else {
  720. $1=$2;
  721. };
  722. return $1;
  723. }, function($ctx1) {$ctx1.fill(self,"unknownVariables",{},smalltalk.MethodLexicalScope)})},
  724. args: [],
  725. source: "unknownVariables\x0a\x09^ unknownVariables ifNil: [ unknownVariables := OrderedCollection new ]",
  726. messageSends: ["ifNil:", "new"],
  727. referencedClasses: ["OrderedCollection"]
  728. }),
  729. smalltalk.MethodLexicalScope);
  730. smalltalk.addClass('ScopeVar', smalltalk.Object, ['scope', 'name'], 'Compiler-Semantic');
  731. 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."
  732. smalltalk.addMethod(
  733. smalltalk.method({
  734. selector: "alias",
  735. category: 'accessing',
  736. fn: function (){
  737. var self=this;
  738. return smalltalk.withContext(function($ctx1) {
  739. var $1;
  740. $1=_st(_st(self)._name())._asVariableName();
  741. return $1;
  742. }, function($ctx1) {$ctx1.fill(self,"alias",{},smalltalk.ScopeVar)})},
  743. args: [],
  744. source: "alias\x0a\x09^ self name asVariableName",
  745. messageSends: ["asVariableName", "name"],
  746. referencedClasses: []
  747. }),
  748. smalltalk.ScopeVar);
  749. smalltalk.addMethod(
  750. smalltalk.method({
  751. selector: "isArgVar",
  752. category: 'testing',
  753. fn: function (){
  754. var self=this;
  755. return smalltalk.withContext(function($ctx1) {
  756. return false;
  757. }, function($ctx1) {$ctx1.fill(self,"isArgVar",{},smalltalk.ScopeVar)})},
  758. args: [],
  759. source: "isArgVar\x0a\x09^ false",
  760. messageSends: [],
  761. referencedClasses: []
  762. }),
  763. smalltalk.ScopeVar);
  764. smalltalk.addMethod(
  765. smalltalk.method({
  766. selector: "isClassRefVar",
  767. category: 'testing',
  768. fn: function (){
  769. var self=this;
  770. return smalltalk.withContext(function($ctx1) {
  771. return false;
  772. }, function($ctx1) {$ctx1.fill(self,"isClassRefVar",{},smalltalk.ScopeVar)})},
  773. args: [],
  774. source: "isClassRefVar\x0a\x09^ false",
  775. messageSends: [],
  776. referencedClasses: []
  777. }),
  778. smalltalk.ScopeVar);
  779. smalltalk.addMethod(
  780. smalltalk.method({
  781. selector: "isInstanceVar",
  782. category: 'testing',
  783. fn: function (){
  784. var self=this;
  785. return smalltalk.withContext(function($ctx1) {
  786. return false;
  787. }, function($ctx1) {$ctx1.fill(self,"isInstanceVar",{},smalltalk.ScopeVar)})},
  788. args: [],
  789. source: "isInstanceVar\x0a\x09^ false",
  790. messageSends: [],
  791. referencedClasses: []
  792. }),
  793. smalltalk.ScopeVar);
  794. smalltalk.addMethod(
  795. smalltalk.method({
  796. selector: "isPseudoVar",
  797. category: 'testing',
  798. fn: function (){
  799. var self=this;
  800. return smalltalk.withContext(function($ctx1) {
  801. return false;
  802. }, function($ctx1) {$ctx1.fill(self,"isPseudoVar",{},smalltalk.ScopeVar)})},
  803. args: [],
  804. source: "isPseudoVar\x0a\x09^ false",
  805. messageSends: [],
  806. referencedClasses: []
  807. }),
  808. smalltalk.ScopeVar);
  809. smalltalk.addMethod(
  810. smalltalk.method({
  811. selector: "isTempVar",
  812. category: 'testing',
  813. fn: function (){
  814. var self=this;
  815. return smalltalk.withContext(function($ctx1) {
  816. return false;
  817. }, function($ctx1) {$ctx1.fill(self,"isTempVar",{},smalltalk.ScopeVar)})},
  818. args: [],
  819. source: "isTempVar\x0a\x09^ false",
  820. messageSends: [],
  821. referencedClasses: []
  822. }),
  823. smalltalk.ScopeVar);
  824. smalltalk.addMethod(
  825. smalltalk.method({
  826. selector: "isUnknownVar",
  827. category: 'testing',
  828. fn: function (){
  829. var self=this;
  830. return smalltalk.withContext(function($ctx1) {
  831. return false;
  832. }, function($ctx1) {$ctx1.fill(self,"isUnknownVar",{},smalltalk.ScopeVar)})},
  833. args: [],
  834. source: "isUnknownVar\x0a\x09^ false",
  835. messageSends: [],
  836. referencedClasses: []
  837. }),
  838. smalltalk.ScopeVar);
  839. smalltalk.addMethod(
  840. smalltalk.method({
  841. selector: "name",
  842. category: 'accessing',
  843. fn: function (){
  844. var self=this;
  845. return smalltalk.withContext(function($ctx1) {
  846. var $1;
  847. $1=self["@name"];
  848. return $1;
  849. }, function($ctx1) {$ctx1.fill(self,"name",{},smalltalk.ScopeVar)})},
  850. args: [],
  851. source: "name\x0a\x09^ name",
  852. messageSends: [],
  853. referencedClasses: []
  854. }),
  855. smalltalk.ScopeVar);
  856. smalltalk.addMethod(
  857. smalltalk.method({
  858. selector: "name:",
  859. category: 'accessing',
  860. fn: function (aString){
  861. var self=this;
  862. return smalltalk.withContext(function($ctx1) {
  863. self["@name"]=aString;
  864. return self}, function($ctx1) {$ctx1.fill(self,"name:",{aString:aString},smalltalk.ScopeVar)})},
  865. args: ["aString"],
  866. source: "name: aString\x0a\x09name := aString",
  867. messageSends: [],
  868. referencedClasses: []
  869. }),
  870. smalltalk.ScopeVar);
  871. smalltalk.addMethod(
  872. smalltalk.method({
  873. selector: "scope",
  874. category: 'accessing',
  875. fn: function (){
  876. var self=this;
  877. return smalltalk.withContext(function($ctx1) {
  878. var $1;
  879. $1=self["@scope"];
  880. return $1;
  881. }, function($ctx1) {$ctx1.fill(self,"scope",{},smalltalk.ScopeVar)})},
  882. args: [],
  883. source: "scope\x0a\x09^ scope",
  884. messageSends: [],
  885. referencedClasses: []
  886. }),
  887. smalltalk.ScopeVar);
  888. smalltalk.addMethod(
  889. smalltalk.method({
  890. selector: "scope:",
  891. category: 'accessing',
  892. fn: function (aScope){
  893. var self=this;
  894. return smalltalk.withContext(function($ctx1) {
  895. self["@scope"]=aScope;
  896. return self}, function($ctx1) {$ctx1.fill(self,"scope:",{aScope:aScope},smalltalk.ScopeVar)})},
  897. args: ["aScope"],
  898. source: "scope: aScope\x0a\x09scope := aScope",
  899. messageSends: [],
  900. referencedClasses: []
  901. }),
  902. smalltalk.ScopeVar);
  903. smalltalk.addMethod(
  904. smalltalk.method({
  905. selector: "validateAssignment",
  906. category: 'testing',
  907. fn: function (){
  908. var self=this;
  909. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  910. return smalltalk.withContext(function($ctx1) {
  911. var $1,$2,$3;
  912. $1=_st(_st(self)._isArgVar())._or_((function(){
  913. return smalltalk.withContext(function($ctx2) {
  914. return _st(self)._isPseudoVar();
  915. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  916. if(smalltalk.assert($1)){
  917. $2=_st($InvalidAssignmentError())._new();
  918. _st($2)._variableName_(_st(self)._name());
  919. $3=_st($2)._signal();
  920. $3;
  921. };
  922. return self}, function($ctx1) {$ctx1.fill(self,"validateAssignment",{},smalltalk.ScopeVar)})},
  923. args: [],
  924. source: "validateAssignment\x0a\x09(self isArgVar or: [ self isPseudoVar ]) ifTrue: [\x0a\x09\x09InvalidAssignmentError new\x0a\x09\x09\x09variableName: self name;\x0a\x09\x09\x09signal]",
  925. messageSends: ["ifTrue:", "variableName:", "name", "new", "signal", "or:", "isPseudoVar", "isArgVar"],
  926. referencedClasses: ["InvalidAssignmentError"]
  927. }),
  928. smalltalk.ScopeVar);
  929. smalltalk.addMethod(
  930. smalltalk.method({
  931. selector: "on:",
  932. category: 'instance creation',
  933. fn: function (aString){
  934. var self=this;
  935. return smalltalk.withContext(function($ctx1) {
  936. var $2,$3,$1;
  937. $2=_st(self)._new();
  938. _st($2)._name_(aString);
  939. $3=_st($2)._yourself();
  940. $1=$3;
  941. return $1;
  942. }, function($ctx1) {$ctx1.fill(self,"on:",{aString:aString},smalltalk.ScopeVar.klass)})},
  943. args: ["aString"],
  944. source: "on: aString\x0a\x09^ self new\x0a\x09\x09name: aString;\x0a\x09\x09yourself",
  945. messageSends: ["name:", "new", "yourself"],
  946. referencedClasses: []
  947. }),
  948. smalltalk.ScopeVar.klass);
  949. smalltalk.addClass('AliasVar', smalltalk.ScopeVar, ['node'], 'Compiler-Semantic');
  950. smalltalk.AliasVar.comment="I am an internally defined variable by the compiler"
  951. smalltalk.addMethod(
  952. smalltalk.method({
  953. selector: "node",
  954. category: 'accessing',
  955. fn: function (){
  956. var self=this;
  957. return smalltalk.withContext(function($ctx1) {
  958. var $1;
  959. $1=self["@node"];
  960. return $1;
  961. }, function($ctx1) {$ctx1.fill(self,"node",{},smalltalk.AliasVar)})},
  962. args: [],
  963. source: "node\x0a\x09^ node",
  964. messageSends: [],
  965. referencedClasses: []
  966. }),
  967. smalltalk.AliasVar);
  968. smalltalk.addMethod(
  969. smalltalk.method({
  970. selector: "node:",
  971. category: 'accessing',
  972. fn: function (aNode){
  973. var self=this;
  974. return smalltalk.withContext(function($ctx1) {
  975. self["@node"]=aNode;
  976. return self}, function($ctx1) {$ctx1.fill(self,"node:",{aNode:aNode},smalltalk.AliasVar)})},
  977. args: ["aNode"],
  978. source: "node: aNode\x0a\x09node := aNode",
  979. messageSends: [],
  980. referencedClasses: []
  981. }),
  982. smalltalk.AliasVar);
  983. smalltalk.addClass('ArgVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  984. smalltalk.ArgVar.comment="I am an argument of a method or block."
  985. smalltalk.addMethod(
  986. smalltalk.method({
  987. selector: "isArgVar",
  988. category: 'testing',
  989. fn: function (){
  990. var self=this;
  991. return smalltalk.withContext(function($ctx1) {
  992. return true;
  993. }, function($ctx1) {$ctx1.fill(self,"isArgVar",{},smalltalk.ArgVar)})},
  994. args: [],
  995. source: "isArgVar\x0a\x09^ true",
  996. messageSends: [],
  997. referencedClasses: []
  998. }),
  999. smalltalk.ArgVar);
  1000. smalltalk.addClass('ClassRefVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1001. smalltalk.ClassRefVar.comment="I am an class reference variable"
  1002. smalltalk.addMethod(
  1003. smalltalk.method({
  1004. selector: "alias",
  1005. category: 'accessing',
  1006. fn: function (){
  1007. var self=this;
  1008. return smalltalk.withContext(function($ctx1) {
  1009. var $1;
  1010. $1=_st(_st("$").__comma(_st(self)._name())).__comma("()");
  1011. return $1;
  1012. }, function($ctx1) {$ctx1.fill(self,"alias",{},smalltalk.ClassRefVar)})},
  1013. args: [],
  1014. 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, '()'",
  1015. messageSends: [",", "name"],
  1016. referencedClasses: []
  1017. }),
  1018. smalltalk.ClassRefVar);
  1019. smalltalk.addMethod(
  1020. smalltalk.method({
  1021. selector: "isClassRefVar",
  1022. category: 'testing',
  1023. fn: function (){
  1024. var self=this;
  1025. return smalltalk.withContext(function($ctx1) {
  1026. return true;
  1027. }, function($ctx1) {$ctx1.fill(self,"isClassRefVar",{},smalltalk.ClassRefVar)})},
  1028. args: [],
  1029. source: "isClassRefVar\x0a\x09^ true",
  1030. messageSends: [],
  1031. referencedClasses: []
  1032. }),
  1033. smalltalk.ClassRefVar);
  1034. smalltalk.addClass('InstanceVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1035. smalltalk.InstanceVar.comment="I am an instance variable of a method or block."
  1036. smalltalk.addMethod(
  1037. smalltalk.method({
  1038. selector: "alias",
  1039. category: 'testing',
  1040. fn: function (){
  1041. var self=this;
  1042. return smalltalk.withContext(function($ctx1) {
  1043. var $1;
  1044. $1=_st(_st("self[\x22@").__comma(_st(self)._name())).__comma("\x22]");
  1045. return $1;
  1046. }, function($ctx1) {$ctx1.fill(self,"alias",{},smalltalk.InstanceVar)})},
  1047. args: [],
  1048. source: "alias\x0a\x09^ 'self[\x22@', self name, '\x22]'",
  1049. messageSends: [",", "name"],
  1050. referencedClasses: []
  1051. }),
  1052. smalltalk.InstanceVar);
  1053. smalltalk.addMethod(
  1054. smalltalk.method({
  1055. selector: "isInstanceVar",
  1056. category: 'testing',
  1057. fn: function (){
  1058. var self=this;
  1059. return smalltalk.withContext(function($ctx1) {
  1060. return true;
  1061. }, function($ctx1) {$ctx1.fill(self,"isInstanceVar",{},smalltalk.InstanceVar)})},
  1062. args: [],
  1063. source: "isInstanceVar\x0a\x09^ true",
  1064. messageSends: [],
  1065. referencedClasses: []
  1066. }),
  1067. smalltalk.InstanceVar);
  1068. smalltalk.addClass('PseudoVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1069. smalltalk.PseudoVar.comment="I am an pseudo variable.\x0a\x0aThe five Smalltalk pseudo variables are: 'self', 'super', 'nil', 'true' and 'false'"
  1070. smalltalk.addMethod(
  1071. smalltalk.method({
  1072. selector: "alias",
  1073. category: 'accessing',
  1074. fn: function (){
  1075. var self=this;
  1076. return smalltalk.withContext(function($ctx1) {
  1077. var $1;
  1078. $1=_st(self)._name();
  1079. return $1;
  1080. }, function($ctx1) {$ctx1.fill(self,"alias",{},smalltalk.PseudoVar)})},
  1081. args: [],
  1082. source: "alias\x0a\x09^ self name",
  1083. messageSends: ["name"],
  1084. referencedClasses: []
  1085. }),
  1086. smalltalk.PseudoVar);
  1087. smalltalk.addMethod(
  1088. smalltalk.method({
  1089. selector: "isPseudoVar",
  1090. category: 'testing',
  1091. fn: function (){
  1092. var self=this;
  1093. return smalltalk.withContext(function($ctx1) {
  1094. return true;
  1095. }, function($ctx1) {$ctx1.fill(self,"isPseudoVar",{},smalltalk.PseudoVar)})},
  1096. args: [],
  1097. source: "isPseudoVar\x0a\x09^ true",
  1098. messageSends: [],
  1099. referencedClasses: []
  1100. }),
  1101. smalltalk.PseudoVar);
  1102. smalltalk.addClass('TempVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1103. smalltalk.TempVar.comment="I am an temporary variable of a method or block."
  1104. smalltalk.addMethod(
  1105. smalltalk.method({
  1106. selector: "isTempVar",
  1107. category: 'testing',
  1108. fn: function (){
  1109. var self=this;
  1110. return smalltalk.withContext(function($ctx1) {
  1111. return true;
  1112. }, function($ctx1) {$ctx1.fill(self,"isTempVar",{},smalltalk.TempVar)})},
  1113. args: [],
  1114. source: "isTempVar\x0a\x09^ true",
  1115. messageSends: [],
  1116. referencedClasses: []
  1117. }),
  1118. smalltalk.TempVar);
  1119. smalltalk.addClass('UnknownVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  1120. smalltalk.UnknownVar.comment="I am an unknown variable. Amber uses unknown variables as JavaScript globals"
  1121. smalltalk.addMethod(
  1122. smalltalk.method({
  1123. selector: "isUnknownVar",
  1124. category: 'testing',
  1125. fn: function (){
  1126. var self=this;
  1127. return smalltalk.withContext(function($ctx1) {
  1128. return true;
  1129. }, function($ctx1) {$ctx1.fill(self,"isUnknownVar",{},smalltalk.UnknownVar)})},
  1130. args: [],
  1131. source: "isUnknownVar\x0a\x09^ true",
  1132. messageSends: [],
  1133. referencedClasses: []
  1134. }),
  1135. smalltalk.UnknownVar);
  1136. smalltalk.addClass('SemanticAnalyzer', smalltalk.NodeVisitor, ['currentScope', 'theClass', 'classReferences', 'messageSends', 'superSends'], 'Compiler-Semantic');
  1137. smalltalk.SemanticAnalyzer.comment="I semantically analyze the abstract syntax tree and annotate it with informations such as non local returns and variable scopes."
  1138. smalltalk.addMethod(
  1139. smalltalk.method({
  1140. selector: "classReferences",
  1141. category: 'accessing',
  1142. fn: function (){
  1143. var self=this;
  1144. function $Set(){return smalltalk.Set||(typeof Set=="undefined"?nil:Set)}
  1145. return smalltalk.withContext(function($ctx1) {
  1146. var $2,$1;
  1147. $2=self["@classReferences"];
  1148. if(($receiver = $2) == nil || $receiver == undefined){
  1149. self["@classReferences"]=_st($Set())._new();
  1150. $1=self["@classReferences"];
  1151. } else {
  1152. $1=$2;
  1153. };
  1154. return $1;
  1155. }, function($ctx1) {$ctx1.fill(self,"classReferences",{},smalltalk.SemanticAnalyzer)})},
  1156. args: [],
  1157. source: "classReferences\x0a\x09^ classReferences ifNil: [ classReferences := Set new ]",
  1158. messageSends: ["ifNil:", "new"],
  1159. referencedClasses: ["Set"]
  1160. }),
  1161. smalltalk.SemanticAnalyzer);
  1162. smalltalk.addMethod(
  1163. smalltalk.method({
  1164. selector: "errorShadowingVariable:",
  1165. category: 'error handling',
  1166. fn: function (aString){
  1167. var self=this;
  1168. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1169. return smalltalk.withContext(function($ctx1) {
  1170. var $1,$2;
  1171. $1=_st($ShadowingVariableError())._new();
  1172. _st($1)._variableName_(aString);
  1173. $2=_st($1)._signal();
  1174. return self}, function($ctx1) {$ctx1.fill(self,"errorShadowingVariable:",{aString:aString},smalltalk.SemanticAnalyzer)})},
  1175. args: ["aString"],
  1176. source: "errorShadowingVariable: aString\x0a\x09ShadowingVariableError new\x0a\x09\x09variableName: aString;\x0a\x09\x09signal",
  1177. messageSends: ["variableName:", "new", "signal"],
  1178. referencedClasses: ["ShadowingVariableError"]
  1179. }),
  1180. smalltalk.SemanticAnalyzer);
  1181. smalltalk.addMethod(
  1182. smalltalk.method({
  1183. selector: "errorUnknownVariable:",
  1184. category: 'error handling',
  1185. fn: function (aNode){
  1186. var self=this;
  1187. var identifier;
  1188. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1189. return smalltalk.withContext(function($ctx1) {
  1190. var $1,$2,$3;
  1191. identifier=_st(aNode)._value();
  1192. $1=_st(_st(_st(["jQuery", "window", "document", "process", "global"])._includes_(identifier))._not())._and_((function(){
  1193. return smalltalk.withContext(function($ctx2) {
  1194. return _st(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 four variable names in addition: `jQuery`, `window`, `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((#('jQuery' 'window' 'document' 'process' 'global') 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:"],
  1208. referencedClasses: ["UnknownVariableError"]
  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=_st(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=_st(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. _st(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.NodeVisitor.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. _st(self)._pushScope_(_st(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. _st(self)._validateVariableScope_(each);
  1450. return _st(self["@currentScope"])._addArg_(each);
  1451. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1452. smalltalk.NodeVisitor.fn.prototype._visitBlockNode_.apply(_st(self), [aNode]);
  1453. _st(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.NodeVisitor.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(_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. _st(self)._pushScope_(_st(self)._newMethodScope());
  1518. _st(aNode)._scope_(self["@currentScope"]);
  1519. _st(self["@currentScope"])._node_(aNode);
  1520. _st(_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. _st(self)._validateVariableScope_(each);
  1527. return _st(self["@currentScope"])._addArg_(each);
  1528. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1529. smalltalk.NodeVisitor.fn.prototype._visitMethodNode_.apply(_st(self), [aNode]);
  1530. $1=aNode;
  1531. _st($1)._classReferences_(_st(self)._classReferences());
  1532. _st($1)._messageSends_(_st(_st(self)._messageSends())._keys());
  1533. $2=_st($1)._superSends_(_st(_st(self)._superSends())._keys());
  1534. _st(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.NodeVisitor.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(_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(_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(_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(_st(self)._messageSends())._at_(_st(aNode)._selector()))._add_(aNode);
  1596. _st(aNode)._index_(_st(_st(_st(self)._messageSends())._at_(_st(aNode)._selector()))._size());
  1597. smalltalk.NodeVisitor.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. _st(self)._validateVariableScope_(each);
  1615. return _st(self["@currentScope"])._addTemp_(each);
  1616. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  1617. smalltalk.NodeVisitor.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. _st(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=_st(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);