2
0

Compiler-Semantic.js 59 KB

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