Compiler-Semantic.js 61 KB

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