2
0

Compiler-Semantic.js 61 KB

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