Compiler-Tests.deploy.js 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  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. "_testifTrue",
  680. smalltalk.method({
  681. selector: "testifTrue",
  682. fn: function (){
  683. var self=this;
  684. return smalltalk.withContext(function($ctx1) {
  685. _st(self)._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  686. _st(self)._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  687. _st(self)._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  688. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  689. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  690. messageSends: ["should:return:"]}),
  691. smalltalk.CodeGeneratorTest);
  692. smalltalk.addMethod(
  693. "_testifTrueIfFalse",
  694. smalltalk.method({
  695. selector: "testifTrueIfFalse",
  696. fn: function (){
  697. var self=this;
  698. return smalltalk.withContext(function($ctx1) {
  699. _st(self)._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  700. _st(self)._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  701. _st(self)._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  702. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  703. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  704. messageSends: ["should:return:"]}),
  705. smalltalk.CodeGeneratorTest);
  706. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  707. smalltalk.addMethod(
  708. "_codeGeneratorClass",
  709. smalltalk.method({
  710. selector: "codeGeneratorClass",
  711. fn: function (){
  712. var self=this;
  713. function $InliningCodeGenerator(){return smalltalk.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  714. return smalltalk.withContext(function($ctx1) {
  715. var $1;
  716. $1=$InliningCodeGenerator();
  717. return $1;
  718. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  719. messageSends: []}),
  720. smalltalk.InliningCodeGeneratorTest);
  721. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  722. smalltalk.addMethod(
  723. "_testClassRefVar",
  724. smalltalk.method({
  725. selector: "testClassRefVar",
  726. fn: function (){
  727. var self=this;
  728. var node;
  729. function $ClassReferenceNode(){return smalltalk.ClassReferenceNode||(typeof ClassReferenceNode=="undefined"?nil:ClassReferenceNode)}
  730. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  731. return smalltalk.withContext(function($ctx1) {
  732. var $1,$2;
  733. $1=_st($ClassReferenceNode())._new();
  734. _st($1)._value_("Object");
  735. $2=_st($1)._yourself();
  736. node=$2;
  737. _st(_st($SemanticAnalyzer())._new())._visit_(node);
  738. _st(self)._assert_(_st(_st(node)._binding())._isClassRefVar());
  739. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  740. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"]}),
  741. smalltalk.ScopeVarTest);
  742. smalltalk.addMethod(
  743. "_testInstanceVar",
  744. smalltalk.method({
  745. selector: "testInstanceVar",
  746. fn: function (){
  747. var self=this;
  748. var node,scope;
  749. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  750. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  751. return smalltalk.withContext(function($ctx1) {
  752. var $1,$2;
  753. $1=_st($VariableNode())._new();
  754. _st($1)._value_("bzzz");
  755. $2=_st($1)._yourself();
  756. node=$2;
  757. scope=_st($MethodLexicalScope())._new();
  758. _st(scope)._addIVar_("bzzz");
  759. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  760. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  761. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"]}),
  762. smalltalk.ScopeVarTest);
  763. smalltalk.addMethod(
  764. "_testPseudoVar",
  765. smalltalk.method({
  766. selector: "testPseudoVar",
  767. fn: function (){
  768. var self=this;
  769. var node,pseudoVars;
  770. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  771. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  772. return smalltalk.withContext(function($ctx1) {
  773. var $1,$2;
  774. pseudoVars=["self", "super", "true", "false", "nil"];
  775. _st(pseudoVars)._do_((function(each){
  776. return smalltalk.withContext(function($ctx2) {
  777. $1=_st($VariableNode())._new();
  778. _st($1)._value_(each);
  779. $2=_st($1)._yourself();
  780. node=$2;
  781. node;
  782. return _st(self)._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isPseudoVar());
  783. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  784. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  785. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"]}),
  786. smalltalk.ScopeVarTest);
  787. smalltalk.addMethod(
  788. "_testTempVar",
  789. smalltalk.method({
  790. selector: "testTempVar",
  791. fn: function (){
  792. var self=this;
  793. var node,scope;
  794. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  795. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  796. return smalltalk.withContext(function($ctx1) {
  797. var $1,$2;
  798. $1=_st($VariableNode())._new();
  799. _st($1)._value_("bzzz");
  800. $2=_st($1)._yourself();
  801. node=$2;
  802. scope=_st($MethodLexicalScope())._new();
  803. _st(scope)._addTemp_("bzzz");
  804. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  805. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  806. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"]}),
  807. smalltalk.ScopeVarTest);
  808. smalltalk.addMethod(
  809. "_testUnknownVar",
  810. smalltalk.method({
  811. selector: "testUnknownVar",
  812. fn: function (){
  813. var self=this;
  814. var node;
  815. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  816. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  817. return smalltalk.withContext(function($ctx1) {
  818. var $1,$2;
  819. $1=_st($VariableNode())._new();
  820. _st($1)._value_("bzzz");
  821. $2=_st($1)._yourself();
  822. node=$2;
  823. _st(self)._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isNil());
  824. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  825. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"]}),
  826. smalltalk.ScopeVarTest);
  827. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  828. smalltalk.addMethod(
  829. "_setUp",
  830. smalltalk.method({
  831. selector: "setUp",
  832. fn: function (){
  833. var self=this;
  834. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  835. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  836. return smalltalk.withContext(function($ctx1) {
  837. self["@analyzer"]=_st($SemanticAnalyzer())._on_($Object());
  838. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  839. messageSends: ["on:"]}),
  840. smalltalk.SemanticAnalyzerTest);
  841. smalltalk.addMethod(
  842. "_testAssignment",
  843. smalltalk.method({
  844. selector: "testAssignment",
  845. fn: function (){
  846. var self=this;
  847. var src,ast;
  848. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  849. return smalltalk.withContext(function($ctx1) {
  850. src="foo self := 1";
  851. ast=_st(smalltalk)._parse_(src);
  852. _st(self)._should_raise_((function(){
  853. return smalltalk.withContext(function($ctx2) {
  854. return _st(self["@analyzer"])._visit_(ast);
  855. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$InvalidAssignmentError());
  856. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  857. messageSends: ["parse:", "should:raise:", "visit:"]}),
  858. smalltalk.SemanticAnalyzerTest);
  859. smalltalk.addMethod(
  860. "_testNonLocalReturn",
  861. smalltalk.method({
  862. selector: "testNonLocalReturn",
  863. fn: function (){
  864. var self=this;
  865. var src,ast;
  866. return smalltalk.withContext(function($ctx1) {
  867. src="foo | a | a + 1. ^ a";
  868. ast=_st(smalltalk)._parse_(src);
  869. _st(self["@analyzer"])._visit_(ast);
  870. _st(self)._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  871. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  872. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"]}),
  873. smalltalk.SemanticAnalyzerTest);
  874. smalltalk.addMethod(
  875. "_testNonLocalReturn2",
  876. smalltalk.method({
  877. selector: "testNonLocalReturn2",
  878. fn: function (){
  879. var self=this;
  880. var src,ast;
  881. return smalltalk.withContext(function($ctx1) {
  882. src="foo | a | a + 1. [ [ ^ a] ]";
  883. ast=_st(smalltalk)._parse_(src);
  884. _st(self["@analyzer"])._visit_(ast);
  885. _st(self)._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  886. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  887. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"]}),
  888. smalltalk.SemanticAnalyzerTest);
  889. smalltalk.addMethod(
  890. "_testScope",
  891. smalltalk.method({
  892. selector: "testScope",
  893. fn: function (){
  894. var self=this;
  895. var src,ast;
  896. return smalltalk.withContext(function($ctx1) {
  897. src="foo | a | a + 1. [ | b | b := a ]";
  898. ast=_st(smalltalk)._parse_(src);
  899. _st(self["@analyzer"])._visit_(ast);
  900. _st(self)._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  901. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  902. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"]}),
  903. smalltalk.SemanticAnalyzerTest);
  904. smalltalk.addMethod(
  905. "_testScope2",
  906. smalltalk.method({
  907. selector: "testScope2",
  908. fn: function (){
  909. var self=this;
  910. var src,ast;
  911. return smalltalk.withContext(function($ctx1) {
  912. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  913. ast=_st(smalltalk)._parse_(src);
  914. _st(self["@analyzer"])._visit_(ast);
  915. _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()));
  916. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  917. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"]}),
  918. smalltalk.SemanticAnalyzerTest);
  919. smalltalk.addMethod(
  920. "_testScopeLevel",
  921. smalltalk.method({
  922. selector: "testScopeLevel",
  923. fn: function (){
  924. var self=this;
  925. var src,ast;
  926. return smalltalk.withContext(function($ctx1) {
  927. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  928. ast=_st(smalltalk)._parse_(src);
  929. _st(self["@analyzer"])._visit_(ast);
  930. _st(self)._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  931. _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));
  932. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  933. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"]}),
  934. smalltalk.SemanticAnalyzerTest);
  935. smalltalk.addMethod(
  936. "_testUnknownVariables",
  937. smalltalk.method({
  938. selector: "testUnknownVariables",
  939. fn: function (){
  940. var self=this;
  941. var src,ast;
  942. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  943. return smalltalk.withContext(function($ctx1) {
  944. src="foo | a | b + a";
  945. ast=_st(smalltalk)._parse_(src);
  946. _st(self)._should_raise_((function(){
  947. return smalltalk.withContext(function($ctx2) {
  948. return _st(self["@analyzer"])._visit_(ast);
  949. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  950. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  951. messageSends: ["parse:", "should:raise:", "visit:"]}),
  952. smalltalk.SemanticAnalyzerTest);
  953. smalltalk.addMethod(
  954. "_testUnknownVariablesWithScope",
  955. smalltalk.method({
  956. selector: "testUnknownVariablesWithScope",
  957. fn: function (){
  958. var self=this;
  959. var src,ast;
  960. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  961. return smalltalk.withContext(function($ctx1) {
  962. src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  963. ast=_st(smalltalk)._parse_(src);
  964. _st(self)._should_raise_((function(){
  965. return smalltalk.withContext(function($ctx2) {
  966. return _st(self["@analyzer"])._visit_(ast);
  967. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  968. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  969. messageSends: ["parse:", "should:raise:", "visit:"]}),
  970. smalltalk.SemanticAnalyzerTest);
  971. smalltalk.addMethod(
  972. "_testVariableShadowing",
  973. smalltalk.method({
  974. selector: "testVariableShadowing",
  975. fn: function (){
  976. var self=this;
  977. var src,ast;
  978. return smalltalk.withContext(function($ctx1) {
  979. src="foo | a | a + 1";
  980. ast=_st(smalltalk)._parse_(src);
  981. _st(self["@analyzer"])._visit_(ast);
  982. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  983. messageSends: ["parse:", "visit:"]}),
  984. smalltalk.SemanticAnalyzerTest);
  985. smalltalk.addMethod(
  986. "_testVariableShadowing2",
  987. smalltalk.method({
  988. selector: "testVariableShadowing2",
  989. fn: function (){
  990. var self=this;
  991. var src,ast;
  992. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  993. return smalltalk.withContext(function($ctx1) {
  994. src="foo | a | a + 1. [ | a | a := 2 ]";
  995. ast=_st(smalltalk)._parse_(src);
  996. _st(self)._should_raise_((function(){
  997. return smalltalk.withContext(function($ctx2) {
  998. return _st(self["@analyzer"])._visit_(ast);
  999. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  1000. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1001. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1002. smalltalk.SemanticAnalyzerTest);
  1003. smalltalk.addMethod(
  1004. "_testVariableShadowing3",
  1005. smalltalk.method({
  1006. selector: "testVariableShadowing3",
  1007. fn: function (){
  1008. var self=this;
  1009. var src,ast;
  1010. return smalltalk.withContext(function($ctx1) {
  1011. src="foo | a | a + 1. [ | b | b := 2 ]";
  1012. ast=_st(smalltalk)._parse_(src);
  1013. _st(self["@analyzer"])._visit_(ast);
  1014. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1015. messageSends: ["parse:", "visit:"]}),
  1016. smalltalk.SemanticAnalyzerTest);
  1017. smalltalk.addMethod(
  1018. "_testVariableShadowing4",
  1019. smalltalk.method({
  1020. selector: "testVariableShadowing4",
  1021. fn: function (){
  1022. var self=this;
  1023. var src,ast;
  1024. return smalltalk.withContext(function($ctx1) {
  1025. src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  1026. ast=_st(smalltalk)._parse_(src);
  1027. _st(self["@analyzer"])._visit_(ast);
  1028. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1029. messageSends: ["parse:", "visit:"]}),
  1030. smalltalk.SemanticAnalyzerTest);
  1031. smalltalk.addMethod(
  1032. "_testVariableShadowing5",
  1033. smalltalk.method({
  1034. selector: "testVariableShadowing5",
  1035. fn: function (){
  1036. var self=this;
  1037. var src,ast;
  1038. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1039. return smalltalk.withContext(function($ctx1) {
  1040. src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  1041. ast=_st(smalltalk)._parse_(src);
  1042. _st(self)._should_raise_((function(){
  1043. return smalltalk.withContext(function($ctx2) {
  1044. return _st(self["@analyzer"])._visit_(ast);
  1045. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  1046. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1047. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1048. smalltalk.SemanticAnalyzerTest);
  1049. smalltalk.addMethod(
  1050. "_testVariablesLookup",
  1051. smalltalk.method({
  1052. selector: "testVariablesLookup",
  1053. fn: function (){
  1054. var self=this;
  1055. var src,ast;
  1056. return smalltalk.withContext(function($ctx1) {
  1057. src="foo | a | a + 1. [ | b | b := a ]";
  1058. ast=_st(smalltalk)._parse_(src);
  1059. _st(self["@analyzer"])._visit_(ast);
  1060. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  1061. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  1062. _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());
  1063. _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()));
  1064. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1065. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"]}),
  1066. smalltalk.SemanticAnalyzerTest);