Compiler-Tests.deploy.js 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529
  1. (function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Compiler-Tests');
  3. smalltalk.addClass('ASTVisitorTest', smalltalk.TestCase, [], 'Compiler-Tests');
  4. smalltalk.addMethod(
  5. smalltalk.method({
  6. selector: "analyze:forClass:",
  7. fn: function (aNode,aClass){
  8. var self=this;
  9. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  10. return smalltalk.withContext(function($ctx1) {
  11. var $1;
  12. _st(_st($SemanticAnalyzer())._on_(aClass))._visit_(aNode);
  13. $1=aNode;
  14. return $1;
  15. }, function($ctx1) {$ctx1.fill(self,"analyze:forClass:",{aNode:aNode,aClass:aClass},smalltalk.ASTVisitorTest)})},
  16. messageSends: ["visit:", "on:"]}),
  17. smalltalk.ASTVisitorTest);
  18. smalltalk.addMethod(
  19. smalltalk.method({
  20. selector: "parse:",
  21. fn: function (aString){
  22. var self=this;
  23. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  24. return smalltalk.withContext(function($ctx1) {
  25. var $1;
  26. $1=_st(_st($Smalltalk())._current())._parse_(aString);
  27. return $1;
  28. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},smalltalk.ASTVisitorTest)})},
  29. messageSends: ["parse:", "current"]}),
  30. smalltalk.ASTVisitorTest);
  31. smalltalk.addMethod(
  32. smalltalk.method({
  33. selector: "parse:forClass:",
  34. fn: function (aString,aClass){
  35. var self=this;
  36. return smalltalk.withContext(function($ctx1) {
  37. var $1;
  38. $1=self._analyze_forClass_(self._parse_(aString),aClass);
  39. return $1;
  40. }, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass},smalltalk.ASTVisitorTest)})},
  41. messageSends: ["analyze:forClass:", "parse:"]}),
  42. smalltalk.ASTVisitorTest);
  43. smalltalk.addClass('ASTPCNodeVisitorTest', smalltalk.ASTVisitorTest, [], 'Compiler-Tests');
  44. smalltalk.addMethod(
  45. smalltalk.method({
  46. selector: "astPCNodeVisitor",
  47. fn: function (){
  48. var self=this;
  49. return smalltalk.withContext(function($ctx1) {
  50. var $1;
  51. $1=self._astPCNodeVisitorForPC_((0));
  52. return $1;
  53. }, function($ctx1) {$ctx1.fill(self,"astPCNodeVisitor",{},smalltalk.ASTPCNodeVisitorTest)})},
  54. messageSends: ["astPCNodeVisitorForPC:"]}),
  55. smalltalk.ASTPCNodeVisitorTest);
  56. smalltalk.addMethod(
  57. smalltalk.method({
  58. selector: "astPCNodeVisitorForPC:",
  59. fn: function (anInteger){
  60. var self=this;
  61. function $ASTPCNodeVisitor(){return smalltalk.ASTPCNodeVisitor||(typeof ASTPCNodeVisitor=="undefined"?nil:ASTPCNodeVisitor)}
  62. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  63. return smalltalk.withContext(function($ctx1) {
  64. var $2,$3,$4,$5,$1;
  65. $2=_st($ASTPCNodeVisitor())._new();
  66. _st($2)._pc_((0));
  67. $3=_st($AIContext())._new();
  68. _st($3)._pc_(anInteger);
  69. $4=_st($3)._yourself();
  70. _st($2)._context_($4);
  71. $5=_st($2)._yourself();
  72. $1=$5;
  73. return $1;
  74. }, function($ctx1) {$ctx1.fill(self,"astPCNodeVisitorForPC:",{anInteger:anInteger},smalltalk.ASTPCNodeVisitorTest)})},
  75. messageSends: ["pc:", "new", "context:", "yourself"]}),
  76. smalltalk.ASTPCNodeVisitorTest);
  77. smalltalk.addMethod(
  78. smalltalk.method({
  79. selector: "testJSStatementNode",
  80. fn: function (){
  81. var self=this;
  82. var ast,visitor;
  83. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  84. return smalltalk.withContext(function($ctx1) {
  85. var $1,$2;
  86. ast=self._parse_forClass_("foo <consolee.log(1)>",$Object());
  87. $1=self._astPCNodeVisitor();
  88. _st($1)._visit_(ast);
  89. $2=_st($1)._currentNode();
  90. self._assert_(_st($2)._isJSStatementNode());
  91. return self}, function($ctx1) {$ctx1.fill(self,"testJSStatementNode",{ast:ast,visitor:visitor},smalltalk.ASTPCNodeVisitorTest)})},
  92. messageSends: ["parse:forClass:", "assert:", "isJSStatementNode", "visit:", "astPCNodeVisitor", "currentNode"]}),
  93. smalltalk.ASTPCNodeVisitorTest);
  94. smalltalk.addMethod(
  95. smalltalk.method({
  96. selector: "testMessageSend",
  97. fn: function (){
  98. var self=this;
  99. var ast;
  100. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  101. return smalltalk.withContext(function($ctx1) {
  102. var $1,$2;
  103. ast=self._parse_forClass_("foo self asString yourself. ^ self asBoolean",$Object());
  104. $1=self._astPCNodeVisitorForPC_((2));
  105. _st($1)._visit_(ast);
  106. $2=_st($1)._currentNode();
  107. self._assert_equals_(_st($2)._selector(),"yourself");
  108. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  109. messageSends: ["parse:forClass:", "assert:equals:", "selector", "visit:", "astPCNodeVisitorForPC:", "currentNode"]}),
  110. smalltalk.ASTPCNodeVisitorTest);
  111. smalltalk.addMethod(
  112. smalltalk.method({
  113. selector: "testMessageSendWithInlining",
  114. fn: function (){
  115. var self=this;
  116. var ast;
  117. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  118. return smalltalk.withContext(function($ctx1) {
  119. var $1,$2,$3,$4;
  120. ast=self._parse_forClass_("foo true ifTrue: [ self asString yourself ]. ^ self asBoolean",$Object());
  121. $1=self._astPCNodeVisitorForPC_((2));
  122. _st($1)._visit_(ast);
  123. $2=_st($1)._currentNode();
  124. self._assert_equals_(_st($2)._selector(),"yourself");
  125. ast=self._parse_forClass_("foo true ifTrue: [ self asString yourself ]. ^ self asBoolean",$Object());
  126. $3=self._astPCNodeVisitorForPC_((3));
  127. _st($3)._visit_(ast);
  128. $4=_st($3)._currentNode();
  129. self._assert_equals_(_st($4)._selector(),"asBoolean");
  130. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSendWithInlining",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  131. messageSends: ["parse:forClass:", "assert:equals:", "selector", "visit:", "astPCNodeVisitorForPC:", "currentNode"]}),
  132. smalltalk.ASTPCNodeVisitorTest);
  133. smalltalk.addMethod(
  134. smalltalk.method({
  135. selector: "testNoMessageSend",
  136. fn: function (){
  137. var self=this;
  138. var ast;
  139. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  140. return smalltalk.withContext(function($ctx1) {
  141. var $1,$2;
  142. ast=self._parse_forClass_("foo ^ self",$Object());
  143. $1=self._astPCNodeVisitor();
  144. _st($1)._visit_(ast);
  145. $2=_st($1)._currentNode();
  146. self._assert_(_st($2)._isNil());
  147. return self}, function($ctx1) {$ctx1.fill(self,"testNoMessageSend",{ast:ast},smalltalk.ASTPCNodeVisitorTest)})},
  148. messageSends: ["parse:forClass:", "assert:", "isNil", "visit:", "astPCNodeVisitor", "currentNode"]}),
  149. smalltalk.ASTPCNodeVisitorTest);
  150. smalltalk.addMethod(
  151. smalltalk.method({
  152. selector: "testPC",
  153. fn: function (){
  154. var self=this;
  155. var ast,visitor;
  156. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  157. return smalltalk.withContext(function($ctx1) {
  158. var $1,$2;
  159. ast=self._parse_forClass_("foo <console.log(1)>",$Object());
  160. $1=self._astPCNodeVisitor();
  161. _st($1)._visit_(ast);
  162. $2=_st($1)._currentNode();
  163. self._assert_(_st($2)._isJSStatementNode());
  164. return self}, function($ctx1) {$ctx1.fill(self,"testPC",{ast:ast,visitor:visitor},smalltalk.ASTPCNodeVisitorTest)})},
  165. messageSends: ["parse:forClass:", "assert:", "isJSStatementNode", "visit:", "astPCNodeVisitor", "currentNode"]}),
  166. smalltalk.ASTPCNodeVisitorTest);
  167. smalltalk.addClass('AbstractASTInterpreterTest', smalltalk.ASTVisitorTest, [], 'Compiler-Tests');
  168. smalltalk.addMethod(
  169. smalltalk.method({
  170. selector: "interpret:",
  171. fn: function (aString){
  172. var self=this;
  173. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  174. return smalltalk.withContext(function($ctx1) {
  175. var $1;
  176. $1=self._interpret_withArguments_(aString,_st($Dictionary())._new());
  177. return $1;
  178. }, function($ctx1) {$ctx1.fill(self,"interpret:",{aString:aString},smalltalk.AbstractASTInterpreterTest)})},
  179. messageSends: ["interpret:withArguments:", "new"]}),
  180. smalltalk.AbstractASTInterpreterTest);
  181. smalltalk.addMethod(
  182. smalltalk.method({
  183. selector: "interpret:receiver:withArguments:",
  184. fn: function (aString,anObject,aDictionary){
  185. var self=this;
  186. var ctx;
  187. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  188. return smalltalk.withContext(function($ctx1) {
  189. var $2,$3,$1;
  190. ctx=_st($AIContext())._new();
  191. _st(ctx)._receiver_(anObject);
  192. _st(aDictionary)._keysAndValuesDo_((function(key,value){
  193. return smalltalk.withContext(function($ctx2) {
  194. return _st(ctx)._localAt_put_(key,value);
  195. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  196. $2=self._interpreter();
  197. _st($2)._context_(ctx);
  198. _st($2)._interpret_(_st(_st(self._parse_forClass_(aString,_st(anObject)._class()))._nodes())._first());
  199. $3=_st($2)._result();
  200. $1=$3;
  201. return $1;
  202. }, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx},smalltalk.AbstractASTInterpreterTest)})},
  203. messageSends: ["new", "receiver:", "keysAndValuesDo:", "localAt:put:", "context:", "interpreter", "interpret:", "first", "nodes", "parse:forClass:", "class", "result"]}),
  204. smalltalk.AbstractASTInterpreterTest);
  205. smalltalk.addMethod(
  206. smalltalk.method({
  207. selector: "interpret:withArguments:",
  208. fn: function (aString,aDictionary){
  209. var self=this;
  210. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  211. return smalltalk.withContext(function($ctx1) {
  212. var $1;
  213. $1=self._interpret_receiver_withArguments_(aString,_st($Object())._new(),aDictionary);
  214. return $1;
  215. }, function($ctx1) {$ctx1.fill(self,"interpret:withArguments:",{aString:aString,aDictionary:aDictionary},smalltalk.AbstractASTInterpreterTest)})},
  216. messageSends: ["interpret:receiver:withArguments:", "new"]}),
  217. smalltalk.AbstractASTInterpreterTest);
  218. smalltalk.addMethod(
  219. smalltalk.method({
  220. selector: "interpreter",
  221. fn: function (){
  222. var self=this;
  223. return smalltalk.withContext(function($ctx1) {
  224. var $1;
  225. $1=self._subclassResponsibility();
  226. return $1;
  227. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.AbstractASTInterpreterTest)})},
  228. messageSends: ["subclassResponsibility"]}),
  229. smalltalk.AbstractASTInterpreterTest);
  230. smalltalk.addClass('ASTInterpreterTest', smalltalk.AbstractASTInterpreterTest, [], 'Compiler-Tests');
  231. smalltalk.addMethod(
  232. smalltalk.method({
  233. selector: "interpreter",
  234. fn: function (){
  235. var self=this;
  236. function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
  237. return smalltalk.withContext(function($ctx1) {
  238. var $1;
  239. $1=_st($ASTInterpreter())._new();
  240. return $1;
  241. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTInterpreterTest)})},
  242. messageSends: ["new"]}),
  243. smalltalk.ASTInterpreterTest);
  244. smalltalk.addMethod(
  245. smalltalk.method({
  246. selector: "testBinarySend",
  247. fn: function (){
  248. var self=this;
  249. return smalltalk.withContext(function($ctx1) {
  250. self._assert_equals_(self._interpret_("foo 2+3+4"),(9));
  251. return self}, function($ctx1) {$ctx1.fill(self,"testBinarySend",{},smalltalk.ASTInterpreterTest)})},
  252. messageSends: ["assert:equals:", "interpret:"]}),
  253. smalltalk.ASTInterpreterTest);
  254. smalltalk.addMethod(
  255. smalltalk.method({
  256. selector: "testBlockLiteral",
  257. fn: function (){
  258. var self=this;
  259. return smalltalk.withContext(function($ctx1) {
  260. self._assert_equals_(self._interpret_("foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]"),(1));
  261. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]"),(1));
  262. self._assert_equals_(self._interpret_("foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]"),(2));
  263. return self}, function($ctx1) {$ctx1.fill(self,"testBlockLiteral",{},smalltalk.ASTInterpreterTest)})},
  264. messageSends: ["assert:equals:", "interpret:"]}),
  265. smalltalk.ASTInterpreterTest);
  266. smalltalk.addMethod(
  267. smalltalk.method({
  268. selector: "testCascade",
  269. fn: function (){
  270. var self=this;
  271. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  272. return smalltalk.withContext(function($ctx1) {
  273. self._assert_equals_(self._interpret_("foo ^ OrderedCollection new add: 2; add: 3; yourself"),_st($OrderedCollection())._with_with_((2),(3)));
  274. return self}, function($ctx1) {$ctx1.fill(self,"testCascade",{},smalltalk.ASTInterpreterTest)})},
  275. messageSends: ["assert:equals:", "interpret:", "with:with:"]}),
  276. smalltalk.ASTInterpreterTest);
  277. smalltalk.addMethod(
  278. smalltalk.method({
  279. selector: "testDynamicArray",
  280. fn: function (){
  281. var self=this;
  282. return smalltalk.withContext(function($ctx1) {
  283. self._assert_equals_(self._interpret_("foo ^ {1+1. 2+2}"),[(2), (4)]);
  284. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArray",{},smalltalk.ASTInterpreterTest)})},
  285. messageSends: ["assert:equals:", "interpret:"]}),
  286. smalltalk.ASTInterpreterTest);
  287. smalltalk.addMethod(
  288. smalltalk.method({
  289. selector: "testDynamicDictionary",
  290. fn: function (){
  291. var self=this;
  292. return smalltalk.withContext(function($ctx1) {
  293. self._assert_equals_(self._interpret_("foo ^ #{1->1. 2->3}"),smalltalk.HashedCollection._from_([(1).__minus_gt((1)),(2).__minus_gt((3))]));
  294. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionary",{},smalltalk.ASTInterpreterTest)})},
  295. messageSends: ["assert:equals:", "interpret:", "->"]}),
  296. smalltalk.ASTInterpreterTest);
  297. smalltalk.addMethod(
  298. smalltalk.method({
  299. selector: "testInlinedJSStatement",
  300. fn: function (){
  301. var self=this;
  302. return smalltalk.withContext(function($ctx1) {
  303. self._assert_equals_(self._interpret_("foo <return 2+3>"),(5));
  304. self._assert_equals_(self._interpret_withArguments_("foo: anInteger <return 2 + anInteger>",smalltalk.HashedCollection._from_(["anInteger".__minus_gt((3))])),(5));
  305. return self}, function($ctx1) {$ctx1.fill(self,"testInlinedJSStatement",{},smalltalk.ASTInterpreterTest)})},
  306. messageSends: ["assert:equals:", "interpret:", "interpret:withArguments:", "->"]}),
  307. smalltalk.ASTInterpreterTest);
  308. smalltalk.addMethod(
  309. smalltalk.method({
  310. selector: "testInstVarAccess",
  311. fn: function (){
  312. var self=this;
  313. return smalltalk.withContext(function($ctx1) {
  314. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ x",(2).__at((3)),smalltalk.HashedCollection._from_([])),(2));
  315. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAccess",{},smalltalk.ASTInterpreterTest)})},
  316. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  317. smalltalk.ASTInterpreterTest);
  318. smalltalk.addMethod(
  319. smalltalk.method({
  320. selector: "testInstVarAssignment",
  321. fn: function (){
  322. var self=this;
  323. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  324. return smalltalk.withContext(function($ctx1) {
  325. self._assert_equals_(self._interpret_receiver_withArguments_("foo: anInteger x := anInteger. ^ x",_st($Point())._new(),smalltalk.HashedCollection._from_(["anInteger".__minus_gt((2))])),(2));
  326. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAssignment",{},smalltalk.ASTInterpreterTest)})},
  327. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new", "->"]}),
  328. smalltalk.ASTInterpreterTest);
  329. smalltalk.addMethod(
  330. smalltalk.method({
  331. selector: "testNonlocalReturn",
  332. fn: function (){
  333. var self=this;
  334. return smalltalk.withContext(function($ctx1) {
  335. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ]. ^2"),(1));
  336. return self}, function($ctx1) {$ctx1.fill(self,"testNonlocalReturn",{},smalltalk.ASTInterpreterTest)})},
  337. messageSends: ["assert:equals:", "interpret:"]}),
  338. smalltalk.ASTInterpreterTest);
  339. smalltalk.addMethod(
  340. smalltalk.method({
  341. selector: "testReceiver",
  342. fn: function (){
  343. var self=this;
  344. return smalltalk.withContext(function($ctx1) {
  345. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ self",(2).__at((3)),smalltalk.HashedCollection._from_([])),(2).__at((3)));
  346. return self}, function($ctx1) {$ctx1.fill(self,"testReceiver",{},smalltalk.ASTInterpreterTest)})},
  347. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  348. smalltalk.ASTInterpreterTest);
  349. smalltalk.addMethod(
  350. smalltalk.method({
  351. selector: "testSuper",
  352. fn: function (){
  353. var self=this;
  354. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  355. return smalltalk.withContext(function($ctx1) {
  356. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ super isBoolean",true,_st($Dictionary())._new()),false);
  357. return self}, function($ctx1) {$ctx1.fill(self,"testSuper",{},smalltalk.ASTInterpreterTest)})},
  358. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new"]}),
  359. smalltalk.ASTInterpreterTest);
  360. smalltalk.addMethod(
  361. smalltalk.method({
  362. selector: "testTempAssignment",
  363. fn: function (){
  364. var self=this;
  365. return smalltalk.withContext(function($ctx1) {
  366. self._assert_equals_(self._interpret_("foo | a | a := 2. ^ a"),(2));
  367. return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{},smalltalk.ASTInterpreterTest)})},
  368. messageSends: ["assert:equals:", "interpret:"]}),
  369. smalltalk.ASTInterpreterTest);
  370. smalltalk.addMethod(
  371. smalltalk.method({
  372. selector: "testThisContext",
  373. fn: function (){
  374. var self=this;
  375. return smalltalk.withContext(function($ctx1) {
  376. self._assert_(_st(_st(self._interpret_("foo ^ thisContext"))._outerContext())._isNil());
  377. self._assert_(_st(_st(self._interpret_("foo ^ [ thisContext ] value"))._outerContext())._notNil());
  378. self._assert_(self._interpret_("foo ^ [ thisContext ] value outerContext == thisContext"));
  379. return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.ASTInterpreterTest)})},
  380. messageSends: ["assert:", "isNil", "outerContext", "interpret:", "notNil"]}),
  381. smalltalk.ASTInterpreterTest);
  382. smalltalk.addClass('ASTSteppingInterpreterTest', smalltalk.AbstractASTInterpreterTest, ['interpreter'], 'Compiler-Tests');
  383. smalltalk.addMethod(
  384. smalltalk.method({
  385. selector: "interpreter",
  386. fn: function (){
  387. var self=this;
  388. function $ASTSteppingInterpreter(){return smalltalk.ASTSteppingInterpreter||(typeof ASTSteppingInterpreter=="undefined"?nil:ASTSteppingInterpreter)}
  389. return smalltalk.withContext(function($ctx1) {
  390. var $2,$1;
  391. $2=self["@interpreter"];
  392. if(($receiver = $2) == nil || $receiver == undefined){
  393. self["@interpreter"]=_st($ASTSteppingInterpreter())._new();
  394. $1=self["@interpreter"];
  395. } else {
  396. $1=$2;
  397. };
  398. return $1;
  399. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTSteppingInterpreterTest)})},
  400. messageSends: ["ifNil:", "new"]}),
  401. smalltalk.ASTSteppingInterpreterTest);
  402. smalltalk.addMethod(
  403. smalltalk.method({
  404. selector: "testAtEnd",
  405. fn: function (){
  406. var self=this;
  407. return smalltalk.withContext(function($ctx1) {
  408. self._interpret_("foo 1 + 2");
  409. self._deny_(_st(self._interpreter())._atEnd());
  410. _st(self._interpreter())._step();
  411. self._deny_(_st(self._interpreter())._atEnd());
  412. _st(self._interpreter())._step();
  413. self._deny_(_st(self._interpreter())._atEnd());
  414. _st(self._interpreter())._step();
  415. self._deny_(_st(self._interpreter())._atEnd());
  416. _st(self._interpreter())._step();
  417. self._assert_(_st(self._interpreter())._atEnd());
  418. return self}, function($ctx1) {$ctx1.fill(self,"testAtEnd",{},smalltalk.ASTSteppingInterpreterTest)})},
  419. messageSends: ["interpret:", "deny:", "atEnd", "interpreter", "step", "assert:"]}),
  420. smalltalk.ASTSteppingInterpreterTest);
  421. smalltalk.addMethod(
  422. smalltalk.method({
  423. selector: "testMessageSend",
  424. fn: function (){
  425. var self=this;
  426. return smalltalk.withContext(function($ctx1) {
  427. self._interpret_("foo 1 + 2");
  428. _st(self._interpreter())._step();
  429. _st(self._interpreter())._step();
  430. _st(self._interpreter())._step();
  431. self._assert_equals_(_st(_st(self._interpreter())._currentNode())._value(),(1));
  432. _st(self._interpreter())._step();
  433. self._assert_equals_(_st(_st(self._interpreter())._currentNode())._value(),(2));
  434. _st(self._interpreter())._step();
  435. self._assert_equals_(_st(self._interpreter())._result(),(3));
  436. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{},smalltalk.ASTSteppingInterpreterTest)})},
  437. messageSends: ["interpret:", "step", "interpreter", "assert:equals:", "value", "currentNode", "result"]}),
  438. smalltalk.ASTSteppingInterpreterTest);
  439. smalltalk.addMethod(
  440. smalltalk.method({
  441. selector: "testSimpleStepping",
  442. fn: function (){
  443. var self=this;
  444. return smalltalk.withContext(function($ctx1) {
  445. self._interpret_("foo 1");
  446. _st(self._interpreter())._step();
  447. self._assert_(_st(_st(self._interpreter())._result())._isNil());
  448. _st(self._interpreter())._step();
  449. self._assert_equals_(_st(self._interpreter())._result(),(1));
  450. return self}, function($ctx1) {$ctx1.fill(self,"testSimpleStepping",{},smalltalk.ASTSteppingInterpreterTest)})},
  451. messageSends: ["interpret:", "step", "interpreter", "assert:", "isNil", "result", "assert:equals:"]}),
  452. smalltalk.ASTSteppingInterpreterTest);
  453. smalltalk.addClass('InterpreterTest', smalltalk.AbstractASTInterpreterTest, [], 'Compiler-Tests');
  454. smalltalk.addMethod(
  455. smalltalk.method({
  456. selector: "interpret:receiver:withArguments:",
  457. fn: function (aString,anObject,aDictionary){
  458. var self=this;
  459. var ctx,interpreter;
  460. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  461. return smalltalk.withContext(function($ctx1) {
  462. var $1,$2,$4,$5,$3;
  463. interpreter=self._interpreter();
  464. $1=_st($AIContext())._new();
  465. _st($1)._receiver_(anObject);
  466. _st($1)._interpreter_(interpreter);
  467. $2=_st($1)._yourself();
  468. ctx=$2;
  469. _st(aDictionary)._keysAndValuesDo_((function(key,value){
  470. return smalltalk.withContext(function($ctx2) {
  471. return _st(ctx)._localAt_put_(key,value);
  472. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1,1)})}));
  473. $4=interpreter;
  474. _st($4)._context_(ctx);
  475. _st($4)._interpret_(_st(self._parse_forClass_(aString,_st(anObject)._class()))._nextChild());
  476. _st($4)._proceed();
  477. $5=_st($4)._result();
  478. $3=$5;
  479. return $3;
  480. }, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx,interpreter:interpreter},smalltalk.InterpreterTest)})},
  481. messageSends: ["interpreter", "receiver:", "new", "interpreter:", "yourself", "keysAndValuesDo:", "localAt:put:", "context:", "interpret:", "nextChild", "parse:forClass:", "class", "proceed", "result"]}),
  482. smalltalk.InterpreterTest);
  483. smalltalk.addMethod(
  484. smalltalk.method({
  485. selector: "interpreter",
  486. fn: function (){
  487. var self=this;
  488. function $Interpreter(){return smalltalk.Interpreter||(typeof Interpreter=="undefined"?nil:Interpreter)}
  489. return smalltalk.withContext(function($ctx1) {
  490. var $1;
  491. $1=_st($Interpreter())._new();
  492. return $1;
  493. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.InterpreterTest)})},
  494. messageSends: ["new"]}),
  495. smalltalk.InterpreterTest);
  496. smalltalk.addMethod(
  497. smalltalk.method({
  498. selector: "testBinarySend",
  499. fn: function (){
  500. var self=this;
  501. return smalltalk.withContext(function($ctx1) {
  502. self._assert_equals_(self._interpret_("foo ^ 2+3+4"),(9));
  503. return self}, function($ctx1) {$ctx1.fill(self,"testBinarySend",{},smalltalk.InterpreterTest)})},
  504. messageSends: ["assert:equals:", "interpret:"]}),
  505. smalltalk.InterpreterTest);
  506. smalltalk.addMethod(
  507. smalltalk.method({
  508. selector: "testBlockEvaluation",
  509. fn: function (){
  510. var self=this;
  511. return smalltalk.withContext(function($ctx1) {
  512. self._assert_equals_(self._interpret_("foo ^ true ifTrue: [ 1 asString, '2' ]"),"12");
  513. self._assert_equals_(self._interpret_("foo ^ #(1 2 3) collect: [ :each | each + 3 ]"),[(4), (5), (6)]);
  514. return self}, function($ctx1) {$ctx1.fill(self,"testBlockEvaluation",{},smalltalk.InterpreterTest)})},
  515. messageSends: ["assert:equals:", "interpret:"]}),
  516. smalltalk.InterpreterTest);
  517. smalltalk.addMethod(
  518. smalltalk.method({
  519. selector: "testBlockLiteral",
  520. fn: function (){
  521. var self=this;
  522. return smalltalk.withContext(function($ctx1) {
  523. self._assert_equals_(self._interpret_("foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]"),(1));
  524. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]"),(1));
  525. self._assert_equals_(self._interpret_("foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]"),(2));
  526. return self}, function($ctx1) {$ctx1.fill(self,"testBlockLiteral",{},smalltalk.InterpreterTest)})},
  527. messageSends: ["assert:equals:", "interpret:"]}),
  528. smalltalk.InterpreterTest);
  529. smalltalk.addMethod(
  530. smalltalk.method({
  531. selector: "testCascade",
  532. fn: function (){
  533. var self=this;
  534. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  535. return smalltalk.withContext(function($ctx1) {
  536. self._assert_equals_(self._interpret_("foo ^ OrderedCollection new add: 2; add: 3; yourself"),_st($OrderedCollection())._with_with_((2),(3)));
  537. return self}, function($ctx1) {$ctx1.fill(self,"testCascade",{},smalltalk.InterpreterTest)})},
  538. messageSends: ["assert:equals:", "interpret:", "with:with:"]}),
  539. smalltalk.InterpreterTest);
  540. smalltalk.addMethod(
  541. smalltalk.method({
  542. selector: "testDynamicArray",
  543. fn: function (){
  544. var self=this;
  545. return smalltalk.withContext(function($ctx1) {
  546. self._assert_equals_(self._interpret_("foo ^ {1+1. 2+2}"),[(2), (4)]);
  547. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArray",{},smalltalk.InterpreterTest)})},
  548. messageSends: ["assert:equals:", "interpret:"]}),
  549. smalltalk.InterpreterTest);
  550. smalltalk.addMethod(
  551. smalltalk.method({
  552. selector: "testDynamicDictionary",
  553. fn: function (){
  554. var self=this;
  555. return smalltalk.withContext(function($ctx1) {
  556. self._assert_equals_(self._interpret_("foo ^ #{1->1. 2->3}"),smalltalk.HashedCollection._from_([(1).__minus_gt((1)),(2).__minus_gt((3))]));
  557. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionary",{},smalltalk.InterpreterTest)})},
  558. messageSends: ["assert:equals:", "interpret:", "->"]}),
  559. smalltalk.InterpreterTest);
  560. smalltalk.addMethod(
  561. smalltalk.method({
  562. selector: "testGlobalVar",
  563. fn: function (){
  564. var self=this;
  565. function $BlockClosure(){return smalltalk.BlockClosure||(typeof BlockClosure=="undefined"?nil:BlockClosure)}
  566. return smalltalk.withContext(function($ctx1) {
  567. self._assert_equals_(self._interpret_("foo ^ eval class"),$BlockClosure());
  568. self._assert_equals_(self._interpret_("foo ^ Math cos: 0"),(1));
  569. self._assert_equals_(self._interpret_("foo ^ NonExistingVar"),nil);
  570. return self}, function($ctx1) {$ctx1.fill(self,"testGlobalVar",{},smalltalk.InterpreterTest)})},
  571. messageSends: ["assert:equals:", "interpret:"]}),
  572. smalltalk.InterpreterTest);
  573. smalltalk.addMethod(
  574. smalltalk.method({
  575. selector: "testInlinedJSStatement",
  576. fn: function (){
  577. var self=this;
  578. return smalltalk.withContext(function($ctx1) {
  579. self._assert_equals_(self._interpret_("foo <return 2+3>"),(5));
  580. self._assert_equals_(self._interpret_withArguments_("foo: anInteger <return 2 + anInteger>",smalltalk.HashedCollection._from_(["anInteger".__minus_gt((3))])),(5));
  581. return self}, function($ctx1) {$ctx1.fill(self,"testInlinedJSStatement",{},smalltalk.InterpreterTest)})},
  582. messageSends: ["assert:equals:", "interpret:", "interpret:withArguments:", "->"]}),
  583. smalltalk.InterpreterTest);
  584. smalltalk.addMethod(
  585. smalltalk.method({
  586. selector: "testInstVarAccess",
  587. fn: function (){
  588. var self=this;
  589. return smalltalk.withContext(function($ctx1) {
  590. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ x",(2).__at((3)),smalltalk.HashedCollection._from_([])),(2));
  591. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAccess",{},smalltalk.InterpreterTest)})},
  592. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  593. smalltalk.InterpreterTest);
  594. smalltalk.addMethod(
  595. smalltalk.method({
  596. selector: "testInstVarAssignment",
  597. fn: function (){
  598. var self=this;
  599. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  600. return smalltalk.withContext(function($ctx1) {
  601. self._assert_equals_(self._interpret_receiver_withArguments_("foo: anInteger x := anInteger. ^ x",_st($Point())._new(),smalltalk.HashedCollection._from_(["anInteger".__minus_gt((2))])),(2));
  602. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAssignment",{},smalltalk.InterpreterTest)})},
  603. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new", "->"]}),
  604. smalltalk.InterpreterTest);
  605. smalltalk.addMethod(
  606. smalltalk.method({
  607. selector: "testKeywordSend",
  608. fn: function (){
  609. var self=this;
  610. return smalltalk.withContext(function($ctx1) {
  611. self._assert_equals_(self._interpret_("foo ^ Point x: 1 y: 2"),(1).__at((2)));
  612. return self}, function($ctx1) {$ctx1.fill(self,"testKeywordSend",{},smalltalk.InterpreterTest)})},
  613. messageSends: ["assert:equals:", "interpret:", "@"]}),
  614. smalltalk.InterpreterTest);
  615. smalltalk.addMethod(
  616. smalltalk.method({
  617. selector: "testMultipleSequences",
  618. fn: function (){
  619. var self=this;
  620. return smalltalk.withContext(function($ctx1) {
  621. self._assert_equals_(self._interpret_("foo | a b c | a := 2. b := 3. c := a + b. ^ c * 6"),(30));
  622. return self}, function($ctx1) {$ctx1.fill(self,"testMultipleSequences",{},smalltalk.InterpreterTest)})},
  623. messageSends: ["assert:equals:", "interpret:"]}),
  624. smalltalk.InterpreterTest);
  625. smalltalk.addMethod(
  626. smalltalk.method({
  627. selector: "testNestedSends",
  628. fn: function (){
  629. var self=this;
  630. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  631. return smalltalk.withContext(function($ctx1) {
  632. self._assert_equals_(self._interpret_("foo ^ (Point x: (Point x: 2 y: 3) y: 4) asString"),_st(_st($Point())._x_y_((2).__at((3)),(4)))._asString());
  633. return self}, function($ctx1) {$ctx1.fill(self,"testNestedSends",{},smalltalk.InterpreterTest)})},
  634. messageSends: ["assert:equals:", "interpret:", "asString", "x:y:", "@"]}),
  635. smalltalk.InterpreterTest);
  636. smalltalk.addMethod(
  637. smalltalk.method({
  638. selector: "testNonlocalReturn",
  639. fn: function (){
  640. var self=this;
  641. return smalltalk.withContext(function($ctx1) {
  642. self._assert_equals_(self._interpret_("foo true ifTrue: [ ^ 1 ]. ^2"),(1));
  643. return self}, function($ctx1) {$ctx1.fill(self,"testNonlocalReturn",{},smalltalk.InterpreterTest)})},
  644. messageSends: ["assert:equals:", "interpret:"]}),
  645. smalltalk.InterpreterTest);
  646. smalltalk.addMethod(
  647. smalltalk.method({
  648. selector: "testReceiver",
  649. fn: function (){
  650. var self=this;
  651. return smalltalk.withContext(function($ctx1) {
  652. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ self",(2).__at((3)),smalltalk.HashedCollection._from_([])),(2).__at((3)));
  653. return self}, function($ctx1) {$ctx1.fill(self,"testReceiver",{},smalltalk.InterpreterTest)})},
  654. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  655. smalltalk.InterpreterTest);
  656. smalltalk.addMethod(
  657. smalltalk.method({
  658. selector: "testSuper",
  659. fn: function (){
  660. var self=this;
  661. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  662. return smalltalk.withContext(function($ctx1) {
  663. self._assert_equals_(self._interpret_receiver_withArguments_("foo ^ super isBoolean",true,_st($Dictionary())._new()),false);
  664. return self}, function($ctx1) {$ctx1.fill(self,"testSuper",{},smalltalk.InterpreterTest)})},
  665. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new"]}),
  666. smalltalk.InterpreterTest);
  667. smalltalk.addMethod(
  668. smalltalk.method({
  669. selector: "testTempAssignment",
  670. fn: function (){
  671. var self=this;
  672. return smalltalk.withContext(function($ctx1) {
  673. self._assert_equals_(self._interpret_("foo | a | a := 2. ^ a"),(2));
  674. self._assert_equals_(self._interpret_("foo | a | a := nil. ^ a"),nil);
  675. return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{},smalltalk.InterpreterTest)})},
  676. messageSends: ["assert:equals:", "interpret:"]}),
  677. smalltalk.InterpreterTest);
  678. smalltalk.addMethod(
  679. smalltalk.method({
  680. selector: "testThisContext",
  681. fn: function (){
  682. var self=this;
  683. return smalltalk.withContext(function($ctx1) {
  684. self._assert_(_st(_st(self._interpret_("foo ^ thisContext"))._outerContext())._isNil());
  685. self._assert_(_st(_st(self._interpret_("foo ^ [ thisContext ] value"))._outerContext())._notNil());
  686. self._assert_(self._interpret_("foo ^ [ thisContext ] value outerContext == thisContext"));
  687. return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.InterpreterTest)})},
  688. messageSends: ["assert:", "isNil", "outerContext", "interpret:", "notNil"]}),
  689. smalltalk.InterpreterTest);
  690. smalltalk.addMethod(
  691. smalltalk.method({
  692. selector: "testUnarySend",
  693. fn: function (){
  694. var self=this;
  695. return smalltalk.withContext(function($ctx1) {
  696. self._assert_equals_(self._interpret_("foo ^ 1 asString"),"1");
  697. return self}, function($ctx1) {$ctx1.fill(self,"testUnarySend",{},smalltalk.InterpreterTest)})},
  698. messageSends: ["assert:equals:", "interpret:"]}),
  699. smalltalk.InterpreterTest);
  700. smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
  701. smalltalk.addMethod(
  702. smalltalk.method({
  703. selector: "codeGeneratorClass",
  704. fn: function (){
  705. var self=this;
  706. function $CodeGenerator(){return smalltalk.CodeGenerator||(typeof CodeGenerator=="undefined"?nil:CodeGenerator)}
  707. return smalltalk.withContext(function($ctx1) {
  708. var $1;
  709. $1=$CodeGenerator();
  710. return $1;
  711. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.CodeGeneratorTest)})},
  712. messageSends: []}),
  713. smalltalk.CodeGeneratorTest);
  714. smalltalk.addMethod(
  715. smalltalk.method({
  716. selector: "compiler",
  717. fn: function (){
  718. var self=this;
  719. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  720. return smalltalk.withContext(function($ctx1) {
  721. var $2,$3,$1;
  722. $2=_st($Compiler())._new();
  723. _st($2)._codeGeneratorClass_(self._codeGeneratorClass());
  724. $3=_st($2)._yourself();
  725. $1=$3;
  726. return $1;
  727. }, function($ctx1) {$ctx1.fill(self,"compiler",{},smalltalk.CodeGeneratorTest)})},
  728. messageSends: ["codeGeneratorClass:", "new", "codeGeneratorClass", "yourself"]}),
  729. smalltalk.CodeGeneratorTest);
  730. smalltalk.addMethod(
  731. smalltalk.method({
  732. selector: "setUp",
  733. fn: function (){
  734. var self=this;
  735. return smalltalk.withContext(function($ctx1) {
  736. self["@receiver"]=_st(self._targetClass())._new();
  737. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.CodeGeneratorTest)})},
  738. messageSends: ["new", "targetClass"]}),
  739. smalltalk.CodeGeneratorTest);
  740. smalltalk.addMethod(
  741. smalltalk.method({
  742. selector: "should:return:",
  743. fn: function (aString,anObject){
  744. var self=this;
  745. var method,result;
  746. return smalltalk.withContext(function($ctx1) {
  747. method=_st(self._compiler())._install_forClass_category_(aString,self._targetClass(),"tests");
  748. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  749. _st(self._targetClass())._removeCompiledMethod_(method);
  750. self._assert_equals_(anObject,result);
  751. return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result},smalltalk.CodeGeneratorTest)})},
  752. messageSends: ["install:forClass:category:", "compiler", "targetClass", "perform:", "selector", "removeCompiledMethod:", "assert:equals:"]}),
  753. smalltalk.CodeGeneratorTest);
  754. smalltalk.addMethod(
  755. smalltalk.method({
  756. selector: "targetClass",
  757. fn: function (){
  758. var self=this;
  759. function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  760. return smalltalk.withContext(function($ctx1) {
  761. var $1;
  762. $1=$DoIt();
  763. return $1;
  764. }, function($ctx1) {$ctx1.fill(self,"targetClass",{},smalltalk.CodeGeneratorTest)})},
  765. messageSends: []}),
  766. smalltalk.CodeGeneratorTest);
  767. smalltalk.addMethod(
  768. smalltalk.method({
  769. selector: "tearDown",
  770. fn: function (){
  771. var self=this;
  772. return smalltalk.withContext(function($ctx1) {
  773. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.CodeGeneratorTest)})},
  774. messageSends: []}),
  775. smalltalk.CodeGeneratorTest);
  776. smalltalk.addMethod(
  777. smalltalk.method({
  778. selector: "testAssignment",
  779. fn: function (){
  780. var self=this;
  781. return smalltalk.withContext(function($ctx1) {
  782. self._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  783. self._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  784. self._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  785. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{},smalltalk.CodeGeneratorTest)})},
  786. messageSends: ["should:return:"]}),
  787. smalltalk.CodeGeneratorTest);
  788. smalltalk.addMethod(
  789. smalltalk.method({
  790. selector: "testBackslashSelectors",
  791. fn: function (){
  792. var self=this;
  793. return smalltalk.withContext(function($ctx1) {
  794. self._should_return_("\x5c arg ^ 4",(4));
  795. self._should_return_("\x5c\x5c arg ^ 42",(42));
  796. return self}, function($ctx1) {$ctx1.fill(self,"testBackslashSelectors",{},smalltalk.CodeGeneratorTest)})},
  797. messageSends: ["should:return:"]}),
  798. smalltalk.CodeGeneratorTest);
  799. smalltalk.addMethod(
  800. smalltalk.method({
  801. selector: "testBlockReturn",
  802. fn: function (){
  803. var self=this;
  804. return smalltalk.withContext(function($ctx1) {
  805. self._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  806. self._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  807. self._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  808. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{},smalltalk.CodeGeneratorTest)})},
  809. messageSends: ["should:return:"]}),
  810. smalltalk.CodeGeneratorTest);
  811. smalltalk.addMethod(
  812. smalltalk.method({
  813. selector: "testCascades",
  814. fn: function (){
  815. var self=this;
  816. return smalltalk.withContext(function($ctx1) {
  817. self._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  818. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{},smalltalk.CodeGeneratorTest)})},
  819. messageSends: ["should:return:"]}),
  820. smalltalk.CodeGeneratorTest);
  821. smalltalk.addMethod(
  822. smalltalk.method({
  823. selector: "testDynamicArrayElementsOrdered",
  824. fn: function (){
  825. var self=this;
  826. return smalltalk.withContext(function($ctx1) {
  827. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  828. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  829. messageSends: ["should:return:"]}),
  830. smalltalk.CodeGeneratorTest);
  831. smalltalk.addMethod(
  832. smalltalk.method({
  833. selector: "testDynamicDictionaryElementsOrdered",
  834. fn: function (){
  835. var self=this;
  836. return smalltalk.withContext(function($ctx1) {
  837. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 'foo'->1.\x0a\x09^ #{ x. (true ifTrue: [ x := 'bar'->2 ]) }\x0a",smalltalk.HashedCollection._from_(["foo".__minus_gt((1)),"bar".__minus_gt((2))]));
  838. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  839. messageSends: ["should:return:", "->"]}),
  840. smalltalk.CodeGeneratorTest);
  841. smalltalk.addMethod(
  842. smalltalk.method({
  843. selector: "testInnerTemporalDependentElementsOrdered",
  844. fn: function (){
  845. var self=this;
  846. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  847. return smalltalk.withContext(function($ctx1) {
  848. self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",["foo".__minus_gt($Array()),"bar".__minus_gt((2))]);
  849. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",["foo".__minus_gt((1)),"bar".__minus_gt((2))]);
  850. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",["foo".__minus_gt((1)),"bar".__minus_gt((2))]);
  851. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ #{ 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",smalltalk.HashedCollection._from_(["foo".__minus_gt((1)),"bar".__minus_gt((2))]));
  852. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  853. messageSends: ["should:return:", "->"]}),
  854. smalltalk.CodeGeneratorTest);
  855. smalltalk.addMethod(
  856. smalltalk.method({
  857. selector: "testLiterals",
  858. fn: function (){
  859. var self=this;
  860. return smalltalk.withContext(function($ctx1) {
  861. self._should_return_("foo ^ 1",(1));
  862. self._should_return_("foo ^ 'hello'","hello");
  863. self._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  864. self._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  865. self._should_return_("foo ^ true",true);
  866. self._should_return_("foo ^ false",false);
  867. self._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._from_([(1).__minus_gt((2)),(3).__minus_gt((4))]));
  868. self._should_return_("foo ^ #hello","hello");
  869. self._should_return_("foo ^ -123.456",(-123.456));
  870. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{},smalltalk.CodeGeneratorTest)})},
  871. messageSends: ["should:return:", "->"]}),
  872. smalltalk.CodeGeneratorTest);
  873. smalltalk.addMethod(
  874. smalltalk.method({
  875. selector: "testLocalReturn",
  876. fn: function (){
  877. var self=this;
  878. return smalltalk.withContext(function($ctx1) {
  879. self._should_return_("foo ^ 1",(1));
  880. self._should_return_("foo ^ 1 + 1",(2));
  881. self._should_return_("foo ",self["@receiver"]);
  882. self._should_return_("foo self asString",self["@receiver"]);
  883. self._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  884. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  885. messageSends: ["should:return:"]}),
  886. smalltalk.CodeGeneratorTest);
  887. smalltalk.addMethod(
  888. smalltalk.method({
  889. selector: "testMessageSends",
  890. fn: function (){
  891. var self=this;
  892. return smalltalk.withContext(function($ctx1) {
  893. self._should_return_("foo ^ 1 asString","1");
  894. self._should_return_("foo ^ 1 + 1",(2));
  895. self._should_return_("foo ^ 1 + 2 * 3",(9));
  896. self._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  897. self._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  898. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{},smalltalk.CodeGeneratorTest)})},
  899. messageSends: ["should:return:"]}),
  900. smalltalk.CodeGeneratorTest);
  901. smalltalk.addMethod(
  902. smalltalk.method({
  903. selector: "testMutableLiterals",
  904. fn: function (){
  905. var self=this;
  906. return smalltalk.withContext(function($ctx1) {
  907. self._should_return_("foo ^ #( 1 2 ) at: 1 put: 3; yourself",[(3), (2)]);
  908. return self}, function($ctx1) {$ctx1.fill(self,"testMutableLiterals",{},smalltalk.CodeGeneratorTest)})},
  909. messageSends: ["should:return:"]}),
  910. smalltalk.CodeGeneratorTest);
  911. smalltalk.addMethod(
  912. smalltalk.method({
  913. selector: "testNestedIfTrue",
  914. fn: function (){
  915. var self=this;
  916. return smalltalk.withContext(function($ctx1) {
  917. self._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  918. self._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  919. self._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  920. self._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  921. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{},smalltalk.CodeGeneratorTest)})},
  922. messageSends: ["should:return:"]}),
  923. smalltalk.CodeGeneratorTest);
  924. smalltalk.addMethod(
  925. smalltalk.method({
  926. selector: "testNonLocalReturn",
  927. fn: function (){
  928. var self=this;
  929. return smalltalk.withContext(function($ctx1) {
  930. self._should_return_("foo [ ^ 1 ] value",(1));
  931. self._should_return_("foo [ ^ 1 + 1 ] value",(2));
  932. self._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  933. self._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  934. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  935. messageSends: ["should:return:"]}),
  936. smalltalk.CodeGeneratorTest);
  937. smalltalk.addMethod(
  938. smalltalk.method({
  939. selector: "testPascalCaseGlobal",
  940. fn: function (){
  941. var self=this;
  942. return smalltalk.withContext(function($ctx1) {
  943. self._should_return_("foo ^Object",_st(smalltalk)._at_("Object"));
  944. self._should_return_("foo ^NonExistent",nil);
  945. return self}, function($ctx1) {$ctx1.fill(self,"testPascalCaseGlobal",{},smalltalk.CodeGeneratorTest)})},
  946. messageSends: ["should:return:", "at:"]}),
  947. smalltalk.CodeGeneratorTest);
  948. smalltalk.addMethod(
  949. smalltalk.method({
  950. selector: "testSendReceiverAndArgumentsOrdered",
  951. fn: function (){
  952. var self=this;
  953. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  954. return smalltalk.withContext(function($ctx1) {
  955. self._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  956. self._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[$Array(),(2)]);
  957. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{},smalltalk.CodeGeneratorTest)})},
  958. messageSends: ["should:return:"]}),
  959. smalltalk.CodeGeneratorTest);
  960. smalltalk.addMethod(
  961. smalltalk.method({
  962. selector: "testifFalse",
  963. fn: function (){
  964. var self=this;
  965. return smalltalk.withContext(function($ctx1) {
  966. self._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  967. self._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  968. self._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  969. self._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  970. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{},smalltalk.CodeGeneratorTest)})},
  971. messageSends: ["should:return:"]}),
  972. smalltalk.CodeGeneratorTest);
  973. smalltalk.addMethod(
  974. smalltalk.method({
  975. selector: "testifFalseIfTrue",
  976. fn: function (){
  977. var self=this;
  978. return smalltalk.withContext(function($ctx1) {
  979. self._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  980. self._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  981. self._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  982. self._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  983. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{},smalltalk.CodeGeneratorTest)})},
  984. messageSends: ["should:return:"]}),
  985. smalltalk.CodeGeneratorTest);
  986. smalltalk.addMethod(
  987. smalltalk.method({
  988. selector: "testifNil",
  989. fn: function (){
  990. var self=this;
  991. return smalltalk.withContext(function($ctx1) {
  992. self._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  993. self._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  994. self._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  995. self._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  996. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{},smalltalk.CodeGeneratorTest)})},
  997. messageSends: ["should:return:"]}),
  998. smalltalk.CodeGeneratorTest);
  999. smalltalk.addMethod(
  1000. smalltalk.method({
  1001. selector: "testifNilIfNotNil",
  1002. fn: function (){
  1003. var self=this;
  1004. return smalltalk.withContext(function($ctx1) {
  1005. self._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  1006. self._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  1007. self._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  1008. self._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  1009. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{},smalltalk.CodeGeneratorTest)})},
  1010. messageSends: ["should:return:"]}),
  1011. smalltalk.CodeGeneratorTest);
  1012. smalltalk.addMethod(
  1013. smalltalk.method({
  1014. selector: "testifNotNil",
  1015. fn: function (){
  1016. var self=this;
  1017. return smalltalk.withContext(function($ctx1) {
  1018. self._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  1019. self._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  1020. self._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  1021. self._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  1022. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{},smalltalk.CodeGeneratorTest)})},
  1023. messageSends: ["should:return:"]}),
  1024. smalltalk.CodeGeneratorTest);
  1025. smalltalk.addMethod(
  1026. smalltalk.method({
  1027. selector: "testifNotNilWithArgument",
  1028. fn: function (){
  1029. var self=this;
  1030. return smalltalk.withContext(function($ctx1) {
  1031. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ]",(3));
  1032. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ]",nil);
  1033. self._should_return_("foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(3));
  1034. self._should_return_("foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(5));
  1035. self._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(3));
  1036. self._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(5));
  1037. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNilWithArgument",{},smalltalk.CodeGeneratorTest)})},
  1038. messageSends: ["should:return:"]}),
  1039. smalltalk.CodeGeneratorTest);
  1040. smalltalk.addMethod(
  1041. smalltalk.method({
  1042. selector: "testifTrue",
  1043. fn: function (){
  1044. var self=this;
  1045. return smalltalk.withContext(function($ctx1) {
  1046. self._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  1047. self._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  1048. self._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  1049. self._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  1050. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  1051. messageSends: ["should:return:"]}),
  1052. smalltalk.CodeGeneratorTest);
  1053. smalltalk.addMethod(
  1054. smalltalk.method({
  1055. selector: "testifTrueIfFalse",
  1056. fn: function (){
  1057. var self=this;
  1058. return smalltalk.withContext(function($ctx1) {
  1059. self._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  1060. self._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  1061. self._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  1062. self._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  1063. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  1064. messageSends: ["should:return:"]}),
  1065. smalltalk.CodeGeneratorTest);
  1066. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  1067. smalltalk.addMethod(
  1068. smalltalk.method({
  1069. selector: "codeGeneratorClass",
  1070. fn: function (){
  1071. var self=this;
  1072. function $InliningCodeGenerator(){return smalltalk.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  1073. return smalltalk.withContext(function($ctx1) {
  1074. var $1;
  1075. $1=$InliningCodeGenerator();
  1076. return $1;
  1077. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  1078. messageSends: []}),
  1079. smalltalk.InliningCodeGeneratorTest);
  1080. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  1081. smalltalk.addMethod(
  1082. smalltalk.method({
  1083. selector: "testClassRefVar",
  1084. fn: function (){
  1085. var self=this;
  1086. var node;
  1087. function $ClassReferenceNode(){return smalltalk.ClassReferenceNode||(typeof ClassReferenceNode=="undefined"?nil:ClassReferenceNode)}
  1088. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  1089. return smalltalk.withContext(function($ctx1) {
  1090. var $1,$2;
  1091. $1=_st($ClassReferenceNode())._new();
  1092. _st($1)._value_("Object");
  1093. $2=_st($1)._yourself();
  1094. node=$2;
  1095. _st(_st($SemanticAnalyzer())._new())._visit_(node);
  1096. self._assert_(_st(_st(node)._binding())._isClassRefVar());
  1097. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  1098. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"]}),
  1099. smalltalk.ScopeVarTest);
  1100. smalltalk.addMethod(
  1101. smalltalk.method({
  1102. selector: "testInstanceVar",
  1103. fn: function (){
  1104. var self=this;
  1105. var node,scope;
  1106. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1107. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1108. return smalltalk.withContext(function($ctx1) {
  1109. var $1,$2;
  1110. $1=_st($VariableNode())._new();
  1111. _st($1)._value_("bzzz");
  1112. $2=_st($1)._yourself();
  1113. node=$2;
  1114. scope=_st($MethodLexicalScope())._new();
  1115. _st(scope)._addIVar_("bzzz");
  1116. self._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  1117. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1118. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"]}),
  1119. smalltalk.ScopeVarTest);
  1120. smalltalk.addMethod(
  1121. smalltalk.method({
  1122. selector: "testPseudoVar",
  1123. fn: function (){
  1124. var self=this;
  1125. var node,pseudoVars;
  1126. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1127. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1128. return smalltalk.withContext(function($ctx1) {
  1129. var $1,$2;
  1130. pseudoVars=["self", "super", "true", "false", "nil"];
  1131. _st(pseudoVars)._do_((function(each){
  1132. return smalltalk.withContext(function($ctx2) {
  1133. $1=_st($VariableNode())._new();
  1134. _st($1)._value_(each);
  1135. $2=_st($1)._yourself();
  1136. node=$2;
  1137. node;
  1138. return self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isPseudoVar());
  1139. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1140. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  1141. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"]}),
  1142. smalltalk.ScopeVarTest);
  1143. smalltalk.addMethod(
  1144. smalltalk.method({
  1145. selector: "testTempVar",
  1146. fn: function (){
  1147. var self=this;
  1148. var node,scope;
  1149. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1150. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1151. return smalltalk.withContext(function($ctx1) {
  1152. var $1,$2;
  1153. $1=_st($VariableNode())._new();
  1154. _st($1)._value_("bzzz");
  1155. $2=_st($1)._yourself();
  1156. node=$2;
  1157. scope=_st($MethodLexicalScope())._new();
  1158. _st(scope)._addTemp_("bzzz");
  1159. self._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  1160. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  1161. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"]}),
  1162. smalltalk.ScopeVarTest);
  1163. smalltalk.addMethod(
  1164. smalltalk.method({
  1165. selector: "testUnknownVar",
  1166. fn: function (){
  1167. var self=this;
  1168. var node;
  1169. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  1170. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  1171. return smalltalk.withContext(function($ctx1) {
  1172. var $1,$2;
  1173. $1=_st($VariableNode())._new();
  1174. _st($1)._value_("bzzz");
  1175. $2=_st($1)._yourself();
  1176. node=$2;
  1177. self._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isNil());
  1178. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  1179. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"]}),
  1180. smalltalk.ScopeVarTest);
  1181. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  1182. smalltalk.addMethod(
  1183. smalltalk.method({
  1184. selector: "setUp",
  1185. fn: function (){
  1186. var self=this;
  1187. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  1188. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  1189. return smalltalk.withContext(function($ctx1) {
  1190. self["@analyzer"]=_st($SemanticAnalyzer())._on_($Object());
  1191. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  1192. messageSends: ["on:"]}),
  1193. smalltalk.SemanticAnalyzerTest);
  1194. smalltalk.addMethod(
  1195. smalltalk.method({
  1196. selector: "testAssignment",
  1197. fn: function (){
  1198. var self=this;
  1199. var src,ast;
  1200. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  1201. return smalltalk.withContext(function($ctx1) {
  1202. src="foo self := 1";
  1203. ast=_st(smalltalk)._parse_(src);
  1204. self._should_raise_((function(){
  1205. return smalltalk.withContext(function($ctx2) {
  1206. return _st(self["@analyzer"])._visit_(ast);
  1207. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$InvalidAssignmentError());
  1208. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1209. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1210. smalltalk.SemanticAnalyzerTest);
  1211. smalltalk.addMethod(
  1212. smalltalk.method({
  1213. selector: "testNonLocalReturn",
  1214. fn: function (){
  1215. var self=this;
  1216. var src,ast;
  1217. return smalltalk.withContext(function($ctx1) {
  1218. src="foo | a | a + 1. ^ a";
  1219. ast=_st(smalltalk)._parse_(src);
  1220. _st(self["@analyzer"])._visit_(ast);
  1221. self._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1222. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1223. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"]}),
  1224. smalltalk.SemanticAnalyzerTest);
  1225. smalltalk.addMethod(
  1226. smalltalk.method({
  1227. selector: "testNonLocalReturn2",
  1228. fn: function (){
  1229. var self=this;
  1230. var src,ast;
  1231. return smalltalk.withContext(function($ctx1) {
  1232. src="foo | a | a + 1. [ [ ^ a] ]";
  1233. ast=_st(smalltalk)._parse_(src);
  1234. _st(self["@analyzer"])._visit_(ast);
  1235. self._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  1236. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1237. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"]}),
  1238. smalltalk.SemanticAnalyzerTest);
  1239. smalltalk.addMethod(
  1240. smalltalk.method({
  1241. selector: "testScope",
  1242. fn: function (){
  1243. var self=this;
  1244. var src,ast;
  1245. return smalltalk.withContext(function($ctx1) {
  1246. src="foo | a | a + 1. [ | b | b := a ]";
  1247. ast=_st(smalltalk)._parse_(src);
  1248. _st(self["@analyzer"])._visit_(ast);
  1249. self._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  1250. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1251. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"]}),
  1252. smalltalk.SemanticAnalyzerTest);
  1253. smalltalk.addMethod(
  1254. smalltalk.method({
  1255. selector: "testScope2",
  1256. fn: function (){
  1257. var self=this;
  1258. var src,ast;
  1259. return smalltalk.withContext(function($ctx1) {
  1260. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1261. ast=_st(smalltalk)._parse_(src);
  1262. _st(self["@analyzer"])._visit_(ast);
  1263. self._deny_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope()).__eq_eq(_st(ast)._scope()));
  1264. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1265. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"]}),
  1266. smalltalk.SemanticAnalyzerTest);
  1267. smalltalk.addMethod(
  1268. smalltalk.method({
  1269. selector: "testScopeLevel",
  1270. fn: function (){
  1271. var self=this;
  1272. var src,ast;
  1273. return smalltalk.withContext(function($ctx1) {
  1274. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  1275. ast=_st(smalltalk)._parse_(src);
  1276. _st(self["@analyzer"])._visit_(ast);
  1277. self._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  1278. self._assert_equals_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._scope())._scopeLevel(),(3));
  1279. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1280. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"]}),
  1281. smalltalk.SemanticAnalyzerTest);
  1282. smalltalk.addMethod(
  1283. smalltalk.method({
  1284. selector: "testUnknownVariables",
  1285. fn: function (){
  1286. var self=this;
  1287. var src,ast;
  1288. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1289. return smalltalk.withContext(function($ctx1) {
  1290. src="foo | a | b + a";
  1291. ast=_st(smalltalk)._parse_(src);
  1292. self._should_raise_((function(){
  1293. return smalltalk.withContext(function($ctx2) {
  1294. return _st(self["@analyzer"])._visit_(ast);
  1295. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$UnknownVariableError());
  1296. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1297. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1298. smalltalk.SemanticAnalyzerTest);
  1299. smalltalk.addMethod(
  1300. smalltalk.method({
  1301. selector: "testUnknownVariablesWithScope",
  1302. fn: function (){
  1303. var self=this;
  1304. var src,ast;
  1305. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  1306. return smalltalk.withContext(function($ctx1) {
  1307. src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  1308. ast=_st(smalltalk)._parse_(src);
  1309. self._should_raise_((function(){
  1310. return smalltalk.withContext(function($ctx2) {
  1311. return _st(self["@analyzer"])._visit_(ast);
  1312. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$UnknownVariableError());
  1313. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1314. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1315. smalltalk.SemanticAnalyzerTest);
  1316. smalltalk.addMethod(
  1317. smalltalk.method({
  1318. selector: "testVariableShadowing",
  1319. fn: function (){
  1320. var self=this;
  1321. var src,ast;
  1322. return smalltalk.withContext(function($ctx1) {
  1323. src="foo | a | a + 1";
  1324. ast=_st(smalltalk)._parse_(src);
  1325. _st(self["@analyzer"])._visit_(ast);
  1326. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1327. messageSends: ["parse:", "visit:"]}),
  1328. smalltalk.SemanticAnalyzerTest);
  1329. smalltalk.addMethod(
  1330. smalltalk.method({
  1331. selector: "testVariableShadowing2",
  1332. fn: function (){
  1333. var self=this;
  1334. var src,ast;
  1335. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1336. return smalltalk.withContext(function($ctx1) {
  1337. src="foo | a | a + 1. [ | a | a := 2 ]";
  1338. ast=_st(smalltalk)._parse_(src);
  1339. self._should_raise_((function(){
  1340. return smalltalk.withContext(function($ctx2) {
  1341. return _st(self["@analyzer"])._visit_(ast);
  1342. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$ShadowingVariableError());
  1343. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1344. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1345. smalltalk.SemanticAnalyzerTest);
  1346. smalltalk.addMethod(
  1347. smalltalk.method({
  1348. selector: "testVariableShadowing3",
  1349. fn: function (){
  1350. var self=this;
  1351. var src,ast;
  1352. return smalltalk.withContext(function($ctx1) {
  1353. src="foo | a | a + 1. [ | b | b := 2 ]";
  1354. ast=_st(smalltalk)._parse_(src);
  1355. _st(self["@analyzer"])._visit_(ast);
  1356. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1357. messageSends: ["parse:", "visit:"]}),
  1358. smalltalk.SemanticAnalyzerTest);
  1359. smalltalk.addMethod(
  1360. smalltalk.method({
  1361. selector: "testVariableShadowing4",
  1362. fn: function (){
  1363. var self=this;
  1364. var src,ast;
  1365. return smalltalk.withContext(function($ctx1) {
  1366. src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  1367. ast=_st(smalltalk)._parse_(src);
  1368. _st(self["@analyzer"])._visit_(ast);
  1369. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1370. messageSends: ["parse:", "visit:"]}),
  1371. smalltalk.SemanticAnalyzerTest);
  1372. smalltalk.addMethod(
  1373. smalltalk.method({
  1374. selector: "testVariableShadowing5",
  1375. fn: function (){
  1376. var self=this;
  1377. var src,ast;
  1378. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1379. return smalltalk.withContext(function($ctx1) {
  1380. src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  1381. ast=_st(smalltalk)._parse_(src);
  1382. self._should_raise_((function(){
  1383. return smalltalk.withContext(function($ctx2) {
  1384. return _st(self["@analyzer"])._visit_(ast);
  1385. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),$ShadowingVariableError());
  1386. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1387. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1388. smalltalk.SemanticAnalyzerTest);
  1389. smalltalk.addMethod(
  1390. smalltalk.method({
  1391. selector: "testVariablesLookup",
  1392. fn: function (){
  1393. var self=this;
  1394. var src,ast;
  1395. return smalltalk.withContext(function($ctx1) {
  1396. src="foo | a | a + 1. [ | b | b := a ]";
  1397. ast=_st(smalltalk)._parse_(src);
  1398. _st(self["@analyzer"])._visit_(ast);
  1399. self._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  1400. self._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  1401. self._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._left())._binding())._isTempVar());
  1402. self._assert_(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._nodes())._first())._nodes())._first())._left())._binding())._scope()).__eq_eq(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()));
  1403. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1404. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"]}),
  1405. smalltalk.SemanticAnalyzerTest);
  1406. })(global_smalltalk,global_nil,global__st);