Compiler-Semantic.js 61 KB

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