Compiler-Tests.deploy.js 47 KB

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