1
0

Compiler-Semantic.js 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145
  1. smalltalk.addPackage('Compiler-Semantic', {});
  2. smalltalk.addClass('InvalidAssignmentError', smalltalk.SemanticError, ['variableName'], 'Compiler-Semantic');
  3. smalltalk.InvalidAssignmentError.comment="I get signaled when a pseudo variable gets assigned."
  4. smalltalk.addMethod(
  5. "_variableName",
  6. smalltalk.method({
  7. selector: "variableName",
  8. category: 'accessing',
  9. fn: function () {
  10. var self=this;
  11. return self['@variableName'];
  12. return self;},
  13. args: [],
  14. source: "variableName\x0a\x09^ variableName",
  15. messageSends: [],
  16. referencedClasses: []
  17. }),
  18. smalltalk.InvalidAssignmentError);
  19. smalltalk.addMethod(
  20. "_variableName_",
  21. smalltalk.method({
  22. selector: "variableName:",
  23. category: 'accessing',
  24. fn: function (aString) {
  25. var self=this;
  26. (self['@variableName']=aString);
  27. return self;},
  28. args: ["aString"],
  29. source: "variableName: aString\x0a\x09variableName := aString",
  30. messageSends: [],
  31. referencedClasses: []
  32. }),
  33. smalltalk.InvalidAssignmentError);
  34. smalltalk.addClass('LexicalScope', smalltalk.Object, ['node', 'temps', 'args', 'outerScope'], 'Compiler-Semantic');
  35. 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."
  36. smalltalk.addMethod(
  37. "_addArg_",
  38. smalltalk.method({
  39. selector: "addArg:",
  40. category: 'adding',
  41. fn: function (aString) {
  42. var self=this;
  43. smalltalk.send(smalltalk.send(self, "_args", []), "_at_put_", [aString, smalltalk.send((smalltalk.ArgVar || ArgVar), "_on_", [aString])]);
  44. smalltalk.send(smalltalk.send(smalltalk.send(self, "_args", []), "_at_", [aString]), "_scope_", [self]);
  45. return self;},
  46. args: ["aString"],
  47. source: "addArg: aString\x0a\x09self args at: aString put: (ArgVar on: aString).\x0a\x09(self args at: aString) scope: self",
  48. messageSends: ["at:put:", "args", "on:", "scope:", "at:"],
  49. referencedClasses: ["ArgVar"]
  50. }),
  51. smalltalk.LexicalScope);
  52. smalltalk.addMethod(
  53. "_addTemp_",
  54. smalltalk.method({
  55. selector: "addTemp:",
  56. category: 'adding',
  57. fn: function (aString) {
  58. var self=this;
  59. smalltalk.send(smalltalk.send(self, "_temps", []), "_at_put_", [aString, smalltalk.send((smalltalk.TempVar || TempVar), "_on_", [aString])]);
  60. smalltalk.send(smalltalk.send(smalltalk.send(self, "_temps", []), "_at_", [aString]), "_scope_", [self]);
  61. return self;},
  62. args: ["aString"],
  63. source: "addTemp: aString\x0a\x09self temps at: aString put: (TempVar on: aString).\x0a\x09(self temps at: aString) scope: self",
  64. messageSends: ["at:put:", "temps", "on:", "scope:", "at:"],
  65. referencedClasses: ["TempVar"]
  66. }),
  67. smalltalk.LexicalScope);
  68. smalltalk.addMethod(
  69. "_allVariableNames",
  70. smalltalk.method({
  71. selector: "allVariableNames",
  72. category: 'accessing',
  73. fn: function () {
  74. var self=this;
  75. return smalltalk.send(smalltalk.send(smalltalk.send(self, "_args", []), "_keys", []), "__comma", [smalltalk.send(smalltalk.send(self, "_temps", []), "_keys", [])]);
  76. return self;},
  77. args: [],
  78. source: "allVariableNames\x0a\x09^ self args keys, self temps keys",
  79. messageSends: [",", "keys", "args", "temps"],
  80. referencedClasses: []
  81. }),
  82. smalltalk.LexicalScope);
  83. smalltalk.addMethod(
  84. "_args",
  85. smalltalk.method({
  86. selector: "args",
  87. category: 'accessing',
  88. fn: function () {
  89. var self=this;
  90. return (($receiver = self['@args']) == nil || $receiver == undefined) ? (function(){return (self['@args']=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));})() : $receiver;
  91. return self;},
  92. args: [],
  93. source: "args\x0a\x09^ args ifNil: [ args := Dictionary new ]",
  94. messageSends: ["ifNil:", "new"],
  95. referencedClasses: ["Dictionary"]
  96. }),
  97. smalltalk.LexicalScope);
  98. smalltalk.addMethod(
  99. "_bindingFor_",
  100. smalltalk.method({
  101. selector: "bindingFor:",
  102. category: 'accessing',
  103. fn: function (aStringOrNode) {
  104. var self=this;
  105. 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;})]);})]);
  106. return self;},
  107. args: ["aStringOrNode"],
  108. source: "bindingFor: aStringOrNode\x0a\x09^ self args at: aStringOrNode value ifAbsent: [\x0a\x09\x09self temps at: aStringOrNode value ifAbsent: [ nil ]]",
  109. messageSends: ["at:ifAbsent:", "args", "value", "temps"],
  110. referencedClasses: []
  111. }),
  112. smalltalk.LexicalScope);
  113. smalltalk.addMethod(
  114. "_isMethodScope",
  115. smalltalk.method({
  116. selector: "isMethodScope",
  117. category: 'testing',
  118. fn: function () {
  119. var self=this;
  120. return false;
  121. return self;},
  122. args: [],
  123. source: "isMethodScope\x0a\x09^ false",
  124. messageSends: [],
  125. referencedClasses: []
  126. }),
  127. smalltalk.LexicalScope);
  128. smalltalk.addMethod(
  129. "_lookupVariable_",
  130. smalltalk.method({
  131. selector: "lookupVariable:",
  132. category: 'accessing',
  133. fn: function (aNode) {
  134. var self=this;
  135. var lookup=nil;
  136. (lookup=smalltalk.send(self, "_bindingFor_", [aNode]));
  137. (($receiver = lookup) == nil || $receiver == undefined) ? (function(){return (lookup=(($receiver = smalltalk.send(self, "_outerScope", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_outerScope", []), "_lookupVariable_", [aNode]);})() : nil);})() : $receiver;
  138. return lookup;
  139. return self;},
  140. args: ["aNode"],
  141. 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",
  142. messageSends: ["bindingFor:", "ifNil:", "ifNotNil:", "outerScope", "lookupVariable:"],
  143. referencedClasses: []
  144. }),
  145. smalltalk.LexicalScope);
  146. smalltalk.addMethod(
  147. "_methodScope",
  148. smalltalk.method({
  149. selector: "methodScope",
  150. category: 'accessing',
  151. fn: function () {
  152. var self=this;
  153. return (($receiver = smalltalk.send(self, "_outerScope", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_outerScope", []), "_methodScope", []);})() : nil;
  154. return self;},
  155. args: [],
  156. source: "methodScope\x0a\x09^ self outerScope ifNotNil: [\x0a\x09\x09self outerScope methodScope ]",
  157. messageSends: ["ifNotNil:", "outerScope", "methodScope"],
  158. referencedClasses: []
  159. }),
  160. smalltalk.LexicalScope);
  161. smalltalk.addMethod(
  162. "_node",
  163. smalltalk.method({
  164. selector: "node",
  165. category: 'accessing',
  166. fn: function () {
  167. var self=this;
  168. return self['@node'];
  169. return self;},
  170. args: [],
  171. source: "node\x0a\x09\x22Answer the node in which I am defined\x22\x0a\x09\x0a\x09^ node",
  172. messageSends: [],
  173. referencedClasses: []
  174. }),
  175. smalltalk.LexicalScope);
  176. smalltalk.addMethod(
  177. "_node_",
  178. smalltalk.method({
  179. selector: "node:",
  180. category: 'accessing',
  181. fn: function (aNode) {
  182. var self=this;
  183. (self['@node']=aNode);
  184. return self;},
  185. args: ["aNode"],
  186. source: "node: aNode\x0a\x09node := aNode",
  187. messageSends: [],
  188. referencedClasses: []
  189. }),
  190. smalltalk.LexicalScope);
  191. smalltalk.addMethod(
  192. "_outerScope",
  193. smalltalk.method({
  194. selector: "outerScope",
  195. category: 'accessing',
  196. fn: function () {
  197. var self=this;
  198. return self['@outerScope'];
  199. return self;},
  200. args: [],
  201. source: "outerScope\x0a\x09^ outerScope",
  202. messageSends: [],
  203. referencedClasses: []
  204. }),
  205. smalltalk.LexicalScope);
  206. smalltalk.addMethod(
  207. "_outerScope_",
  208. smalltalk.method({
  209. selector: "outerScope:",
  210. category: 'accessing',
  211. fn: function (aLexicalScope) {
  212. var self=this;
  213. (self['@outerScope']=aLexicalScope);
  214. return self;},
  215. args: ["aLexicalScope"],
  216. source: "outerScope: aLexicalScope\x0a\x09outerScope := aLexicalScope",
  217. messageSends: [],
  218. referencedClasses: []
  219. }),
  220. smalltalk.LexicalScope);
  221. smalltalk.addMethod(
  222. "_scopeLevel",
  223. smalltalk.method({
  224. selector: "scopeLevel",
  225. category: 'accessing',
  226. fn: function () {
  227. var self=this;
  228. return ((($receiver = (($receiver = smalltalk.send(self, "_outerScope", [])) == nil || $receiver == undefined) ? (function(){return (0);})() : (function(){return smalltalk.send(smalltalk.send(self, "_outerScope", []), "_scopeLevel", []);})()).klass === smalltalk.Number) ? $receiver +(1) : smalltalk.send($receiver, "__plus", [(1)]));
  229. return self;},
  230. args: [],
  231. source: "scopeLevel\x0a\x09^ (self outerScope \x0a\x09\x09ifNil: [ 0 ]\x0a\x09\x09ifNotNil: [ self outerScope scopeLevel ]) + 1",
  232. messageSends: ["+", "ifNil:ifNotNil:", "outerScope", "scopeLevel"],
  233. referencedClasses: []
  234. }),
  235. smalltalk.LexicalScope);
  236. smalltalk.addMethod(
  237. "_temps",
  238. smalltalk.method({
  239. selector: "temps",
  240. category: 'accessing',
  241. fn: function () {
  242. var self=this;
  243. return (($receiver = self['@temps']) == nil || $receiver == undefined) ? (function(){return (self['@temps']=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));})() : $receiver;
  244. return self;},
  245. args: [],
  246. source: "temps\x0a\x09^ temps ifNil: [ temps := Dictionary new ]",
  247. messageSends: ["ifNil:", "new"],
  248. referencedClasses: ["Dictionary"]
  249. }),
  250. smalltalk.LexicalScope);
  251. smalltalk.addClass('MethodLexicalScope', smalltalk.LexicalScope, ['iVars', 'unknownVariables', 'nonLocalReturn'], 'Compiler-Semantic');
  252. smalltalk.MethodLexicalScope.comment="I represent a method scope."
  253. smalltalk.addMethod(
  254. "_addIvar_",
  255. smalltalk.method({
  256. selector: "addIvar:",
  257. category: 'adding',
  258. fn: function (aString) {
  259. var self=this;
  260. smalltalk.send(smalltalk.send(self, "_iVars", []), "_at_put_", [aString, smalltalk.send((smalltalk.InstanceVar || InstanceVar), "_on_", [aString])]);
  261. smalltalk.send(smalltalk.send(smalltalk.send(self, "_iVars", []), "_at_", [aString]), "_scope_", [self]);
  262. return self;},
  263. args: ["aString"],
  264. source: "addIvar: aString\x0a\x09self iVars at: aString put: (InstanceVar on: aString).\x0a\x09(self iVars at: aString) scope: self",
  265. messageSends: ["at:put:", "iVars", "on:", "scope:", "at:"],
  266. referencedClasses: ["InstanceVar"]
  267. }),
  268. smalltalk.MethodLexicalScope);
  269. smalltalk.addMethod(
  270. "_allVariableNames",
  271. smalltalk.method({
  272. selector: "allVariableNames",
  273. category: 'accessing',
  274. fn: function () {
  275. var self=this;
  276. return smalltalk.send(smalltalk.send(self, "_allVariableNames", [], smalltalk.MethodLexicalScope.superclass || nil), "__comma", [smalltalk.send(smalltalk.send(self, "_iVars", []), "_keys", [])]);
  277. return self;},
  278. args: [],
  279. source: "allVariableNames\x0a\x09^ super allVariableNames, self iVars keys",
  280. messageSends: [",", "allVariableNames", "keys", "iVars"],
  281. referencedClasses: []
  282. }),
  283. smalltalk.MethodLexicalScope);
  284. smalltalk.addMethod(
  285. "_bindingFor_",
  286. smalltalk.method({
  287. selector: "bindingFor:",
  288. category: 'accessing',
  289. fn: function (aNode) {
  290. var self=this;
  291. return (($receiver = smalltalk.send(self, "_bindingFor_", [aNode], smalltalk.MethodLexicalScope.superclass || nil)) == nil || $receiver == undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_iVars", []), "_at_ifAbsent_", [smalltalk.send(aNode, "_value", []), (function(){return nil;})]);})() : $receiver;
  292. return self;},
  293. args: ["aNode"],
  294. source: "bindingFor: aNode\x0a\x09^ (super bindingFor: aNode) ifNil: [\x0a\x09\x09self iVars at: aNode value ifAbsent: [ nil ]]",
  295. messageSends: ["ifNil:", "bindingFor:", "at:ifAbsent:", "iVars", "value"],
  296. referencedClasses: []
  297. }),
  298. smalltalk.MethodLexicalScope);
  299. smalltalk.addMethod(
  300. "_hasNonLocalReturn",
  301. smalltalk.method({
  302. selector: "hasNonLocalReturn",
  303. category: 'testing',
  304. fn: function () {
  305. var self=this;
  306. return smalltalk.send(self, "_nonLocalReturn", []);
  307. return self;},
  308. args: [],
  309. source: "hasNonLocalReturn\x0a\x09^ self nonLocalReturn",
  310. messageSends: ["nonLocalReturn"],
  311. referencedClasses: []
  312. }),
  313. smalltalk.MethodLexicalScope);
  314. smalltalk.addMethod(
  315. "_iVars",
  316. smalltalk.method({
  317. selector: "iVars",
  318. category: 'accessing',
  319. fn: function () {
  320. var self=this;
  321. return (($receiver = self['@iVars']) == nil || $receiver == undefined) ? (function(){return (self['@iVars']=smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));})() : $receiver;
  322. return self;},
  323. args: [],
  324. source: "iVars\x0a\x09^ iVars ifNil: [ iVars := Dictionary new ]",
  325. messageSends: ["ifNil:", "new"],
  326. referencedClasses: ["Dictionary"]
  327. }),
  328. smalltalk.MethodLexicalScope);
  329. smalltalk.addMethod(
  330. "_isMethodScope",
  331. smalltalk.method({
  332. selector: "isMethodScope",
  333. category: 'testing',
  334. fn: function () {
  335. var self=this;
  336. return true;
  337. return self;},
  338. args: [],
  339. source: "isMethodScope\x0a\x09^ true",
  340. messageSends: [],
  341. referencedClasses: []
  342. }),
  343. smalltalk.MethodLexicalScope);
  344. smalltalk.addMethod(
  345. "_methodScope",
  346. smalltalk.method({
  347. selector: "methodScope",
  348. category: 'accessing',
  349. fn: function () {
  350. var self=this;
  351. return self;
  352. return self;},
  353. args: [],
  354. source: "methodScope\x0a\x09^ self",
  355. messageSends: [],
  356. referencedClasses: []
  357. }),
  358. smalltalk.MethodLexicalScope);
  359. smalltalk.addMethod(
  360. "_nonLocalReturn",
  361. smalltalk.method({
  362. selector: "nonLocalReturn",
  363. category: 'accessing',
  364. fn: function () {
  365. var self=this;
  366. return (($receiver = self['@nonLocalReturn']) == nil || $receiver == undefined) ? (function(){return false;})() : $receiver;
  367. return self;},
  368. args: [],
  369. source: "nonLocalReturn\x0a\x09^ nonLocalReturn ifNil: [ false ]",
  370. messageSends: ["ifNil:"],
  371. referencedClasses: []
  372. }),
  373. smalltalk.MethodLexicalScope);
  374. smalltalk.addMethod(
  375. "_nonLocalReturn_",
  376. smalltalk.method({
  377. selector: "nonLocalReturn:",
  378. category: 'accessing',
  379. fn: function (aBoolean) {
  380. var self=this;
  381. (self['@nonLocalReturn']=aBoolean);
  382. return self;},
  383. args: ["aBoolean"],
  384. source: "nonLocalReturn: aBoolean\x0a\x09nonLocalReturn := aBoolean",
  385. messageSends: [],
  386. referencedClasses: []
  387. }),
  388. smalltalk.MethodLexicalScope);
  389. smalltalk.addMethod(
  390. "_unknownVariables",
  391. smalltalk.method({
  392. selector: "unknownVariables",
  393. category: 'accessing',
  394. fn: function () {
  395. var self=this;
  396. return (($receiver = self['@unknownVariables']) == nil || $receiver == undefined) ? (function(){return (self['@unknownVariables']=smalltalk.send((smalltalk.OrderedCollection || OrderedCollection), "_new", []));})() : $receiver;
  397. return self;},
  398. args: [],
  399. source: "unknownVariables\x0a\x09^ unknownVariables ifNil: [ unknownVariables := OrderedCollection new ]",
  400. messageSends: ["ifNil:", "new"],
  401. referencedClasses: ["OrderedCollection"]
  402. }),
  403. smalltalk.MethodLexicalScope);
  404. smalltalk.addClass('ScopeVar', smalltalk.Object, ['scope', 'name'], 'Compiler-Semantic');
  405. 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."
  406. smalltalk.addMethod(
  407. "_alias",
  408. smalltalk.method({
  409. selector: "alias",
  410. category: 'accessing',
  411. fn: function () {
  412. var self=this;
  413. return smalltalk.send(smalltalk.send(self, "_name", []), "_asVariableName", []);
  414. return self;},
  415. args: [],
  416. source: "alias\x0a\x09^ self name asVariableName",
  417. messageSends: ["asVariableName", "name"],
  418. referencedClasses: []
  419. }),
  420. smalltalk.ScopeVar);
  421. smalltalk.addMethod(
  422. "_isArgVar",
  423. smalltalk.method({
  424. selector: "isArgVar",
  425. category: 'testing',
  426. fn: function () {
  427. var self=this;
  428. return false;
  429. return self;},
  430. args: [],
  431. source: "isArgVar\x0a\x09^ false",
  432. messageSends: [],
  433. referencedClasses: []
  434. }),
  435. smalltalk.ScopeVar);
  436. smalltalk.addMethod(
  437. "_isInstanceVar",
  438. smalltalk.method({
  439. selector: "isInstanceVar",
  440. category: 'testing',
  441. fn: function () {
  442. var self=this;
  443. return false;
  444. return self;},
  445. args: [],
  446. source: "isInstanceVar\x0a\x09^ false",
  447. messageSends: [],
  448. referencedClasses: []
  449. }),
  450. smalltalk.ScopeVar);
  451. smalltalk.addMethod(
  452. "_isTempVar",
  453. smalltalk.method({
  454. selector: "isTempVar",
  455. category: 'testing',
  456. fn: function () {
  457. var self=this;
  458. return false;
  459. return self;},
  460. args: [],
  461. source: "isTempVar\x0a\x09^ false",
  462. messageSends: [],
  463. referencedClasses: []
  464. }),
  465. smalltalk.ScopeVar);
  466. smalltalk.addMethod(
  467. "_isUnknownVar",
  468. smalltalk.method({
  469. selector: "isUnknownVar",
  470. category: 'testing',
  471. fn: function () {
  472. var self=this;
  473. return false;
  474. return self;},
  475. args: [],
  476. source: "isUnknownVar\x0a\x09^ false",
  477. messageSends: [],
  478. referencedClasses: []
  479. }),
  480. smalltalk.ScopeVar);
  481. smalltalk.addMethod(
  482. "_name",
  483. smalltalk.method({
  484. selector: "name",
  485. category: 'accessing',
  486. fn: function () {
  487. var self=this;
  488. return self['@name'];
  489. return self;},
  490. args: [],
  491. source: "name\x0a\x09^ name",
  492. messageSends: [],
  493. referencedClasses: []
  494. }),
  495. smalltalk.ScopeVar);
  496. smalltalk.addMethod(
  497. "_name_",
  498. smalltalk.method({
  499. selector: "name:",
  500. category: 'accessing',
  501. fn: function (aString) {
  502. var self=this;
  503. (self['@name']=aString);
  504. return self;},
  505. args: ["aString"],
  506. source: "name: aString\x0a\x09name := aString",
  507. messageSends: [],
  508. referencedClasses: []
  509. }),
  510. smalltalk.ScopeVar);
  511. smalltalk.addMethod(
  512. "_scope",
  513. smalltalk.method({
  514. selector: "scope",
  515. category: 'accessing',
  516. fn: function () {
  517. var self=this;
  518. return self['@scope'];
  519. return self;},
  520. args: [],
  521. source: "scope\x0a\x09^ scope",
  522. messageSends: [],
  523. referencedClasses: []
  524. }),
  525. smalltalk.ScopeVar);
  526. smalltalk.addMethod(
  527. "_scope_",
  528. smalltalk.method({
  529. selector: "scope:",
  530. category: 'accessing',
  531. fn: function (aScope) {
  532. var self=this;
  533. (self['@scope']=aScope);
  534. return self;},
  535. args: ["aScope"],
  536. source: "scope: aScope\x0a\x09scope := aScope",
  537. messageSends: [],
  538. referencedClasses: []
  539. }),
  540. smalltalk.ScopeVar);
  541. smalltalk.addMethod(
  542. "_on_",
  543. smalltalk.method({
  544. selector: "on:",
  545. category: 'instance creation',
  546. fn: function (aString) {
  547. var self=this;
  548. return (function($rec){smalltalk.send($rec, "_name_", [aString]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_new", []));
  549. return self;},
  550. args: ["aString"],
  551. source: "on: aString\x0a\x09^ self new \x0a\x09\x09name: aString;\x0a\x09\x09yourself",
  552. messageSends: ["name:", "yourself", "new"],
  553. referencedClasses: []
  554. }),
  555. smalltalk.ScopeVar.klass);
  556. smalltalk.addClass('AliasVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  557. smalltalk.AliasVar.comment="I am an internally defined variable by the compiler"
  558. smalltalk.addClass('ArgVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  559. smalltalk.ArgVar.comment="I am an argument of a method or block."
  560. smalltalk.addMethod(
  561. "_isArgVar",
  562. smalltalk.method({
  563. selector: "isArgVar",
  564. category: 'testing',
  565. fn: function () {
  566. var self=this;
  567. return true;
  568. return self;},
  569. args: [],
  570. source: "isArgVar\x0a\x09^ true",
  571. messageSends: [],
  572. referencedClasses: []
  573. }),
  574. smalltalk.ArgVar);
  575. smalltalk.addClass('ClassRefVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  576. smalltalk.ClassRefVar.comment="I am an class reference variable"
  577. smalltalk.addMethod(
  578. "_alias",
  579. smalltalk.method({
  580. selector: "alias",
  581. category: 'accessing',
  582. fn: function () {
  583. var self=this;
  584. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send("(Smalltalk.", "__comma", [smalltalk.send(self, "_name", [])]), "__comma", [" || "]), "__comma", [smalltalk.send(self, "_name", [])]), "__comma", [")"]);
  585. return self;},
  586. args: [],
  587. source: "alias\x0a\x09^ '(Smalltalk.', self name, ' || ', self name, ')'",
  588. messageSends: [",", "name"],
  589. referencedClasses: []
  590. }),
  591. smalltalk.ClassRefVar);
  592. smalltalk.addClass('InstanceVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  593. smalltalk.InstanceVar.comment="I am an instance variable of a method or block."
  594. smalltalk.addMethod(
  595. "_alias",
  596. smalltalk.method({
  597. selector: "alias",
  598. category: 'testing',
  599. fn: function () {
  600. var self=this;
  601. return smalltalk.send(smalltalk.send("self[\x22@", "__comma", [smalltalk.send(self, "_name", [])]), "__comma", ["]"]);
  602. return self;},
  603. args: [],
  604. source: "alias\x0a\x09^ 'self[\x22@', self name, ']'",
  605. messageSends: [",", "name"],
  606. referencedClasses: []
  607. }),
  608. smalltalk.InstanceVar);
  609. smalltalk.addMethod(
  610. "_isInstanceVar",
  611. smalltalk.method({
  612. selector: "isInstanceVar",
  613. category: 'testing',
  614. fn: function () {
  615. var self=this;
  616. return true;
  617. return self;},
  618. args: [],
  619. source: "isInstanceVar\x0a\x09^ true",
  620. messageSends: [],
  621. referencedClasses: []
  622. }),
  623. smalltalk.InstanceVar);
  624. smalltalk.addClass('TempVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  625. smalltalk.TempVar.comment="I am an temporary variable of a method or block."
  626. smalltalk.addMethod(
  627. "_isTempVar",
  628. smalltalk.method({
  629. selector: "isTempVar",
  630. category: 'testing',
  631. fn: function () {
  632. var self=this;
  633. return true;
  634. return self;},
  635. args: [],
  636. source: "isTempVar\x0a\x09^ true",
  637. messageSends: [],
  638. referencedClasses: []
  639. }),
  640. smalltalk.TempVar);
  641. smalltalk.addClass('UnknownVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
  642. smalltalk.UnknownVar.comment="I am an unknown variable. Amber uses unknown variables as JavaScript globals"
  643. smalltalk.addMethod(
  644. "_isUnknownVar",
  645. smalltalk.method({
  646. selector: "isUnknownVar",
  647. category: 'testing',
  648. fn: function () {
  649. var self=this;
  650. return true;
  651. return self;},
  652. args: [],
  653. source: "isUnknownVar\x0a\x09^ true",
  654. messageSends: [],
  655. referencedClasses: []
  656. }),
  657. smalltalk.UnknownVar);
  658. smalltalk.addClass('SemanticAnalyzer', smalltalk.NodeVisitor, ['currentScope', 'theClass', 'classReferences', 'messageSends'], 'Compiler-Semantic');
  659. smalltalk.SemanticAnalyzer.comment="I semantically analyze the abstract syntax tree and annotate it with informations such as non local returns and variable scopes."
  660. smalltalk.addMethod(
  661. "_allowUnknownVariables",
  662. smalltalk.method({
  663. selector: "allowUnknownVariables",
  664. category: 'testing',
  665. fn: function () {
  666. var self=this;
  667. return true;
  668. return self;},
  669. args: [],
  670. source: "allowUnknownVariables\x0a\x09^ true",
  671. messageSends: [],
  672. referencedClasses: []
  673. }),
  674. smalltalk.SemanticAnalyzer);
  675. smalltalk.addMethod(
  676. "_classReferences",
  677. smalltalk.method({
  678. selector: "classReferences",
  679. category: 'accessing',
  680. fn: function () {
  681. var self=this;
  682. return (($receiver = self['@classReferences']) == nil || $receiver == undefined) ? (function(){return (self['@classReferences']=smalltalk.send((smalltalk.Set || Set), "_new", []));})() : $receiver;
  683. return self;},
  684. args: [],
  685. source: "classReferences\x0a\x09^ classReferences ifNil: [ classReferences := Set new ]",
  686. messageSends: ["ifNil:", "new"],
  687. referencedClasses: ["Set"]
  688. }),
  689. smalltalk.SemanticAnalyzer);
  690. smalltalk.addMethod(
  691. "_errorInvalidAssignment_",
  692. smalltalk.method({
  693. selector: "errorInvalidAssignment:",
  694. category: 'error handling',
  695. fn: function (aString) {
  696. var self=this;
  697. (function($rec){smalltalk.send($rec, "_variableName_", [aString]);return smalltalk.send($rec, "_signal", []);})(smalltalk.send((smalltalk.InvalidAssignmentError || InvalidAssignmentError), "_new", []));
  698. return self;},
  699. args: ["aString"],
  700. source: "errorInvalidAssignment: aString\x0a\x09InvalidAssignmentError new\x0a\x09\x09variableName: aString;\x0a\x09\x09signal",
  701. messageSends: ["variableName:", "signal", "new"],
  702. referencedClasses: ["InvalidAssignmentError"]
  703. }),
  704. smalltalk.SemanticAnalyzer);
  705. smalltalk.addMethod(
  706. "_errorShadowingVariable_",
  707. smalltalk.method({
  708. selector: "errorShadowingVariable:",
  709. category: 'error handling',
  710. fn: function (aString) {
  711. var self=this;
  712. (function($rec){smalltalk.send($rec, "_variableName_", [aString]);return smalltalk.send($rec, "_signal", []);})(smalltalk.send((smalltalk.ShadowingVariableError || ShadowingVariableError), "_new", []));
  713. return self;},
  714. args: ["aString"],
  715. source: "errorShadowingVariable: aString\x0a\x09ShadowingVariableError new\x0a\x09\x09variableName: aString;\x0a\x09\x09signal",
  716. messageSends: ["variableName:", "signal", "new"],
  717. referencedClasses: ["ShadowingVariableError"]
  718. }),
  719. smalltalk.SemanticAnalyzer);
  720. smalltalk.addMethod(
  721. "_errorUnknownVariable_",
  722. smalltalk.method({
  723. selector: "errorUnknownVariable:",
  724. category: 'error handling',
  725. fn: function (aNode) {
  726. var self=this;
  727. ((($receiver = smalltalk.send(self, "_allowUnknownVariables", [])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_unknownVariables", []), "_add_", [smalltalk.send(aNode, "_value", [])]);})() : (function(){return (function($rec){smalltalk.send($rec, "_variableName_", [smalltalk.send(aNode, "_value", [])]);return smalltalk.send($rec, "_signal", []);})(smalltalk.send((smalltalk.UnknownVariableError || UnknownVariableError), "_new", []));})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return smalltalk.send(smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_unknownVariables", []), "_add_", [smalltalk.send(aNode, "_value", [])]);}), (function(){return (function($rec){smalltalk.send($rec, "_variableName_", [smalltalk.send(aNode, "_value", [])]);return smalltalk.send($rec, "_signal", []);})(smalltalk.send((smalltalk.UnknownVariableError || UnknownVariableError), "_new", []));})]));
  728. return self;},
  729. args: ["aNode"],
  730. source: "errorUnknownVariable: aNode\x0a\x09self allowUnknownVariables \x0a\x09\x09ifTrue: [ currentScope methodScope unknownVariables add: aNode value ]\x0a\x09\x09ifFalse: [ \x0a\x09\x09\x09UnknownVariableError new\x0a\x09\x09\x09\x09variableName: aNode value;\x0a\x09\x09\x09\x09signal ]",
  731. messageSends: ["ifTrue:ifFalse:", "allowUnknownVariables", "add:", "unknownVariables", "methodScope", "value", "variableName:", "signal", "new"],
  732. referencedClasses: ["UnknownVariableError"]
  733. }),
  734. smalltalk.SemanticAnalyzer);
  735. smalltalk.addMethod(
  736. "_messageSends",
  737. smalltalk.method({
  738. selector: "messageSends",
  739. category: 'accessing',
  740. fn: function () {
  741. var self=this;
  742. return (($receiver = self['@messageSends']) == nil || $receiver == undefined) ? (function(){return (self['@messageSends']=smalltalk.send((smalltalk.Set || Set), "_new", []));})() : $receiver;
  743. return self;},
  744. args: [],
  745. source: "messageSends\x0a\x09^ messageSends ifNil: [ messageSends := Set new ]",
  746. messageSends: ["ifNil:", "new"],
  747. referencedClasses: ["Set"]
  748. }),
  749. smalltalk.SemanticAnalyzer);
  750. smalltalk.addMethod(
  751. "_newBlockScope",
  752. smalltalk.method({
  753. selector: "newBlockScope",
  754. category: 'factory',
  755. fn: function () {
  756. var self=this;
  757. return smalltalk.send(self, "_newScopeOfClass_", [(smalltalk.LexicalScope || LexicalScope)]);
  758. return self;},
  759. args: [],
  760. source: "newBlockScope\x0a\x09^ self newScopeOfClass: LexicalScope",
  761. messageSends: ["newScopeOfClass:"],
  762. referencedClasses: ["LexicalScope"]
  763. }),
  764. smalltalk.SemanticAnalyzer);
  765. smalltalk.addMethod(
  766. "_newMethodScope",
  767. smalltalk.method({
  768. selector: "newMethodScope",
  769. category: 'factory',
  770. fn: function () {
  771. var self=this;
  772. return smalltalk.send(self, "_newScopeOfClass_", [(smalltalk.MethodLexicalScope || MethodLexicalScope)]);
  773. return self;},
  774. args: [],
  775. source: "newMethodScope\x0a\x09^ self newScopeOfClass: MethodLexicalScope",
  776. messageSends: ["newScopeOfClass:"],
  777. referencedClasses: ["MethodLexicalScope"]
  778. }),
  779. smalltalk.SemanticAnalyzer);
  780. smalltalk.addMethod(
  781. "_newScopeOfClass_",
  782. smalltalk.method({
  783. selector: "newScopeOfClass:",
  784. category: 'factory',
  785. fn: function (aLexicalScopeClass) {
  786. var self=this;
  787. return (function($rec){smalltalk.send($rec, "_outerScope_", [self['@currentScope']]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(aLexicalScopeClass, "_new", []));
  788. return self;},
  789. args: ["aLexicalScopeClass"],
  790. source: "newScopeOfClass: aLexicalScopeClass\x0a\x09^ aLexicalScopeClass new \x0a\x09\x09outerScope: currentScope;\x0a\x09\x09yourself",
  791. messageSends: ["outerScope:", "yourself", "new"],
  792. referencedClasses: []
  793. }),
  794. smalltalk.SemanticAnalyzer);
  795. smalltalk.addMethod(
  796. "_popScope",
  797. smalltalk.method({
  798. selector: "popScope",
  799. category: 'scope',
  800. fn: function () {
  801. var self=this;
  802. (($receiver = self['@currentScope']) != nil && $receiver != undefined) ? (function(){return (self['@currentScope']=smalltalk.send(self['@currentScope'], "_outerScope", []));})() : nil;
  803. return self;},
  804. args: [],
  805. source: "popScope\x0a\x09currentScope ifNotNil: [\x0a\x09\x09currentScope := currentScope outerScope ]",
  806. messageSends: ["ifNotNil:", "outerScope"],
  807. referencedClasses: []
  808. }),
  809. smalltalk.SemanticAnalyzer);
  810. smalltalk.addMethod(
  811. "_pseudoVariables",
  812. smalltalk.method({
  813. selector: "pseudoVariables",
  814. category: 'accessing',
  815. fn: function () {
  816. var self=this;
  817. return ["self", "super", "true", "false", "nil", "thisContext"];
  818. return self;},
  819. args: [],
  820. source: "pseudoVariables\x0a\x09^#('self' 'super' 'true' 'false' 'nil' 'thisContext')",
  821. messageSends: [],
  822. referencedClasses: []
  823. }),
  824. smalltalk.SemanticAnalyzer);
  825. smalltalk.addMethod(
  826. "_pushScope_",
  827. smalltalk.method({
  828. selector: "pushScope:",
  829. category: 'scope',
  830. fn: function (aScope) {
  831. var self=this;
  832. smalltalk.send(aScope, "_outerScope_", [self['@currentScope']]);
  833. (self['@currentScope']=aScope);
  834. return self;},
  835. args: ["aScope"],
  836. source: "pushScope: aScope\x0a\x09aScope outerScope: currentScope.\x0a\x09currentScope := aScope",
  837. messageSends: ["outerScope:"],
  838. referencedClasses: []
  839. }),
  840. smalltalk.SemanticAnalyzer);
  841. smalltalk.addMethod(
  842. "_theClass",
  843. smalltalk.method({
  844. selector: "theClass",
  845. category: 'accessing',
  846. fn: function () {
  847. var self=this;
  848. return self['@theClass'];
  849. return self;},
  850. args: [],
  851. source: "theClass\x0a\x09^ theClass",
  852. messageSends: [],
  853. referencedClasses: []
  854. }),
  855. smalltalk.SemanticAnalyzer);
  856. smalltalk.addMethod(
  857. "_theClass_",
  858. smalltalk.method({
  859. selector: "theClass:",
  860. category: 'accessing',
  861. fn: function (aClass) {
  862. var self=this;
  863. (self['@theClass']=aClass);
  864. return self;},
  865. args: ["aClass"],
  866. source: "theClass: aClass\x0a\x09theClass := aClass",
  867. messageSends: [],
  868. referencedClasses: []
  869. }),
  870. smalltalk.SemanticAnalyzer);
  871. smalltalk.addMethod(
  872. "_validateVariableScope_",
  873. smalltalk.method({
  874. selector: "validateVariableScope:",
  875. category: 'scope',
  876. fn: function (aString) {
  877. var self=this;
  878. (($receiver = smalltalk.send(self['@currentScope'], "_lookupVariable_", [aString])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(self, "_errorShadowingVariable_", [aString]);})() : nil;
  879. return self;},
  880. args: ["aString"],
  881. 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 ]",
  882. messageSends: ["ifNotNil:", "lookupVariable:", "errorShadowingVariable:"],
  883. referencedClasses: []
  884. }),
  885. smalltalk.SemanticAnalyzer);
  886. smalltalk.addMethod(
  887. "_visitAssignmentNode_",
  888. smalltalk.method({
  889. selector: "visitAssignmentNode:",
  890. category: 'visiting',
  891. fn: function (aNode) {
  892. var self=this;
  893. ((($receiver = smalltalk.send(smalltalk.send(self, "_pseudoVariables", []), "_includes_", [smalltalk.send(smalltalk.send(aNode, "_left", []), "_value", [])])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_errorInvalidAssignment_", [smalltalk.send(aNode, "_left", [])]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_errorInvalidAssignment_", [smalltalk.send(aNode, "_left", [])]);})]));
  894. smalltalk.send(smalltalk.send(aNode, "_left", []), "_beAssigned", []);
  895. smalltalk.send(smalltalk.send(aNode, "_right", []), "_beUsed", []);
  896. smalltalk.send(self, "_visitAssignmentNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  897. return self;},
  898. args: ["aNode"],
  899. source: "visitAssignmentNode: aNode\x0a\x09(self pseudoVariables includes: aNode left value) ifTrue: [\x0a\x09\x09self errorInvalidAssignment: aNode left ].\x0a\x09aNode left beAssigned.\x0a\x09aNode right beUsed.\x0a\x09super visitAssignmentNode: aNode",
  900. messageSends: ["ifTrue:", "includes:", "pseudoVariables", "value", "left", "errorInvalidAssignment:", "beAssigned", "beUsed", "right", "visitAssignmentNode:"],
  901. referencedClasses: []
  902. }),
  903. smalltalk.SemanticAnalyzer);
  904. smalltalk.addMethod(
  905. "_visitBlockNode_",
  906. smalltalk.method({
  907. selector: "visitBlockNode:",
  908. category: 'visiting',
  909. fn: function (aNode) {
  910. var self=this;
  911. smalltalk.send(self, "_pushScope_", [smalltalk.send(self, "_newBlockScope", [])]);
  912. smalltalk.send(aNode, "_scope_", [self['@currentScope']]);
  913. smalltalk.send(smalltalk.send(aNode, "_parameters", []), "_do_", [(function(each){smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addArg_", [each]);})]);
  914. smalltalk.send(self, "_visitBlockNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  915. smalltalk.send(self, "_popScope", []);
  916. return self;},
  917. args: ["aNode"],
  918. source: "visitBlockNode: aNode\x0a\x09self pushScope: self newBlockScope.\x0a\x09aNode scope: currentScope.\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",
  919. messageSends: ["pushScope:", "newBlockScope", "scope:", "do:", "parameters", "validateVariableScope:", "addArg:", "visitBlockNode:", "popScope"],
  920. referencedClasses: []
  921. }),
  922. smalltalk.SemanticAnalyzer);
  923. smalltalk.addMethod(
  924. "_visitCascadeNode_",
  925. smalltalk.method({
  926. selector: "visitCascadeNode:",
  927. category: 'visiting',
  928. fn: function (aNode) {
  929. var self=this;
  930. smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_do_", [(function(each){return smalltalk.send(each, "_receiver_", [smalltalk.send(aNode, "_receiver", [])]);})]);
  931. smalltalk.send(self, "_visitCascadeNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  932. return self;},
  933. args: ["aNode"],
  934. source: "visitCascadeNode: aNode\x0a\x09\x22Populate the receiver into all children\x22\x0a\x09aNode nodes do: [ :each | each receiver: aNode receiver ].\x0a\x09super visitCascadeNode: aNode",
  935. messageSends: ["do:", "nodes", "receiver:", "receiver", "visitCascadeNode:"],
  936. referencedClasses: []
  937. }),
  938. smalltalk.SemanticAnalyzer);
  939. smalltalk.addMethod(
  940. "_visitClassReferenceNode_",
  941. smalltalk.method({
  942. selector: "visitClassReferenceNode:",
  943. category: 'visiting',
  944. fn: function (aNode) {
  945. var self=this;
  946. smalltalk.send(smalltalk.send(self, "_classReferences", []), "_add_", [smalltalk.send(aNode, "_value", [])]);
  947. smalltalk.send(aNode, "_binding_", [(function($rec){smalltalk.send($rec, "_name_", [smalltalk.send(aNode, "_value", [])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.ClassRefVar || ClassRefVar), "_new", []))]);
  948. return self;},
  949. args: ["aNode"],
  950. source: "visitClassReferenceNode: aNode\x0a\x09self classReferences add: aNode value.\x0a\x09aNode binding: (ClassRefVar new name: aNode value; yourself)",
  951. messageSends: ["add:", "classReferences", "value", "binding:", "name:", "yourself", "new"],
  952. referencedClasses: ["ClassRefVar"]
  953. }),
  954. smalltalk.SemanticAnalyzer);
  955. smalltalk.addMethod(
  956. "_visitMethodNode_",
  957. smalltalk.method({
  958. selector: "visitMethodNode:",
  959. category: 'visiting',
  960. fn: function (aNode) {
  961. var self=this;
  962. smalltalk.send(self, "_pushScope_", [smalltalk.send(self, "_newMethodScope", [])]);
  963. smalltalk.send(aNode, "_scope_", [self['@currentScope']]);
  964. smalltalk.send(smalltalk.send(smalltalk.send(self, "_theClass", []), "_allInstanceVariableNames", []), "_do_", [(function(each){return smalltalk.send(self['@currentScope'], "_addIVar_", [each]);})]);
  965. smalltalk.send(smalltalk.send(aNode, "_arguments", []), "_do_", [(function(each){smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addArg_", [each]);})]);
  966. smalltalk.send(self, "_visitMethodNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  967. (function($rec){smalltalk.send($rec, "_classReferences_", [smalltalk.send(self, "_classReferences", [])]);return smalltalk.send($rec, "_messageSends_", [smalltalk.send(self, "_messageSends", [])]);})(aNode);
  968. smalltalk.send(self, "_popScope", []);
  969. return self;},
  970. args: ["aNode"],
  971. source: "visitMethodNode: aNode\x0a\x09self pushScope: self newMethodScope.\x0a\x09aNode scope: currentScope.\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.\x0a\x09self popScope",
  972. messageSends: ["pushScope:", "newMethodScope", "scope:", "do:", "allInstanceVariableNames", "theClass", "addIVar:", "arguments", "validateVariableScope:", "addArg:", "visitMethodNode:", "classReferences:", "classReferences", "messageSends:", "messageSends", "popScope"],
  973. referencedClasses: []
  974. }),
  975. smalltalk.SemanticAnalyzer);
  976. smalltalk.addMethod(
  977. "_visitReturnNode_",
  978. smalltalk.method({
  979. selector: "visitReturnNode:",
  980. category: 'visiting',
  981. fn: function (aNode) {
  982. var self=this;
  983. ((($receiver = smalltalk.send(self['@currentScope'], "_isMethodScope", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_nonLocalReturn_", [true]);return smalltalk.send(aNode, "_nonLocalReturn_", [true]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){smalltalk.send(smalltalk.send(self['@currentScope'], "_methodScope", []), "_nonLocalReturn_", [true]);return smalltalk.send(aNode, "_nonLocalReturn_", [true]);})]));
  984. smalltalk.send(smalltalk.send(smalltalk.send(aNode, "_nodes", []), "_first", []), "_beUsed", []);
  985. smalltalk.send(self, "_visitReturnNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  986. return self;},
  987. args: ["aNode"],
  988. source: "visitReturnNode: aNode\x0a\x09currentScope isMethodScope ifFalse: [\x0a\x09\x09currentScope methodScope nonLocalReturn: true.\x0a\x09\x09aNode nonLocalReturn: true ].\x0a\x09aNode nodes first beUsed.\x0a\x09super visitReturnNode: aNode",
  989. messageSends: ["ifFalse:", "isMethodScope", "nonLocalReturn:", "methodScope", "beUsed", "first", "nodes", "visitReturnNode:"],
  990. referencedClasses: []
  991. }),
  992. smalltalk.SemanticAnalyzer);
  993. smalltalk.addMethod(
  994. "_visitSendNode_",
  995. smalltalk.method({
  996. selector: "visitSendNode:",
  997. category: 'visiting',
  998. fn: function (aNode) {
  999. var self=this;
  1000. smalltalk.send(smalltalk.send(self, "_messageSends", []), "_add_", [smalltalk.send(aNode, "_selector", [])]);
  1001. (($receiver = smalltalk.send(aNode, "_receiver", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(smalltalk.send(aNode, "_receiver", []), "_beUsed", []);})() : nil;
  1002. smalltalk.send(smalltalk.send(aNode, "_arguments", []), "_do_", [(function(each){return smalltalk.send(each, "_beUsed", []);})]);
  1003. smalltalk.send(self, "_visitSendNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  1004. return self;},
  1005. args: ["aNode"],
  1006. source: "visitSendNode: aNode\x0a\x09self messageSends add: aNode selector.\x0a\x09aNode receiver ifNotNil: [\x0a\x09\x09aNode receiver beUsed ].\x0a\x09aNode arguments do: [ :each |\x0a\x09\x09each beUsed ].\x0a\x09super visitSendNode: aNode",
  1007. messageSends: ["add:", "messageSends", "selector", "ifNotNil:", "receiver", "beUsed", "do:", "arguments", "visitSendNode:"],
  1008. referencedClasses: []
  1009. }),
  1010. smalltalk.SemanticAnalyzer);
  1011. smalltalk.addMethod(
  1012. "_visitSequenceNode_",
  1013. smalltalk.method({
  1014. selector: "visitSequenceNode:",
  1015. category: 'visiting',
  1016. fn: function (aNode) {
  1017. var self=this;
  1018. smalltalk.send(smalltalk.send(aNode, "_temps", []), "_do_", [(function(each){smalltalk.send(self, "_validateVariableScope_", [each]);return smalltalk.send(self['@currentScope'], "_addTemp_", [each]);})]);
  1019. smalltalk.send(self, "_visitSequenceNode_", [aNode], smalltalk.SemanticAnalyzer.superclass || nil);
  1020. return self;},
  1021. args: ["aNode"],
  1022. source: "visitSequenceNode: aNode\x0a\x09aNode temps do: [ :each | \x0a\x09\x09self validateVariableScope: each.\x0a\x09\x09currentScope addTemp: each ].\x0a\x0a\x09super visitSequenceNode: aNode",
  1023. messageSends: ["do:", "temps", "validateVariableScope:", "addTemp:", "visitSequenceNode:"],
  1024. referencedClasses: []
  1025. }),
  1026. smalltalk.SemanticAnalyzer);
  1027. smalltalk.addMethod(
  1028. "_visitVariableNode_",
  1029. smalltalk.method({
  1030. selector: "visitVariableNode:",
  1031. category: 'visiting',
  1032. fn: function (aNode) {
  1033. var self=this;
  1034. smalltalk.send(aNode, "_binding_", [(($receiver = smalltalk.send(self['@currentScope'], "_lookupVariable_", [aNode])) == nil || $receiver == undefined) ? (function(){smalltalk.send(self, "_errorUnknownVariable_", [aNode]);return (function($rec){smalltalk.send($rec, "_name_", [smalltalk.send(aNode, "_value", [])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send((smalltalk.UnknownVar || UnknownVar), "_new", []));})() : $receiver]);
  1035. return self;},
  1036. args: ["aNode"],
  1037. 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 ])",
  1038. messageSends: ["binding:", "ifNil:", "lookupVariable:", "errorUnknownVariable:", "name:", "value", "yourself", "new"],
  1039. referencedClasses: ["UnknownVar"]
  1040. }),
  1041. smalltalk.SemanticAnalyzer);
  1042. smalltalk.addMethod(
  1043. "_on_",
  1044. smalltalk.method({
  1045. selector: "on:",
  1046. category: 'instance creation',
  1047. fn: function (aClass) {
  1048. var self=this;
  1049. return (function($rec){smalltalk.send($rec, "_theClass_", [aClass]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(self, "_new", []));
  1050. return self;},
  1051. args: ["aClass"],
  1052. source: "on: aClass\x0a\x09^ self new\x0a\x09\x09theClass: aClass;\x0a\x09\x09yourself",
  1053. messageSends: ["theClass:", "yourself", "new"],
  1054. referencedClasses: []
  1055. }),
  1056. smalltalk.SemanticAnalyzer.klass);