Compiler-Tests.deploy.js 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. smalltalk.addPackage('Compiler-Tests');
  2. smalltalk.addClass('AbstractASTInterpreterTest', smalltalk.TestCase, [], 'Compiler-Tests');
  3. smalltalk.addMethod(
  4. "_analyze_forClass_",
  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) { var $1;
  11. _st(_st($SemanticAnalyzer())._on_(aClass))._visit_(aNode);
  12. $1=aNode;
  13. return $1;
  14. }, function($ctx1) {$ctx1.fill(self,"analyze:forClass:",{aNode:aNode,aClass:aClass},smalltalk.AbstractASTInterpreterTest)})},
  15. messageSends: ["visit:", "on:"]}),
  16. smalltalk.AbstractASTInterpreterTest);
  17. smalltalk.addMethod(
  18. "_interpret_",
  19. smalltalk.method({
  20. selector: "interpret:",
  21. fn: function (aString){
  22. var self=this;
  23. function $Dictionary(){return smalltalk.Dictionary||(typeof Dictionary=="undefined"?nil:Dictionary)}
  24. return smalltalk.withContext(function($ctx1) { var $1;
  25. $1=_st(self)._interpret_withArguments_(aString,_st($Dictionary())._new());
  26. return $1;
  27. }, function($ctx1) {$ctx1.fill(self,"interpret:",{aString:aString},smalltalk.AbstractASTInterpreterTest)})},
  28. messageSends: ["interpret:withArguments:", "new"]}),
  29. smalltalk.AbstractASTInterpreterTest);
  30. smalltalk.addMethod(
  31. "_interpret_receiver_withArguments_",
  32. smalltalk.method({
  33. selector: "interpret:receiver:withArguments:",
  34. fn: function (aString,anObject,aDictionary){
  35. var self=this;
  36. var ctx;
  37. function $AIContext(){return smalltalk.AIContext||(typeof AIContext=="undefined"?nil:AIContext)}
  38. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  39. ctx=_st($AIContext())._new();
  40. _st(ctx)._receiver_(anObject);
  41. _st(aDictionary)._keysAndValuesDo_((function(key,value){
  42. return smalltalk.withContext(function($ctx2) { return _st(ctx)._localAt_put_(key,value);
  43. }, function($ctx2) {$ctx2.fillBlock({key:key,value:value},$ctx1)})}));
  44. $2=_st(self)._interpreter();
  45. _st($2)._context_(ctx);
  46. _st($2)._interpret_(_st(_st(_st(self)._parse_forClass_(aString,_st(anObject)._class()))._nodes())._first());
  47. $3=_st($2)._result();
  48. $1=$3;
  49. return $1;
  50. }, function($ctx1) {$ctx1.fill(self,"interpret:receiver:withArguments:",{aString:aString,anObject:anObject,aDictionary:aDictionary,ctx:ctx},smalltalk.AbstractASTInterpreterTest)})},
  51. messageSends: ["new", "receiver:", "keysAndValuesDo:", "localAt:put:", "context:", "interpreter", "interpret:", "first", "nodes", "parse:forClass:", "class", "result"]}),
  52. smalltalk.AbstractASTInterpreterTest);
  53. smalltalk.addMethod(
  54. "_interpret_withArguments_",
  55. smalltalk.method({
  56. selector: "interpret:withArguments:",
  57. fn: function (aString,aDictionary){
  58. var self=this;
  59. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  60. return smalltalk.withContext(function($ctx1) { var $1;
  61. $1=_st(self)._interpret_receiver_withArguments_(aString,_st($Object())._new(),aDictionary);
  62. return $1;
  63. }, function($ctx1) {$ctx1.fill(self,"interpret:withArguments:",{aString:aString,aDictionary:aDictionary},smalltalk.AbstractASTInterpreterTest)})},
  64. messageSends: ["interpret:receiver:withArguments:", "new"]}),
  65. smalltalk.AbstractASTInterpreterTest);
  66. smalltalk.addMethod(
  67. "_interpreter",
  68. smalltalk.method({
  69. selector: "interpreter",
  70. fn: function (){
  71. var self=this;
  72. return smalltalk.withContext(function($ctx1) { var $1;
  73. $1=_st(self)._subclassResponsibility();
  74. return $1;
  75. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.AbstractASTInterpreterTest)})},
  76. messageSends: ["subclassResponsibility"]}),
  77. smalltalk.AbstractASTInterpreterTest);
  78. smalltalk.addMethod(
  79. "_parse_",
  80. smalltalk.method({
  81. selector: "parse:",
  82. fn: function (aString){
  83. var self=this;
  84. function $Smalltalk(){return smalltalk.Smalltalk||(typeof Smalltalk=="undefined"?nil:Smalltalk)}
  85. return smalltalk.withContext(function($ctx1) { var $1;
  86. $1=_st(_st($Smalltalk())._current())._parse_(aString);
  87. return $1;
  88. }, function($ctx1) {$ctx1.fill(self,"parse:",{aString:aString},smalltalk.AbstractASTInterpreterTest)})},
  89. messageSends: ["parse:", "current"]}),
  90. smalltalk.AbstractASTInterpreterTest);
  91. smalltalk.addMethod(
  92. "_parse_forClass_",
  93. smalltalk.method({
  94. selector: "parse:forClass:",
  95. fn: function (aString,aClass){
  96. var self=this;
  97. return smalltalk.withContext(function($ctx1) { var $1;
  98. $1=_st(self)._analyze_forClass_(_st(self)._parse_(aString),aClass);
  99. return $1;
  100. }, function($ctx1) {$ctx1.fill(self,"parse:forClass:",{aString:aString,aClass:aClass},smalltalk.AbstractASTInterpreterTest)})},
  101. messageSends: ["analyze:forClass:", "parse:"]}),
  102. smalltalk.AbstractASTInterpreterTest);
  103. smalltalk.addClass('ASTInterpreterTest', smalltalk.AbstractASTInterpreterTest, [], 'Compiler-Tests');
  104. smalltalk.addMethod(
  105. "_interpreter",
  106. smalltalk.method({
  107. selector: "interpreter",
  108. fn: function (){
  109. var self=this;
  110. function $ASTInterpreter(){return smalltalk.ASTInterpreter||(typeof ASTInterpreter=="undefined"?nil:ASTInterpreter)}
  111. return smalltalk.withContext(function($ctx1) { var $1;
  112. $1=_st($ASTInterpreter())._new();
  113. return $1;
  114. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTInterpreterTest)})},
  115. messageSends: ["new"]}),
  116. smalltalk.ASTInterpreterTest);
  117. smalltalk.addMethod(
  118. "_testBinarySend",
  119. smalltalk.method({
  120. selector: "testBinarySend",
  121. fn: function (){
  122. var self=this;
  123. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo 2+3+4"),(9));
  124. return self}, function($ctx1) {$ctx1.fill(self,"testBinarySend",{},smalltalk.ASTInterpreterTest)})},
  125. messageSends: ["assert:equals:", "interpret:"]}),
  126. smalltalk.ASTInterpreterTest);
  127. smalltalk.addMethod(
  128. "_testBlockLiteral",
  129. smalltalk.method({
  130. selector: "testBlockLiteral",
  131. fn: function (){
  132. var self=this;
  133. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo ^ true ifTrue: [ 1 ] ifFalse: [ 2 ]"),(1));
  134. _st(self)._assert_equals_(_st(self)._interpret_("foo true ifTrue: [ ^ 1 ] ifFalse: [ 2 ]"),(1));
  135. _st(self)._assert_equals_(_st(self)._interpret_("foo ^ false ifTrue: [ 1 ] ifFalse: [ 2 ]"),(2));
  136. return self}, function($ctx1) {$ctx1.fill(self,"testBlockLiteral",{},smalltalk.ASTInterpreterTest)})},
  137. messageSends: ["assert:equals:", "interpret:"]}),
  138. smalltalk.ASTInterpreterTest);
  139. smalltalk.addMethod(
  140. "_testCascade",
  141. smalltalk.method({
  142. selector: "testCascade",
  143. fn: function (){
  144. var self=this;
  145. function $OrderedCollection(){return smalltalk.OrderedCollection||(typeof OrderedCollection=="undefined"?nil:OrderedCollection)}
  146. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo ^ OrderedCollection new add: 2; add: 3; yourself"),_st($OrderedCollection())._with_with_((2),(3)));
  147. return self}, function($ctx1) {$ctx1.fill(self,"testCascade",{},smalltalk.ASTInterpreterTest)})},
  148. messageSends: ["assert:equals:", "interpret:", "with:with:"]}),
  149. smalltalk.ASTInterpreterTest);
  150. smalltalk.addMethod(
  151. "_testDynamicArray",
  152. smalltalk.method({
  153. selector: "testDynamicArray",
  154. fn: function (){
  155. var self=this;
  156. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo ^ {1+1. 2+2}"),[(2), (4)]);
  157. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArray",{},smalltalk.ASTInterpreterTest)})},
  158. messageSends: ["assert:equals:", "interpret:"]}),
  159. smalltalk.ASTInterpreterTest);
  160. smalltalk.addMethod(
  161. "_testDynamicDictionary",
  162. smalltalk.method({
  163. selector: "testDynamicDictionary",
  164. fn: function (){
  165. var self=this;
  166. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo ^ #{1->1. 2->3}"),smalltalk.HashedCollection._fromPairs_([_st((1)).__minus_gt((1)),_st((2)).__minus_gt((3))]));
  167. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionary",{},smalltalk.ASTInterpreterTest)})},
  168. messageSends: ["assert:equals:", "interpret:", "->"]}),
  169. smalltalk.ASTInterpreterTest);
  170. smalltalk.addMethod(
  171. "_testInlinedJSStatement",
  172. smalltalk.method({
  173. selector: "testInlinedJSStatement",
  174. fn: function (){
  175. var self=this;
  176. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo <return 2+3>"),(5));
  177. _st(self)._assert_equals_(_st(self)._interpret_withArguments_("foo: anInteger <return 2 + anInteger>",smalltalk.HashedCollection._fromPairs_([_st("anInteger").__minus_gt((3))])),(5));
  178. return self}, function($ctx1) {$ctx1.fill(self,"testInlinedJSStatement",{},smalltalk.ASTInterpreterTest)})},
  179. messageSends: ["assert:equals:", "interpret:", "interpret:withArguments:", "->"]}),
  180. smalltalk.ASTInterpreterTest);
  181. smalltalk.addMethod(
  182. "_testInstVarAccess",
  183. smalltalk.method({
  184. selector: "testInstVarAccess",
  185. fn: function (){
  186. var self=this;
  187. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_receiver_withArguments_("foo ^ x",_st((2)).__at((3)),smalltalk.HashedCollection._fromPairs_([])),(2));
  188. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAccess",{},smalltalk.ASTInterpreterTest)})},
  189. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  190. smalltalk.ASTInterpreterTest);
  191. smalltalk.addMethod(
  192. "_testInstVarAssignment",
  193. smalltalk.method({
  194. selector: "testInstVarAssignment",
  195. fn: function (){
  196. var self=this;
  197. function $Point(){return smalltalk.Point||(typeof Point=="undefined"?nil:Point)}
  198. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_receiver_withArguments_("foo: anInteger x := anInteger. ^ x",_st($Point())._new(),smalltalk.HashedCollection._fromPairs_([_st("anInteger").__minus_gt((2))])),(2));
  199. return self}, function($ctx1) {$ctx1.fill(self,"testInstVarAssignment",{},smalltalk.ASTInterpreterTest)})},
  200. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "new", "->"]}),
  201. smalltalk.ASTInterpreterTest);
  202. smalltalk.addMethod(
  203. "_testNonlocalReturn",
  204. smalltalk.method({
  205. selector: "testNonlocalReturn",
  206. fn: function (){
  207. var self=this;
  208. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo true ifTrue: [ ^ 1 ]. ^2"),(1));
  209. return self}, function($ctx1) {$ctx1.fill(self,"testNonlocalReturn",{},smalltalk.ASTInterpreterTest)})},
  210. messageSends: ["assert:equals:", "interpret:"]}),
  211. smalltalk.ASTInterpreterTest);
  212. smalltalk.addMethod(
  213. "_testReceiver",
  214. smalltalk.method({
  215. selector: "testReceiver",
  216. fn: function (){
  217. var self=this;
  218. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_receiver_withArguments_("foo ^ self",_st((2)).__at((3)),smalltalk.HashedCollection._fromPairs_([])),_st((2)).__at((3)));
  219. return self}, function($ctx1) {$ctx1.fill(self,"testReceiver",{},smalltalk.ASTInterpreterTest)})},
  220. messageSends: ["assert:equals:", "interpret:receiver:withArguments:", "@"]}),
  221. smalltalk.ASTInterpreterTest);
  222. smalltalk.addMethod(
  223. "_testTempAssignment",
  224. smalltalk.method({
  225. selector: "testTempAssignment",
  226. fn: function (){
  227. var self=this;
  228. return smalltalk.withContext(function($ctx1) { _st(self)._assert_equals_(_st(self)._interpret_("foo | a | a := 2. ^ a"),(2));
  229. return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{},smalltalk.ASTInterpreterTest)})},
  230. messageSends: ["assert:equals:", "interpret:"]}),
  231. smalltalk.ASTInterpreterTest);
  232. smalltalk.addClass('ASTSteppingInterpreterTest', smalltalk.AbstractASTInterpreterTest, ['interpreter'], 'Compiler-Tests');
  233. smalltalk.addMethod(
  234. "_interpreter",
  235. smalltalk.method({
  236. selector: "interpreter",
  237. fn: function (){
  238. var self=this;
  239. function $ASTSteppingInterpreter(){return smalltalk.ASTSteppingInterpreter||(typeof ASTSteppingInterpreter=="undefined"?nil:ASTSteppingInterpreter)}
  240. return smalltalk.withContext(function($ctx1) { var $2,$1;
  241. $2=self["@interpreter"];
  242. if(($receiver = $2) == nil || $receiver == undefined){
  243. self["@interpreter"]=_st($ASTSteppingInterpreter())._new();
  244. $1=self["@interpreter"];
  245. } else {
  246. $1=$2;
  247. };
  248. return $1;
  249. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTSteppingInterpreterTest)})},
  250. messageSends: ["ifNil:", "new"]}),
  251. smalltalk.ASTSteppingInterpreterTest);
  252. smalltalk.addMethod(
  253. "_testAtEnd",
  254. smalltalk.method({
  255. selector: "testAtEnd",
  256. fn: function (){
  257. var self=this;
  258. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_("foo 1 + 2");
  259. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  260. _st(_st(self)._interpreter())._step();
  261. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  262. _st(_st(self)._interpreter())._step();
  263. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  264. _st(_st(self)._interpreter())._step();
  265. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  266. _st(_st(self)._interpreter())._step();
  267. _st(self)._assert_(_st(_st(self)._interpreter())._atEnd());
  268. return self}, function($ctx1) {$ctx1.fill(self,"testAtEnd",{},smalltalk.ASTSteppingInterpreterTest)})},
  269. messageSends: ["interpret:", "deny:", "atEnd", "interpreter", "step", "assert:"]}),
  270. smalltalk.ASTSteppingInterpreterTest);
  271. smalltalk.addMethod(
  272. "_testMessageSend",
  273. smalltalk.method({
  274. selector: "testMessageSend",
  275. fn: function (){
  276. var self=this;
  277. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_("foo 1 + 2");
  278. _st(_st(self)._interpreter())._step();
  279. _st(_st(self)._interpreter())._step();
  280. _st(_st(self)._interpreter())._step();
  281. _st(self)._assert_equals_(_st(_st(_st(self)._interpreter())._currentNode())._value(),(1));
  282. _st(_st(self)._interpreter())._step();
  283. _st(self)._assert_equals_(_st(_st(_st(self)._interpreter())._currentNode())._value(),(2));
  284. _st(_st(self)._interpreter())._step();
  285. _st(self)._assert_equals_(_st(_st(self)._interpreter())._result(),(3));
  286. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{},smalltalk.ASTSteppingInterpreterTest)})},
  287. messageSends: ["interpret:", "step", "interpreter", "assert:equals:", "value", "currentNode", "result"]}),
  288. smalltalk.ASTSteppingInterpreterTest);
  289. smalltalk.addMethod(
  290. "_testSimpleStepping",
  291. smalltalk.method({
  292. selector: "testSimpleStepping",
  293. fn: function (){
  294. var self=this;
  295. return smalltalk.withContext(function($ctx1) { _st(self)._interpret_("foo 1");
  296. _st(_st(self)._interpreter())._step();
  297. _st(self)._assert_(_st(_st(_st(self)._interpreter())._result())._isNil());
  298. _st(_st(self)._interpreter())._step();
  299. _st(self)._assert_equals_(_st(_st(self)._interpreter())._result(),(1));
  300. return self}, function($ctx1) {$ctx1.fill(self,"testSimpleStepping",{},smalltalk.ASTSteppingInterpreterTest)})},
  301. messageSends: ["interpret:", "step", "interpreter", "assert:", "isNil", "result", "assert:equals:"]}),
  302. smalltalk.ASTSteppingInterpreterTest);
  303. smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
  304. smalltalk.addMethod(
  305. "_codeGeneratorClass",
  306. smalltalk.method({
  307. selector: "codeGeneratorClass",
  308. fn: function (){
  309. var self=this;
  310. function $CodeGenerator(){return smalltalk.CodeGenerator||(typeof CodeGenerator=="undefined"?nil:CodeGenerator)}
  311. return smalltalk.withContext(function($ctx1) { var $1;
  312. $1=$CodeGenerator();
  313. return $1;
  314. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.CodeGeneratorTest)})},
  315. messageSends: []}),
  316. smalltalk.CodeGeneratorTest);
  317. smalltalk.addMethod(
  318. "_compiler",
  319. smalltalk.method({
  320. selector: "compiler",
  321. fn: function (){
  322. var self=this;
  323. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  324. return smalltalk.withContext(function($ctx1) { var $2,$3,$1;
  325. $2=_st($Compiler())._new();
  326. _st($2)._codeGeneratorClass_(_st(self)._codeGeneratorClass());
  327. $3=_st($2)._yourself();
  328. $1=$3;
  329. return $1;
  330. }, function($ctx1) {$ctx1.fill(self,"compiler",{},smalltalk.CodeGeneratorTest)})},
  331. messageSends: ["codeGeneratorClass:", "codeGeneratorClass", "new", "yourself"]}),
  332. smalltalk.CodeGeneratorTest);
  333. smalltalk.addMethod(
  334. "_setUp",
  335. smalltalk.method({
  336. selector: "setUp",
  337. fn: function (){
  338. var self=this;
  339. return smalltalk.withContext(function($ctx1) { self["@receiver"]=_st(_st(self)._targetClass())._new();
  340. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.CodeGeneratorTest)})},
  341. messageSends: ["new", "targetClass"]}),
  342. smalltalk.CodeGeneratorTest);
  343. smalltalk.addMethod(
  344. "_should_return_",
  345. smalltalk.method({
  346. selector: "should:return:",
  347. fn: function (aString,anObject){
  348. var self=this;
  349. var method,result;
  350. return smalltalk.withContext(function($ctx1) { method=_st(_st(self)._compiler())._install_forClass_category_(aString,_st(self)._targetClass(),"tests");
  351. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  352. _st(_st(self)._targetClass())._removeCompiledMethod_(method);
  353. _st(self)._assert_equals_(anObject,result);
  354. return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result},smalltalk.CodeGeneratorTest)})},
  355. messageSends: ["install:forClass:category:", "targetClass", "compiler", "perform:", "selector", "removeCompiledMethod:", "assert:equals:"]}),
  356. smalltalk.CodeGeneratorTest);
  357. smalltalk.addMethod(
  358. "_targetClass",
  359. smalltalk.method({
  360. selector: "targetClass",
  361. fn: function (){
  362. var self=this;
  363. function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  364. return smalltalk.withContext(function($ctx1) { var $1;
  365. $1=$DoIt();
  366. return $1;
  367. }, function($ctx1) {$ctx1.fill(self,"targetClass",{},smalltalk.CodeGeneratorTest)})},
  368. messageSends: []}),
  369. smalltalk.CodeGeneratorTest);
  370. smalltalk.addMethod(
  371. "_tearDown",
  372. smalltalk.method({
  373. selector: "tearDown",
  374. fn: function (){
  375. var self=this;
  376. return smalltalk.withContext(function($ctx1) { return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.CodeGeneratorTest)})},
  377. messageSends: []}),
  378. smalltalk.CodeGeneratorTest);
  379. smalltalk.addMethod(
  380. "_testAssignment",
  381. smalltalk.method({
  382. selector: "testAssignment",
  383. fn: function (){
  384. var self=this;
  385. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  386. _st(self)._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  387. _st(self)._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  388. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{},smalltalk.CodeGeneratorTest)})},
  389. messageSends: ["should:return:"]}),
  390. smalltalk.CodeGeneratorTest);
  391. smalltalk.addMethod(
  392. "_testBlockReturn",
  393. smalltalk.method({
  394. selector: "testBlockReturn",
  395. fn: function (){
  396. var self=this;
  397. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  398. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  399. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  400. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{},smalltalk.CodeGeneratorTest)})},
  401. messageSends: ["should:return:"]}),
  402. smalltalk.CodeGeneratorTest);
  403. smalltalk.addMethod(
  404. "_testCascades",
  405. smalltalk.method({
  406. selector: "testCascades",
  407. fn: function (){
  408. var self=this;
  409. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  410. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{},smalltalk.CodeGeneratorTest)})},
  411. messageSends: ["should:return:"]}),
  412. smalltalk.CodeGeneratorTest);
  413. smalltalk.addMethod(
  414. "_testDynamicArrayElementsOrdered",
  415. smalltalk.method({
  416. selector: "testDynamicArrayElementsOrdered",
  417. fn: function (){
  418. var self=this;
  419. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  420. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  421. messageSends: ["should:return:"]}),
  422. smalltalk.CodeGeneratorTest);
  423. smalltalk.addMethod(
  424. "_testDynamicDictionaryElementsOrdered",
  425. smalltalk.method({
  426. selector: "testDynamicDictionaryElementsOrdered",
  427. fn: function (){
  428. var self=this;
  429. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 'foo'->1.\x0a\x09^ #{ x. (true ifTrue: [ x := 'bar'->2 ]) }\x0a",smalltalk.HashedCollection._fromPairs_([_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]));
  430. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  431. messageSends: ["should:return:", "->"]}),
  432. smalltalk.CodeGeneratorTest);
  433. smalltalk.addMethod(
  434. "_testInnerTemporalDependentElementsOrdered",
  435. smalltalk.method({
  436. selector: "testInnerTemporalDependentElementsOrdered",
  437. fn: function (){
  438. var self=this;
  439. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  440. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",[_st("foo").__minus_gt($Array()),_st("bar").__minus_gt((2))]);
  441. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: 'foo'->x with: 'bar'->(true ifTrue: [ x := 2 ])\x0a",[_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]);
  442. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",[_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]);
  443. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ #{ 'foo'->x. 'bar'->(true ifTrue: [ x := 2 ]) }\x0a",smalltalk.HashedCollection._fromPairs_([_st("foo").__minus_gt((1)),_st("bar").__minus_gt((2))]));
  444. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  445. messageSends: ["should:return:", "->"]}),
  446. smalltalk.CodeGeneratorTest);
  447. smalltalk.addMethod(
  448. "_testLiterals",
  449. smalltalk.method({
  450. selector: "testLiterals",
  451. fn: function (){
  452. var self=this;
  453. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1",(1));
  454. _st(self)._should_return_("foo ^ 'hello'","hello");
  455. _st(self)._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  456. _st(self)._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  457. _st(self)._should_return_("foo ^ true",true);
  458. _st(self)._should_return_("foo ^ false",false);
  459. _st(self)._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._fromPairs_([_st((1)).__minus_gt((2)),_st((3)).__minus_gt((4))]));
  460. _st(self)._should_return_("foo ^ #hello","hello");
  461. _st(self)._should_return_("foo ^ -123.456",(-123.456));
  462. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{},smalltalk.CodeGeneratorTest)})},
  463. messageSends: ["should:return:", "->"]}),
  464. smalltalk.CodeGeneratorTest);
  465. smalltalk.addMethod(
  466. "_testLocalReturn",
  467. smalltalk.method({
  468. selector: "testLocalReturn",
  469. fn: function (){
  470. var self=this;
  471. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1",(1));
  472. _st(self)._should_return_("foo ^ 1 + 1",(2));
  473. _st(self)._should_return_("foo ",self["@receiver"]);
  474. _st(self)._should_return_("foo self asString",self["@receiver"]);
  475. _st(self)._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  476. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  477. messageSends: ["should:return:"]}),
  478. smalltalk.CodeGeneratorTest);
  479. smalltalk.addMethod(
  480. "_testMessageSends",
  481. smalltalk.method({
  482. selector: "testMessageSends",
  483. fn: function (){
  484. var self=this;
  485. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 asString","1");
  486. _st(self)._should_return_("foo ^ 1 + 1",(2));
  487. _st(self)._should_return_("foo ^ 1 + 2 * 3",(9));
  488. _st(self)._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  489. _st(self)._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  490. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{},smalltalk.CodeGeneratorTest)})},
  491. messageSends: ["should:return:"]}),
  492. smalltalk.CodeGeneratorTest);
  493. smalltalk.addMethod(
  494. "_testMutableLiterals",
  495. smalltalk.method({
  496. selector: "testMutableLiterals",
  497. fn: function (){
  498. var self=this;
  499. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ #( 1 2 ) at: 1 put: 3; yourself",[(3), (2)]);
  500. return self}, function($ctx1) {$ctx1.fill(self,"testMutableLiterals",{},smalltalk.CodeGeneratorTest)})},
  501. messageSends: ["should:return:"]}),
  502. smalltalk.CodeGeneratorTest);
  503. smalltalk.addMethod(
  504. "_testNestedIfTrue",
  505. smalltalk.method({
  506. selector: "testNestedIfTrue",
  507. fn: function (){
  508. var self=this;
  509. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  510. _st(self)._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  511. _st(self)._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  512. _st(self)._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  513. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{},smalltalk.CodeGeneratorTest)})},
  514. messageSends: ["should:return:"]}),
  515. smalltalk.CodeGeneratorTest);
  516. smalltalk.addMethod(
  517. "_testNonLocalReturn",
  518. smalltalk.method({
  519. selector: "testNonLocalReturn",
  520. fn: function (){
  521. var self=this;
  522. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo [ ^ 1 ] value",(1));
  523. _st(self)._should_return_("foo [ ^ 1 + 1 ] value",(2));
  524. _st(self)._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  525. _st(self)._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  526. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  527. messageSends: ["should:return:"]}),
  528. smalltalk.CodeGeneratorTest);
  529. smalltalk.addMethod(
  530. "_testPascalCaseGlobal",
  531. smalltalk.method({
  532. selector: "testPascalCaseGlobal",
  533. fn: function (){
  534. var self=this;
  535. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^Object",_st(smalltalk)._at_("Object"));
  536. _st(self)._should_return_("foo ^NonExistent",nil);
  537. return self}, function($ctx1) {$ctx1.fill(self,"testPascalCaseGlobal",{},smalltalk.CodeGeneratorTest)})},
  538. messageSends: ["should:return:", "at:"]}),
  539. smalltalk.CodeGeneratorTest);
  540. smalltalk.addMethod(
  541. "_testSendReceiverAndArgumentsOrdered",
  542. smalltalk.method({
  543. selector: "testSendReceiverAndArgumentsOrdered",
  544. fn: function (){
  545. var self=this;
  546. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  547. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  548. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[$Array(),(2)]);
  549. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{},smalltalk.CodeGeneratorTest)})},
  550. messageSends: ["should:return:"]}),
  551. smalltalk.CodeGeneratorTest);
  552. smalltalk.addMethod(
  553. "_testifFalse",
  554. smalltalk.method({
  555. selector: "testifFalse",
  556. fn: function (){
  557. var self=this;
  558. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  559. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  560. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  561. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  562. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{},smalltalk.CodeGeneratorTest)})},
  563. messageSends: ["should:return:"]}),
  564. smalltalk.CodeGeneratorTest);
  565. smalltalk.addMethod(
  566. "_testifFalseIfTrue",
  567. smalltalk.method({
  568. selector: "testifFalseIfTrue",
  569. fn: function (){
  570. var self=this;
  571. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  572. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  573. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  574. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  575. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{},smalltalk.CodeGeneratorTest)})},
  576. messageSends: ["should:return:"]}),
  577. smalltalk.CodeGeneratorTest);
  578. smalltalk.addMethod(
  579. "_testifNil",
  580. smalltalk.method({
  581. selector: "testifNil",
  582. fn: function (){
  583. var self=this;
  584. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  585. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  586. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  587. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  588. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{},smalltalk.CodeGeneratorTest)})},
  589. messageSends: ["should:return:"]}),
  590. smalltalk.CodeGeneratorTest);
  591. smalltalk.addMethod(
  592. "_testifNilIfNotNil",
  593. smalltalk.method({
  594. selector: "testifNilIfNotNil",
  595. fn: function (){
  596. var self=this;
  597. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  598. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  599. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  600. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  601. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{},smalltalk.CodeGeneratorTest)})},
  602. messageSends: ["should:return:"]}),
  603. smalltalk.CodeGeneratorTest);
  604. smalltalk.addMethod(
  605. "_testifNotNil",
  606. smalltalk.method({
  607. selector: "testifNotNil",
  608. fn: function (){
  609. var self=this;
  610. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  611. _st(self)._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  612. _st(self)._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  613. _st(self)._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  614. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{},smalltalk.CodeGeneratorTest)})},
  615. messageSends: ["should:return:"]}),
  616. smalltalk.CodeGeneratorTest);
  617. smalltalk.addMethod(
  618. "_testifTrue",
  619. smalltalk.method({
  620. selector: "testifTrue",
  621. fn: function (){
  622. var self=this;
  623. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  624. _st(self)._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  625. _st(self)._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  626. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  627. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  628. messageSends: ["should:return:"]}),
  629. smalltalk.CodeGeneratorTest);
  630. smalltalk.addMethod(
  631. "_testifTrueIfFalse",
  632. smalltalk.method({
  633. selector: "testifTrueIfFalse",
  634. fn: function (){
  635. var self=this;
  636. return smalltalk.withContext(function($ctx1) { _st(self)._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  637. _st(self)._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  638. _st(self)._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  639. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  640. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  641. messageSends: ["should:return:"]}),
  642. smalltalk.CodeGeneratorTest);
  643. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  644. smalltalk.addMethod(
  645. "_codeGeneratorClass",
  646. smalltalk.method({
  647. selector: "codeGeneratorClass",
  648. fn: function (){
  649. var self=this;
  650. function $InliningCodeGenerator(){return smalltalk.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  651. return smalltalk.withContext(function($ctx1) { var $1;
  652. $1=$InliningCodeGenerator();
  653. return $1;
  654. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  655. messageSends: []}),
  656. smalltalk.InliningCodeGeneratorTest);
  657. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  658. smalltalk.addMethod(
  659. "_testClassRefVar",
  660. smalltalk.method({
  661. selector: "testClassRefVar",
  662. fn: function (){
  663. var self=this;
  664. var node;
  665. function $ClassReferenceNode(){return smalltalk.ClassReferenceNode||(typeof ClassReferenceNode=="undefined"?nil:ClassReferenceNode)}
  666. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  667. return smalltalk.withContext(function($ctx1) { var $1,$2;
  668. $1=_st($ClassReferenceNode())._new();
  669. _st($1)._value_("Object");
  670. $2=_st($1)._yourself();
  671. node=$2;
  672. _st(_st($SemanticAnalyzer())._new())._visit_(node);
  673. _st(self)._assert_(_st(_st(node)._binding())._isClassRefVar());
  674. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  675. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"]}),
  676. smalltalk.ScopeVarTest);
  677. smalltalk.addMethod(
  678. "_testInstanceVar",
  679. smalltalk.method({
  680. selector: "testInstanceVar",
  681. fn: function (){
  682. var self=this;
  683. var node,scope;
  684. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  685. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  686. return smalltalk.withContext(function($ctx1) { var $1,$2;
  687. $1=_st($VariableNode())._new();
  688. _st($1)._value_("bzzz");
  689. $2=_st($1)._yourself();
  690. node=$2;
  691. scope=_st($MethodLexicalScope())._new();
  692. _st(scope)._addIVar_("bzzz");
  693. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  694. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  695. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"]}),
  696. smalltalk.ScopeVarTest);
  697. smalltalk.addMethod(
  698. "_testPseudoVar",
  699. smalltalk.method({
  700. selector: "testPseudoVar",
  701. fn: function (){
  702. var self=this;
  703. var node,pseudoVars;
  704. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  705. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  706. return smalltalk.withContext(function($ctx1) { var $1,$2;
  707. pseudoVars=["self", "super", "true", "false", "nil"];
  708. _st(pseudoVars)._do_((function(each){
  709. return smalltalk.withContext(function($ctx2) { $1=_st($VariableNode())._new();
  710. _st($1)._value_(each);
  711. $2=_st($1)._yourself();
  712. node=$2;
  713. node;
  714. return _st(self)._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isPseudoVar());
  715. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  716. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  717. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"]}),
  718. smalltalk.ScopeVarTest);
  719. smalltalk.addMethod(
  720. "_testTempVar",
  721. smalltalk.method({
  722. selector: "testTempVar",
  723. fn: function (){
  724. var self=this;
  725. var node,scope;
  726. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  727. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  728. return smalltalk.withContext(function($ctx1) { var $1,$2;
  729. $1=_st($VariableNode())._new();
  730. _st($1)._value_("bzzz");
  731. $2=_st($1)._yourself();
  732. node=$2;
  733. scope=_st($MethodLexicalScope())._new();
  734. _st(scope)._addTemp_("bzzz");
  735. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  736. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  737. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"]}),
  738. smalltalk.ScopeVarTest);
  739. smalltalk.addMethod(
  740. "_testUnknownVar",
  741. smalltalk.method({
  742. selector: "testUnknownVar",
  743. fn: function (){
  744. var self=this;
  745. var node;
  746. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  747. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  748. return smalltalk.withContext(function($ctx1) { var $1,$2;
  749. $1=_st($VariableNode())._new();
  750. _st($1)._value_("bzzz");
  751. $2=_st($1)._yourself();
  752. node=$2;
  753. _st(self)._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isNil());
  754. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  755. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"]}),
  756. smalltalk.ScopeVarTest);
  757. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  758. smalltalk.addMethod(
  759. "_setUp",
  760. smalltalk.method({
  761. selector: "setUp",
  762. fn: function (){
  763. var self=this;
  764. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  765. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  766. return smalltalk.withContext(function($ctx1) { self["@analyzer"]=_st($SemanticAnalyzer())._on_($Object());
  767. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  768. messageSends: ["on:"]}),
  769. smalltalk.SemanticAnalyzerTest);
  770. smalltalk.addMethod(
  771. "_testAssignment",
  772. smalltalk.method({
  773. selector: "testAssignment",
  774. fn: function (){
  775. var self=this;
  776. var src,ast;
  777. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  778. return smalltalk.withContext(function($ctx1) { src="foo self := 1";
  779. ast=_st(smalltalk)._parse_(src);
  780. _st(self)._should_raise_((function(){
  781. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  782. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$InvalidAssignmentError());
  783. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  784. messageSends: ["parse:", "should:raise:", "visit:"]}),
  785. smalltalk.SemanticAnalyzerTest);
  786. smalltalk.addMethod(
  787. "_testNonLocalReturn",
  788. smalltalk.method({
  789. selector: "testNonLocalReturn",
  790. fn: function (){
  791. var self=this;
  792. var src,ast;
  793. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. ^ a";
  794. ast=_st(smalltalk)._parse_(src);
  795. _st(self["@analyzer"])._visit_(ast);
  796. _st(self)._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  797. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  798. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"]}),
  799. smalltalk.SemanticAnalyzerTest);
  800. smalltalk.addMethod(
  801. "_testNonLocalReturn2",
  802. smalltalk.method({
  803. selector: "testNonLocalReturn2",
  804. fn: function (){
  805. var self=this;
  806. var src,ast;
  807. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ ^ a] ]";
  808. ast=_st(smalltalk)._parse_(src);
  809. _st(self["@analyzer"])._visit_(ast);
  810. _st(self)._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  811. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  812. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"]}),
  813. smalltalk.SemanticAnalyzerTest);
  814. smalltalk.addMethod(
  815. "_testScope",
  816. smalltalk.method({
  817. selector: "testScope",
  818. fn: function (){
  819. var self=this;
  820. var src,ast;
  821. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := a ]";
  822. ast=_st(smalltalk)._parse_(src);
  823. _st(self["@analyzer"])._visit_(ast);
  824. _st(self)._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  825. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  826. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"]}),
  827. smalltalk.SemanticAnalyzerTest);
  828. smalltalk.addMethod(
  829. "_testScope2",
  830. smalltalk.method({
  831. selector: "testScope2",
  832. fn: function (){
  833. var self=this;
  834. var src,ast;
  835. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ | b | b := a ] ]";
  836. ast=_st(smalltalk)._parse_(src);
  837. _st(self["@analyzer"])._visit_(ast);
  838. _st(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()));
  839. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  840. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"]}),
  841. smalltalk.SemanticAnalyzerTest);
  842. smalltalk.addMethod(
  843. "_testScopeLevel",
  844. smalltalk.method({
  845. selector: "testScopeLevel",
  846. fn: function (){
  847. var self=this;
  848. var src,ast;
  849. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ | b | b := a ] ]";
  850. ast=_st(smalltalk)._parse_(src);
  851. _st(self["@analyzer"])._visit_(ast);
  852. _st(self)._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  853. _st(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));
  854. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  855. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"]}),
  856. smalltalk.SemanticAnalyzerTest);
  857. smalltalk.addMethod(
  858. "_testUnknownVariables",
  859. smalltalk.method({
  860. selector: "testUnknownVariables",
  861. fn: function (){
  862. var self=this;
  863. var src,ast;
  864. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  865. return smalltalk.withContext(function($ctx1) { src="foo | a | b + a";
  866. ast=_st(smalltalk)._parse_(src);
  867. _st(self)._should_raise_((function(){
  868. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  869. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  870. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  871. messageSends: ["parse:", "should:raise:", "visit:"]}),
  872. smalltalk.SemanticAnalyzerTest);
  873. smalltalk.addMethod(
  874. "_testUnknownVariablesWithScope",
  875. smalltalk.method({
  876. selector: "testUnknownVariablesWithScope",
  877. fn: function (){
  878. var self=this;
  879. var src,ast;
  880. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  881. return smalltalk.withContext(function($ctx1) { src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  882. ast=_st(smalltalk)._parse_(src);
  883. _st(self)._should_raise_((function(){
  884. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  885. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  886. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  887. messageSends: ["parse:", "should:raise:", "visit:"]}),
  888. smalltalk.SemanticAnalyzerTest);
  889. smalltalk.addMethod(
  890. "_testVariableShadowing",
  891. smalltalk.method({
  892. selector: "testVariableShadowing",
  893. fn: function (){
  894. var self=this;
  895. var src,ast;
  896. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1";
  897. ast=_st(smalltalk)._parse_(src);
  898. _st(self["@analyzer"])._visit_(ast);
  899. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  900. messageSends: ["parse:", "visit:"]}),
  901. smalltalk.SemanticAnalyzerTest);
  902. smalltalk.addMethod(
  903. "_testVariableShadowing2",
  904. smalltalk.method({
  905. selector: "testVariableShadowing2",
  906. fn: function (){
  907. var self=this;
  908. var src,ast;
  909. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  910. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | a | a := 2 ]";
  911. ast=_st(smalltalk)._parse_(src);
  912. _st(self)._should_raise_((function(){
  913. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  914. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  915. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  916. messageSends: ["parse:", "should:raise:", "visit:"]}),
  917. smalltalk.SemanticAnalyzerTest);
  918. smalltalk.addMethod(
  919. "_testVariableShadowing3",
  920. smalltalk.method({
  921. selector: "testVariableShadowing3",
  922. fn: function (){
  923. var self=this;
  924. var src,ast;
  925. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := 2 ]";
  926. ast=_st(smalltalk)._parse_(src);
  927. _st(self["@analyzer"])._visit_(ast);
  928. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  929. messageSends: ["parse:", "visit:"]}),
  930. smalltalk.SemanticAnalyzerTest);
  931. smalltalk.addMethod(
  932. "_testVariableShadowing4",
  933. smalltalk.method({
  934. selector: "testVariableShadowing4",
  935. fn: function (){
  936. var self=this;
  937. var src,ast;
  938. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  939. ast=_st(smalltalk)._parse_(src);
  940. _st(self["@analyzer"])._visit_(ast);
  941. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  942. messageSends: ["parse:", "visit:"]}),
  943. smalltalk.SemanticAnalyzerTest);
  944. smalltalk.addMethod(
  945. "_testVariableShadowing5",
  946. smalltalk.method({
  947. selector: "testVariableShadowing5",
  948. fn: function (){
  949. var self=this;
  950. var src,ast;
  951. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  952. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  953. ast=_st(smalltalk)._parse_(src);
  954. _st(self)._should_raise_((function(){
  955. return smalltalk.withContext(function($ctx2) { return _st(self["@analyzer"])._visit_(ast);
  956. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  957. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  958. messageSends: ["parse:", "should:raise:", "visit:"]}),
  959. smalltalk.SemanticAnalyzerTest);
  960. smalltalk.addMethod(
  961. "_testVariablesLookup",
  962. smalltalk.method({
  963. selector: "testVariablesLookup",
  964. fn: function (){
  965. var self=this;
  966. var src,ast;
  967. return smalltalk.withContext(function($ctx1) { src="foo | a | a + 1. [ | b | b := a ]";
  968. ast=_st(smalltalk)._parse_(src);
  969. _st(self["@analyzer"])._visit_(ast);
  970. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  971. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  972. _st(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());
  973. _st(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()));
  974. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  975. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"]}),
  976. smalltalk.SemanticAnalyzerTest);