Compiler-Tests.deploy.js 47 KB

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