1
0

Compiler-Semantic.js 50 KB

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