Compiler-Tests.deploy.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183
  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.addMethod(
  253. "_testThisContext",
  254. smalltalk.method({
  255. selector: "testThisContext",
  256. fn: function (){
  257. var self=this;
  258. return smalltalk.withContext(function($ctx1) {
  259. _st(self)._assert_(_st(_st(_st(self)._interpret_("foo ^ thisContext"))._outerContext())._isNil());
  260. _st(self)._assert_(_st(_st(_st(self)._interpret_("foo ^ [ thisContext ] value"))._outerContext())._notNil());
  261. _st(self)._assert_(_st(self)._interpret_("foo ^ [ thisContext ] value outerContext == thisContext"));
  262. return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.ASTInterpreterTest)})},
  263. messageSends: ["assert:", "isNil", "outerContext", "interpret:", "notNil"]}),
  264. smalltalk.ASTInterpreterTest);
  265. smalltalk.addClass('ASTSteppingInterpreterTest', smalltalk.AbstractASTInterpreterTest, ['interpreter'], 'Compiler-Tests');
  266. smalltalk.addMethod(
  267. "_interpreter",
  268. smalltalk.method({
  269. selector: "interpreter",
  270. fn: function (){
  271. var self=this;
  272. function $ASTSteppingInterpreter(){return smalltalk.ASTSteppingInterpreter||(typeof ASTSteppingInterpreter=="undefined"?nil:ASTSteppingInterpreter)}
  273. return smalltalk.withContext(function($ctx1) {
  274. var $2,$1;
  275. $2=self["@interpreter"];
  276. if(($receiver = $2) == nil || $receiver == undefined){
  277. self["@interpreter"]=_st($ASTSteppingInterpreter())._new();
  278. $1=self["@interpreter"];
  279. } else {
  280. $1=$2;
  281. };
  282. return $1;
  283. }, function($ctx1) {$ctx1.fill(self,"interpreter",{},smalltalk.ASTSteppingInterpreterTest)})},
  284. messageSends: ["ifNil:", "new"]}),
  285. smalltalk.ASTSteppingInterpreterTest);
  286. smalltalk.addMethod(
  287. "_testAtEnd",
  288. smalltalk.method({
  289. selector: "testAtEnd",
  290. fn: function (){
  291. var self=this;
  292. return smalltalk.withContext(function($ctx1) {
  293. _st(self)._interpret_("foo 1 + 2");
  294. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  295. _st(_st(self)._interpreter())._step();
  296. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  297. _st(_st(self)._interpreter())._step();
  298. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  299. _st(_st(self)._interpreter())._step();
  300. _st(self)._deny_(_st(_st(self)._interpreter())._atEnd());
  301. _st(_st(self)._interpreter())._step();
  302. _st(self)._assert_(_st(_st(self)._interpreter())._atEnd());
  303. return self}, function($ctx1) {$ctx1.fill(self,"testAtEnd",{},smalltalk.ASTSteppingInterpreterTest)})},
  304. messageSends: ["interpret:", "deny:", "atEnd", "interpreter", "step", "assert:"]}),
  305. smalltalk.ASTSteppingInterpreterTest);
  306. smalltalk.addMethod(
  307. "_testMessageSend",
  308. smalltalk.method({
  309. selector: "testMessageSend",
  310. fn: function (){
  311. var self=this;
  312. return smalltalk.withContext(function($ctx1) {
  313. _st(self)._interpret_("foo 1 + 2");
  314. _st(_st(self)._interpreter())._step();
  315. _st(_st(self)._interpreter())._step();
  316. _st(_st(self)._interpreter())._step();
  317. _st(self)._assert_equals_(_st(_st(_st(self)._interpreter())._currentNode())._value(),(1));
  318. _st(_st(self)._interpreter())._step();
  319. _st(self)._assert_equals_(_st(_st(_st(self)._interpreter())._currentNode())._value(),(2));
  320. _st(_st(self)._interpreter())._step();
  321. _st(self)._assert_equals_(_st(_st(self)._interpreter())._result(),(3));
  322. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSend",{},smalltalk.ASTSteppingInterpreterTest)})},
  323. messageSends: ["interpret:", "step", "interpreter", "assert:equals:", "value", "currentNode", "result"]}),
  324. smalltalk.ASTSteppingInterpreterTest);
  325. smalltalk.addMethod(
  326. "_testSimpleStepping",
  327. smalltalk.method({
  328. selector: "testSimpleStepping",
  329. fn: function (){
  330. var self=this;
  331. return smalltalk.withContext(function($ctx1) {
  332. _st(self)._interpret_("foo 1");
  333. _st(_st(self)._interpreter())._step();
  334. _st(self)._assert_(_st(_st(_st(self)._interpreter())._result())._isNil());
  335. _st(_st(self)._interpreter())._step();
  336. _st(self)._assert_equals_(_st(_st(self)._interpreter())._result(),(1));
  337. return self}, function($ctx1) {$ctx1.fill(self,"testSimpleStepping",{},smalltalk.ASTSteppingInterpreterTest)})},
  338. messageSends: ["interpret:", "step", "interpreter", "assert:", "isNil", "result", "assert:equals:"]}),
  339. smalltalk.ASTSteppingInterpreterTest);
  340. smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
  341. smalltalk.addMethod(
  342. "_codeGeneratorClass",
  343. smalltalk.method({
  344. selector: "codeGeneratorClass",
  345. fn: function (){
  346. var self=this;
  347. function $CodeGenerator(){return smalltalk.CodeGenerator||(typeof CodeGenerator=="undefined"?nil:CodeGenerator)}
  348. return smalltalk.withContext(function($ctx1) {
  349. var $1;
  350. $1=$CodeGenerator();
  351. return $1;
  352. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.CodeGeneratorTest)})},
  353. messageSends: []}),
  354. smalltalk.CodeGeneratorTest);
  355. smalltalk.addMethod(
  356. "_compiler",
  357. smalltalk.method({
  358. selector: "compiler",
  359. fn: function (){
  360. var self=this;
  361. function $Compiler(){return smalltalk.Compiler||(typeof Compiler=="undefined"?nil:Compiler)}
  362. return smalltalk.withContext(function($ctx1) {
  363. var $2,$3,$1;
  364. $2=_st($Compiler())._new();
  365. _st($2)._codeGeneratorClass_(_st(self)._codeGeneratorClass());
  366. $3=_st($2)._yourself();
  367. $1=$3;
  368. return $1;
  369. }, function($ctx1) {$ctx1.fill(self,"compiler",{},smalltalk.CodeGeneratorTest)})},
  370. messageSends: ["codeGeneratorClass:", "codeGeneratorClass", "new", "yourself"]}),
  371. smalltalk.CodeGeneratorTest);
  372. smalltalk.addMethod(
  373. "_setUp",
  374. smalltalk.method({
  375. selector: "setUp",
  376. fn: function (){
  377. var self=this;
  378. return smalltalk.withContext(function($ctx1) {
  379. self["@receiver"]=_st(_st(self)._targetClass())._new();
  380. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.CodeGeneratorTest)})},
  381. messageSends: ["new", "targetClass"]}),
  382. smalltalk.CodeGeneratorTest);
  383. smalltalk.addMethod(
  384. "_should_return_",
  385. smalltalk.method({
  386. selector: "should:return:",
  387. fn: function (aString,anObject){
  388. var self=this;
  389. var method,result;
  390. return smalltalk.withContext(function($ctx1) {
  391. method=_st(_st(self)._compiler())._install_forClass_category_(aString,_st(self)._targetClass(),"tests");
  392. result=_st(self["@receiver"])._perform_(_st(method)._selector());
  393. _st(_st(self)._targetClass())._removeCompiledMethod_(method);
  394. _st(self)._assert_equals_(anObject,result);
  395. return self}, function($ctx1) {$ctx1.fill(self,"should:return:",{aString:aString,anObject:anObject,method:method,result:result},smalltalk.CodeGeneratorTest)})},
  396. messageSends: ["install:forClass:category:", "targetClass", "compiler", "perform:", "selector", "removeCompiledMethod:", "assert:equals:"]}),
  397. smalltalk.CodeGeneratorTest);
  398. smalltalk.addMethod(
  399. "_targetClass",
  400. smalltalk.method({
  401. selector: "targetClass",
  402. fn: function (){
  403. var self=this;
  404. function $DoIt(){return smalltalk.DoIt||(typeof DoIt=="undefined"?nil:DoIt)}
  405. return smalltalk.withContext(function($ctx1) {
  406. var $1;
  407. $1=$DoIt();
  408. return $1;
  409. }, function($ctx1) {$ctx1.fill(self,"targetClass",{},smalltalk.CodeGeneratorTest)})},
  410. messageSends: []}),
  411. smalltalk.CodeGeneratorTest);
  412. smalltalk.addMethod(
  413. "_tearDown",
  414. smalltalk.method({
  415. selector: "tearDown",
  416. fn: function (){
  417. var self=this;
  418. return smalltalk.withContext(function($ctx1) {
  419. return self}, function($ctx1) {$ctx1.fill(self,"tearDown",{},smalltalk.CodeGeneratorTest)})},
  420. messageSends: []}),
  421. smalltalk.CodeGeneratorTest);
  422. smalltalk.addMethod(
  423. "_testAssignment",
  424. smalltalk.method({
  425. selector: "testAssignment",
  426. fn: function (){
  427. var self=this;
  428. return smalltalk.withContext(function($ctx1) {
  429. _st(self)._should_return_("foo | a | a := true ifTrue: [ 1 ]. ^ a",(1));
  430. _st(self)._should_return_("foo | a | a := false ifTrue: [ 1 ]. ^ a",nil);
  431. _st(self)._should_return_("foo | a | ^ a := true ifTrue: [ 1 ]",(1));
  432. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{},smalltalk.CodeGeneratorTest)})},
  433. messageSends: ["should:return:"]}),
  434. smalltalk.CodeGeneratorTest);
  435. smalltalk.addMethod(
  436. "_testBackslashSelectors",
  437. smalltalk.method({
  438. selector: "testBackslashSelectors",
  439. fn: function (){
  440. var self=this;
  441. return smalltalk.withContext(function($ctx1) {
  442. _st(self)._should_return_("\x5c arg ^ 4",(4));
  443. _st(self)._should_return_("\x5c\x5c arg ^ 42",(42));
  444. return self}, function($ctx1) {$ctx1.fill(self,"testBackslashSelectors",{},smalltalk.CodeGeneratorTest)})},
  445. messageSends: ["should:return:"]}),
  446. smalltalk.CodeGeneratorTest);
  447. smalltalk.addMethod(
  448. "_testBlockReturn",
  449. smalltalk.method({
  450. selector: "testBlockReturn",
  451. fn: function (){
  452. var self=this;
  453. return smalltalk.withContext(function($ctx1) {
  454. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]",[(2), (3), (4)]);
  455. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]",[(2), (3), (4)]);
  456. _st(self)._should_return_("foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]",[(2), (1), (4)]);
  457. return self}, function($ctx1) {$ctx1.fill(self,"testBlockReturn",{},smalltalk.CodeGeneratorTest)})},
  458. messageSends: ["should:return:"]}),
  459. smalltalk.CodeGeneratorTest);
  460. smalltalk.addMethod(
  461. "_testCascades",
  462. smalltalk.method({
  463. selector: "testCascades",
  464. fn: function (){
  465. var self=this;
  466. return smalltalk.withContext(function($ctx1) {
  467. _st(self)._should_return_("foo ^ Array new add: 3; add: 4; yourself",[(3), (4)]);
  468. return self}, function($ctx1) {$ctx1.fill(self,"testCascades",{},smalltalk.CodeGeneratorTest)})},
  469. messageSends: ["should:return:"]}),
  470. smalltalk.CodeGeneratorTest);
  471. smalltalk.addMethod(
  472. "_testDynamicArrayElementsOrdered",
  473. smalltalk.method({
  474. selector: "testDynamicArrayElementsOrdered",
  475. fn: function (){
  476. var self=this;
  477. return smalltalk.withContext(function($ctx1) {
  478. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ { x. true ifTrue: [ x := 2 ] }\x0a",[(1), (2)]);
  479. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicArrayElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  480. messageSends: ["should:return:"]}),
  481. smalltalk.CodeGeneratorTest);
  482. smalltalk.addMethod(
  483. "_testDynamicDictionaryElementsOrdered",
  484. smalltalk.method({
  485. selector: "testDynamicDictionaryElementsOrdered",
  486. fn: function (){
  487. var self=this;
  488. return smalltalk.withContext(function($ctx1) {
  489. _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))]));
  490. return self}, function($ctx1) {$ctx1.fill(self,"testDynamicDictionaryElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  491. messageSends: ["should:return:", "->"]}),
  492. smalltalk.CodeGeneratorTest);
  493. smalltalk.addMethod(
  494. "_testInnerTemporalDependentElementsOrdered",
  495. smalltalk.method({
  496. selector: "testInnerTemporalDependentElementsOrdered",
  497. fn: function (){
  498. var self=this;
  499. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  500. return smalltalk.withContext(function($ctx1) {
  501. _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))]);
  502. _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))]);
  503. _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))]);
  504. _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))]));
  505. return self}, function($ctx1) {$ctx1.fill(self,"testInnerTemporalDependentElementsOrdered",{},smalltalk.CodeGeneratorTest)})},
  506. messageSends: ["should:return:", "->"]}),
  507. smalltalk.CodeGeneratorTest);
  508. smalltalk.addMethod(
  509. "_testLiterals",
  510. smalltalk.method({
  511. selector: "testLiterals",
  512. fn: function (){
  513. var self=this;
  514. return smalltalk.withContext(function($ctx1) {
  515. _st(self)._should_return_("foo ^ 1",(1));
  516. _st(self)._should_return_("foo ^ 'hello'","hello");
  517. _st(self)._should_return_("foo ^ #(1 2 3 4)",[(1), (2), (3), (4)]);
  518. _st(self)._should_return_("foo ^ {1. [:x | x ] value: 2. 3. [4] value}",[(1), (2), (3), (4)]);
  519. _st(self)._should_return_("foo ^ true",true);
  520. _st(self)._should_return_("foo ^ false",false);
  521. _st(self)._should_return_("foo ^ #{1->2. 3->4}",smalltalk.HashedCollection._fromPairs_([_st((1)).__minus_gt((2)),_st((3)).__minus_gt((4))]));
  522. _st(self)._should_return_("foo ^ #hello","hello");
  523. _st(self)._should_return_("foo ^ -123.456",(-123.456));
  524. return self}, function($ctx1) {$ctx1.fill(self,"testLiterals",{},smalltalk.CodeGeneratorTest)})},
  525. messageSends: ["should:return:", "->"]}),
  526. smalltalk.CodeGeneratorTest);
  527. smalltalk.addMethod(
  528. "_testLocalReturn",
  529. smalltalk.method({
  530. selector: "testLocalReturn",
  531. fn: function (){
  532. var self=this;
  533. return smalltalk.withContext(function($ctx1) {
  534. _st(self)._should_return_("foo ^ 1",(1));
  535. _st(self)._should_return_("foo ^ 1 + 1",(2));
  536. _st(self)._should_return_("foo ",self["@receiver"]);
  537. _st(self)._should_return_("foo self asString",self["@receiver"]);
  538. _st(self)._should_return_("foo | a b | a := 1. b := 2. ^ a + b",(3));
  539. return self}, function($ctx1) {$ctx1.fill(self,"testLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  540. messageSends: ["should:return:"]}),
  541. smalltalk.CodeGeneratorTest);
  542. smalltalk.addMethod(
  543. "_testMessageSends",
  544. smalltalk.method({
  545. selector: "testMessageSends",
  546. fn: function (){
  547. var self=this;
  548. return smalltalk.withContext(function($ctx1) {
  549. _st(self)._should_return_("foo ^ 1 asString","1");
  550. _st(self)._should_return_("foo ^ 1 + 1",(2));
  551. _st(self)._should_return_("foo ^ 1 + 2 * 3",(9));
  552. _st(self)._should_return_("foo ^ 1 to: 3",[(1), (2), (3)]);
  553. _st(self)._should_return_("foo ^ 1 to: 5 by: 2",[(1), (3), (5)]);
  554. return self}, function($ctx1) {$ctx1.fill(self,"testMessageSends",{},smalltalk.CodeGeneratorTest)})},
  555. messageSends: ["should:return:"]}),
  556. smalltalk.CodeGeneratorTest);
  557. smalltalk.addMethod(
  558. "_testMutableLiterals",
  559. smalltalk.method({
  560. selector: "testMutableLiterals",
  561. fn: function (){
  562. var self=this;
  563. return smalltalk.withContext(function($ctx1) {
  564. _st(self)._should_return_("foo ^ #( 1 2 ) at: 1 put: 3; yourself",[(3), (2)]);
  565. return self}, function($ctx1) {$ctx1.fill(self,"testMutableLiterals",{},smalltalk.CodeGeneratorTest)})},
  566. messageSends: ["should:return:"]}),
  567. smalltalk.CodeGeneratorTest);
  568. smalltalk.addMethod(
  569. "_testNestedIfTrue",
  570. smalltalk.method({
  571. selector: "testNestedIfTrue",
  572. fn: function (){
  573. var self=this;
  574. return smalltalk.withContext(function($ctx1) {
  575. _st(self)._should_return_("foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]",(1));
  576. _st(self)._should_return_("foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]",nil);
  577. _st(self)._should_return_("foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]",(1));
  578. _st(self)._should_return_("foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]",self["@receiver"]);
  579. return self}, function($ctx1) {$ctx1.fill(self,"testNestedIfTrue",{},smalltalk.CodeGeneratorTest)})},
  580. messageSends: ["should:return:"]}),
  581. smalltalk.CodeGeneratorTest);
  582. smalltalk.addMethod(
  583. "_testNonLocalReturn",
  584. smalltalk.method({
  585. selector: "testNonLocalReturn",
  586. fn: function (){
  587. var self=this;
  588. return smalltalk.withContext(function($ctx1) {
  589. _st(self)._should_return_("foo [ ^ 1 ] value",(1));
  590. _st(self)._should_return_("foo [ ^ 1 + 1 ] value",(2));
  591. _st(self)._should_return_("foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt",(3));
  592. _st(self)._should_return_("foo [ :x | ^ x + x ] value: 4. ^ 2",(8));
  593. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{},smalltalk.CodeGeneratorTest)})},
  594. messageSends: ["should:return:"]}),
  595. smalltalk.CodeGeneratorTest);
  596. smalltalk.addMethod(
  597. "_testPascalCaseGlobal",
  598. smalltalk.method({
  599. selector: "testPascalCaseGlobal",
  600. fn: function (){
  601. var self=this;
  602. return smalltalk.withContext(function($ctx1) {
  603. _st(self)._should_return_("foo ^Object",_st(smalltalk)._at_("Object"));
  604. _st(self)._should_return_("foo ^NonExistent",nil);
  605. return self}, function($ctx1) {$ctx1.fill(self,"testPascalCaseGlobal",{},smalltalk.CodeGeneratorTest)})},
  606. messageSends: ["should:return:", "at:"]}),
  607. smalltalk.CodeGeneratorTest);
  608. smalltalk.addMethod(
  609. "_testSendReceiverAndArgumentsOrdered",
  610. smalltalk.method({
  611. selector: "testSendReceiverAndArgumentsOrdered",
  612. fn: function (){
  613. var self=this;
  614. function $Array(){return smalltalk.Array||(typeof Array=="undefined"?nil:Array)}
  615. return smalltalk.withContext(function($ctx1) {
  616. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := 1.\x0a\x09^ Array with: x with: (true ifTrue: [ x := 2 ])\x0a",[(1), (2)]);
  617. _st(self)._should_return_("foo\x0a\x09| x |\x0a\x09x := Array.\x0a\x09^ x with: x with: (true ifTrue: [ x := 2 ])\x0a",[$Array(),(2)]);
  618. return self}, function($ctx1) {$ctx1.fill(self,"testSendReceiverAndArgumentsOrdered",{},smalltalk.CodeGeneratorTest)})},
  619. messageSends: ["should:return:"]}),
  620. smalltalk.CodeGeneratorTest);
  621. smalltalk.addMethod(
  622. "_testifFalse",
  623. smalltalk.method({
  624. selector: "testifFalse",
  625. fn: function (){
  626. var self=this;
  627. return smalltalk.withContext(function($ctx1) {
  628. _st(self)._should_return_("foo true ifFalse: [ ^ 1 ]",self["@receiver"]);
  629. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ]",(2));
  630. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ]",nil);
  631. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ]",(2));
  632. return self}, function($ctx1) {$ctx1.fill(self,"testifFalse",{},smalltalk.CodeGeneratorTest)})},
  633. messageSends: ["should:return:"]}),
  634. smalltalk.CodeGeneratorTest);
  635. smalltalk.addMethod(
  636. "_testifFalseIfTrue",
  637. smalltalk.method({
  638. selector: "testifFalseIfTrue",
  639. fn: function (){
  640. var self=this;
  641. return smalltalk.withContext(function($ctx1) {
  642. _st(self)._should_return_("foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]",(2));
  643. _st(self)._should_return_("foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]",(2));
  644. _st(self)._should_return_("foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]",(2));
  645. _st(self)._should_return_("foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]",(2));
  646. return self}, function($ctx1) {$ctx1.fill(self,"testifFalseIfTrue",{},smalltalk.CodeGeneratorTest)})},
  647. messageSends: ["should:return:"]}),
  648. smalltalk.CodeGeneratorTest);
  649. smalltalk.addMethod(
  650. "_testifNil",
  651. smalltalk.method({
  652. selector: "testifNil",
  653. fn: function (){
  654. var self=this;
  655. return smalltalk.withContext(function($ctx1) {
  656. _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ]",(1));
  657. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ]",(2));
  658. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ]",self["@receiver"]);
  659. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ]",(2));
  660. return self}, function($ctx1) {$ctx1.fill(self,"testifNil",{},smalltalk.CodeGeneratorTest)})},
  661. messageSends: ["should:return:"]}),
  662. smalltalk.CodeGeneratorTest);
  663. smalltalk.addMethod(
  664. "_testifNilIfNotNil",
  665. smalltalk.method({
  666. selector: "testifNilIfNotNil",
  667. fn: function (){
  668. var self=this;
  669. return smalltalk.withContext(function($ctx1) {
  670. _st(self)._should_return_("foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]",(3));
  671. _st(self)._should_return_("foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]",(2));
  672. _st(self)._should_return_("foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(3));
  673. _st(self)._should_return_("foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]",(2));
  674. return self}, function($ctx1) {$ctx1.fill(self,"testifNilIfNotNil",{},smalltalk.CodeGeneratorTest)})},
  675. messageSends: ["should:return:"]}),
  676. smalltalk.CodeGeneratorTest);
  677. smalltalk.addMethod(
  678. "_testifNotNil",
  679. smalltalk.method({
  680. selector: "testifNotNil",
  681. fn: function (){
  682. var self=this;
  683. return smalltalk.withContext(function($ctx1) {
  684. _st(self)._should_return_("foo ^ 1 ifNotNil: [ 2 ]",(2));
  685. _st(self)._should_return_("foo ^ nil ifNotNil: [ 2 ]",nil);
  686. _st(self)._should_return_("foo 1 ifNotNil: [ ^ 2 ]",(2));
  687. _st(self)._should_return_("foo nil ifNotNil: [ ^ 2 ]",self["@receiver"]);
  688. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNil",{},smalltalk.CodeGeneratorTest)})},
  689. messageSends: ["should:return:"]}),
  690. smalltalk.CodeGeneratorTest);
  691. smalltalk.addMethod(
  692. "_testifNotNilWithArgument",
  693. smalltalk.method({
  694. selector: "testifNotNilWithArgument",
  695. fn: function (){
  696. var self=this;
  697. return smalltalk.withContext(function($ctx1) {
  698. _st(self)._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ]",(3));
  699. _st(self)._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ]",nil);
  700. _st(self)._should_return_("foo ^ 1 ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(3));
  701. _st(self)._should_return_("foo ^ nil ifNil: [ 5 ] ifNotNil: [ :val | val + 2 ]",(5));
  702. _st(self)._should_return_("foo ^ 1 ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(3));
  703. _st(self)._should_return_("foo ^ nil ifNotNil: [ :val | val + 2 ] ifNil: [ 5 ]",(5));
  704. return self}, function($ctx1) {$ctx1.fill(self,"testifNotNilWithArgument",{},smalltalk.CodeGeneratorTest)})},
  705. messageSends: ["should:return:"]}),
  706. smalltalk.CodeGeneratorTest);
  707. smalltalk.addMethod(
  708. "_testifTrue",
  709. smalltalk.method({
  710. selector: "testifTrue",
  711. fn: function (){
  712. var self=this;
  713. return smalltalk.withContext(function($ctx1) {
  714. _st(self)._should_return_("foo false ifTrue: [ ^ 1 ]",self["@receiver"]);
  715. _st(self)._should_return_("foo true ifTrue: [ ^ 2 ]",(2));
  716. _st(self)._should_return_("foo ^ false ifTrue: [ 1 ]",nil);
  717. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ]",(2));
  718. return self}, function($ctx1) {$ctx1.fill(self,"testifTrue",{},smalltalk.CodeGeneratorTest)})},
  719. messageSends: ["should:return:"]}),
  720. smalltalk.CodeGeneratorTest);
  721. smalltalk.addMethod(
  722. "_testifTrueIfFalse",
  723. smalltalk.method({
  724. selector: "testifTrueIfFalse",
  725. fn: function (){
  726. var self=this;
  727. return smalltalk.withContext(function($ctx1) {
  728. _st(self)._should_return_("foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]",(2));
  729. _st(self)._should_return_("foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]",(1));
  730. _st(self)._should_return_("foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]",(1));
  731. _st(self)._should_return_("foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]",(2));
  732. return self}, function($ctx1) {$ctx1.fill(self,"testifTrueIfFalse",{},smalltalk.CodeGeneratorTest)})},
  733. messageSends: ["should:return:"]}),
  734. smalltalk.CodeGeneratorTest);
  735. smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
  736. smalltalk.addMethod(
  737. "_codeGeneratorClass",
  738. smalltalk.method({
  739. selector: "codeGeneratorClass",
  740. fn: function (){
  741. var self=this;
  742. function $InliningCodeGenerator(){return smalltalk.InliningCodeGenerator||(typeof InliningCodeGenerator=="undefined"?nil:InliningCodeGenerator)}
  743. return smalltalk.withContext(function($ctx1) {
  744. var $1;
  745. $1=$InliningCodeGenerator();
  746. return $1;
  747. }, function($ctx1) {$ctx1.fill(self,"codeGeneratorClass",{},smalltalk.InliningCodeGeneratorTest)})},
  748. messageSends: []}),
  749. smalltalk.InliningCodeGeneratorTest);
  750. smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
  751. smalltalk.addMethod(
  752. "_testClassRefVar",
  753. smalltalk.method({
  754. selector: "testClassRefVar",
  755. fn: function (){
  756. var self=this;
  757. var node;
  758. function $ClassReferenceNode(){return smalltalk.ClassReferenceNode||(typeof ClassReferenceNode=="undefined"?nil:ClassReferenceNode)}
  759. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  760. return smalltalk.withContext(function($ctx1) {
  761. var $1,$2;
  762. $1=_st($ClassReferenceNode())._new();
  763. _st($1)._value_("Object");
  764. $2=_st($1)._yourself();
  765. node=$2;
  766. _st(_st($SemanticAnalyzer())._new())._visit_(node);
  767. _st(self)._assert_(_st(_st(node)._binding())._isClassRefVar());
  768. return self}, function($ctx1) {$ctx1.fill(self,"testClassRefVar",{node:node},smalltalk.ScopeVarTest)})},
  769. messageSends: ["value:", "new", "yourself", "visit:", "assert:", "isClassRefVar", "binding"]}),
  770. smalltalk.ScopeVarTest);
  771. smalltalk.addMethod(
  772. "_testInstanceVar",
  773. smalltalk.method({
  774. selector: "testInstanceVar",
  775. fn: function (){
  776. var self=this;
  777. var node,scope;
  778. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  779. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  780. return smalltalk.withContext(function($ctx1) {
  781. var $1,$2;
  782. $1=_st($VariableNode())._new();
  783. _st($1)._value_("bzzz");
  784. $2=_st($1)._yourself();
  785. node=$2;
  786. scope=_st($MethodLexicalScope())._new();
  787. _st(scope)._addIVar_("bzzz");
  788. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isInstanceVar());
  789. return self}, function($ctx1) {$ctx1.fill(self,"testInstanceVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  790. messageSends: ["value:", "new", "yourself", "addIVar:", "assert:", "isInstanceVar", "bindingFor:"]}),
  791. smalltalk.ScopeVarTest);
  792. smalltalk.addMethod(
  793. "_testPseudoVar",
  794. smalltalk.method({
  795. selector: "testPseudoVar",
  796. fn: function (){
  797. var self=this;
  798. var node,pseudoVars;
  799. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  800. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  801. return smalltalk.withContext(function($ctx1) {
  802. var $1,$2;
  803. pseudoVars=["self", "super", "true", "false", "nil"];
  804. _st(pseudoVars)._do_((function(each){
  805. return smalltalk.withContext(function($ctx2) {
  806. $1=_st($VariableNode())._new();
  807. _st($1)._value_(each);
  808. $2=_st($1)._yourself();
  809. node=$2;
  810. node;
  811. return _st(self)._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isPseudoVar());
  812. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  813. return self}, function($ctx1) {$ctx1.fill(self,"testPseudoVar",{node:node,pseudoVars:pseudoVars},smalltalk.ScopeVarTest)})},
  814. messageSends: ["do:", "value:", "new", "yourself", "assert:", "isPseudoVar", "bindingFor:"]}),
  815. smalltalk.ScopeVarTest);
  816. smalltalk.addMethod(
  817. "_testTempVar",
  818. smalltalk.method({
  819. selector: "testTempVar",
  820. fn: function (){
  821. var self=this;
  822. var node,scope;
  823. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  824. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  825. return smalltalk.withContext(function($ctx1) {
  826. var $1,$2;
  827. $1=_st($VariableNode())._new();
  828. _st($1)._value_("bzzz");
  829. $2=_st($1)._yourself();
  830. node=$2;
  831. scope=_st($MethodLexicalScope())._new();
  832. _st(scope)._addTemp_("bzzz");
  833. _st(self)._assert_(_st(_st(scope)._bindingFor_(node))._isTempVar());
  834. return self}, function($ctx1) {$ctx1.fill(self,"testTempVar",{node:node,scope:scope},smalltalk.ScopeVarTest)})},
  835. messageSends: ["value:", "new", "yourself", "addTemp:", "assert:", "isTempVar", "bindingFor:"]}),
  836. smalltalk.ScopeVarTest);
  837. smalltalk.addMethod(
  838. "_testUnknownVar",
  839. smalltalk.method({
  840. selector: "testUnknownVar",
  841. fn: function (){
  842. var self=this;
  843. var node;
  844. function $VariableNode(){return smalltalk.VariableNode||(typeof VariableNode=="undefined"?nil:VariableNode)}
  845. function $MethodLexicalScope(){return smalltalk.MethodLexicalScope||(typeof MethodLexicalScope=="undefined"?nil:MethodLexicalScope)}
  846. return smalltalk.withContext(function($ctx1) {
  847. var $1,$2;
  848. $1=_st($VariableNode())._new();
  849. _st($1)._value_("bzzz");
  850. $2=_st($1)._yourself();
  851. node=$2;
  852. _st(self)._assert_(_st(_st(_st($MethodLexicalScope())._new())._bindingFor_(node))._isNil());
  853. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVar",{node:node},smalltalk.ScopeVarTest)})},
  854. messageSends: ["value:", "new", "yourself", "assert:", "isNil", "bindingFor:"]}),
  855. smalltalk.ScopeVarTest);
  856. smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
  857. smalltalk.addMethod(
  858. "_setUp",
  859. smalltalk.method({
  860. selector: "setUp",
  861. fn: function (){
  862. var self=this;
  863. function $Object(){return smalltalk.Object||(typeof Object=="undefined"?nil:Object)}
  864. function $SemanticAnalyzer(){return smalltalk.SemanticAnalyzer||(typeof SemanticAnalyzer=="undefined"?nil:SemanticAnalyzer)}
  865. return smalltalk.withContext(function($ctx1) {
  866. self["@analyzer"]=_st($SemanticAnalyzer())._on_($Object());
  867. return self}, function($ctx1) {$ctx1.fill(self,"setUp",{},smalltalk.SemanticAnalyzerTest)})},
  868. messageSends: ["on:"]}),
  869. smalltalk.SemanticAnalyzerTest);
  870. smalltalk.addMethod(
  871. "_testAssignment",
  872. smalltalk.method({
  873. selector: "testAssignment",
  874. fn: function (){
  875. var self=this;
  876. var src,ast;
  877. function $InvalidAssignmentError(){return smalltalk.InvalidAssignmentError||(typeof InvalidAssignmentError=="undefined"?nil:InvalidAssignmentError)}
  878. return smalltalk.withContext(function($ctx1) {
  879. src="foo self := 1";
  880. ast=_st(smalltalk)._parse_(src);
  881. _st(self)._should_raise_((function(){
  882. return smalltalk.withContext(function($ctx2) {
  883. return _st(self["@analyzer"])._visit_(ast);
  884. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$InvalidAssignmentError());
  885. return self}, function($ctx1) {$ctx1.fill(self,"testAssignment",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  886. messageSends: ["parse:", "should:raise:", "visit:"]}),
  887. smalltalk.SemanticAnalyzerTest);
  888. smalltalk.addMethod(
  889. "_testNonLocalReturn",
  890. smalltalk.method({
  891. selector: "testNonLocalReturn",
  892. fn: function (){
  893. var self=this;
  894. var src,ast;
  895. return smalltalk.withContext(function($ctx1) {
  896. src="foo | a | a + 1. ^ a";
  897. ast=_st(smalltalk)._parse_(src);
  898. _st(self["@analyzer"])._visit_(ast);
  899. _st(self)._deny_(_st(_st(ast)._scope())._hasNonLocalReturn());
  900. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  901. messageSends: ["parse:", "visit:", "deny:", "hasNonLocalReturn", "scope"]}),
  902. smalltalk.SemanticAnalyzerTest);
  903. smalltalk.addMethod(
  904. "_testNonLocalReturn2",
  905. smalltalk.method({
  906. selector: "testNonLocalReturn2",
  907. fn: function (){
  908. var self=this;
  909. var src,ast;
  910. return smalltalk.withContext(function($ctx1) {
  911. src="foo | a | a + 1. [ [ ^ a] ]";
  912. ast=_st(smalltalk)._parse_(src);
  913. _st(self["@analyzer"])._visit_(ast);
  914. _st(self)._assert_(_st(_st(ast)._scope())._hasNonLocalReturn());
  915. return self}, function($ctx1) {$ctx1.fill(self,"testNonLocalReturn2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  916. messageSends: ["parse:", "visit:", "assert:", "hasNonLocalReturn", "scope"]}),
  917. smalltalk.SemanticAnalyzerTest);
  918. smalltalk.addMethod(
  919. "_testScope",
  920. smalltalk.method({
  921. selector: "testScope",
  922. fn: function (){
  923. var self=this;
  924. var src,ast;
  925. return smalltalk.withContext(function($ctx1) {
  926. src="foo | a | a + 1. [ | b | b := a ]";
  927. ast=_st(smalltalk)._parse_(src);
  928. _st(self["@analyzer"])._visit_(ast);
  929. _st(self)._deny_(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._last())._scope()).__eq_eq(_st(ast)._scope()));
  930. return self}, function($ctx1) {$ctx1.fill(self,"testScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  931. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "last", "nodes", "first"]}),
  932. smalltalk.SemanticAnalyzerTest);
  933. smalltalk.addMethod(
  934. "_testScope2",
  935. smalltalk.method({
  936. selector: "testScope2",
  937. fn: function (){
  938. var self=this;
  939. var src,ast;
  940. return smalltalk.withContext(function($ctx1) {
  941. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  942. ast=_st(smalltalk)._parse_(src);
  943. _st(self["@analyzer"])._visit_(ast);
  944. _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()));
  945. return self}, function($ctx1) {$ctx1.fill(self,"testScope2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  946. messageSends: ["parse:", "visit:", "deny:", "==", "scope", "first", "nodes", "last"]}),
  947. smalltalk.SemanticAnalyzerTest);
  948. smalltalk.addMethod(
  949. "_testScopeLevel",
  950. smalltalk.method({
  951. selector: "testScopeLevel",
  952. fn: function (){
  953. var self=this;
  954. var src,ast;
  955. return smalltalk.withContext(function($ctx1) {
  956. src="foo | a | a + 1. [ [ | b | b := a ] ]";
  957. ast=_st(smalltalk)._parse_(src);
  958. _st(self["@analyzer"])._visit_(ast);
  959. _st(self)._assert_equals_(_st(_st(ast)._scope())._scopeLevel(),(1));
  960. _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));
  961. return self}, function($ctx1) {$ctx1.fill(self,"testScopeLevel",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  962. messageSends: ["parse:", "visit:", "assert:equals:", "scopeLevel", "scope", "first", "nodes", "last"]}),
  963. smalltalk.SemanticAnalyzerTest);
  964. smalltalk.addMethod(
  965. "_testUnknownVariables",
  966. smalltalk.method({
  967. selector: "testUnknownVariables",
  968. fn: function (){
  969. var self=this;
  970. var src,ast;
  971. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  972. return smalltalk.withContext(function($ctx1) {
  973. src="foo | a | b + a";
  974. ast=_st(smalltalk)._parse_(src);
  975. _st(self)._should_raise_((function(){
  976. return smalltalk.withContext(function($ctx2) {
  977. return _st(self["@analyzer"])._visit_(ast);
  978. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  979. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariables",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  980. messageSends: ["parse:", "should:raise:", "visit:"]}),
  981. smalltalk.SemanticAnalyzerTest);
  982. smalltalk.addMethod(
  983. "_testUnknownVariablesWithScope",
  984. smalltalk.method({
  985. selector: "testUnknownVariablesWithScope",
  986. fn: function (){
  987. var self=this;
  988. var src,ast;
  989. function $UnknownVariableError(){return smalltalk.UnknownVariableError||(typeof UnknownVariableError=="undefined"?nil:UnknownVariableError)}
  990. return smalltalk.withContext(function($ctx1) {
  991. src="foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
  992. ast=_st(smalltalk)._parse_(src);
  993. _st(self)._should_raise_((function(){
  994. return smalltalk.withContext(function($ctx2) {
  995. return _st(self["@analyzer"])._visit_(ast);
  996. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$UnknownVariableError());
  997. return self}, function($ctx1) {$ctx1.fill(self,"testUnknownVariablesWithScope",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  998. messageSends: ["parse:", "should:raise:", "visit:"]}),
  999. smalltalk.SemanticAnalyzerTest);
  1000. smalltalk.addMethod(
  1001. "_testVariableShadowing",
  1002. smalltalk.method({
  1003. selector: "testVariableShadowing",
  1004. fn: function (){
  1005. var self=this;
  1006. var src,ast;
  1007. return smalltalk.withContext(function($ctx1) {
  1008. src="foo | a | a + 1";
  1009. ast=_st(smalltalk)._parse_(src);
  1010. _st(self["@analyzer"])._visit_(ast);
  1011. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1012. messageSends: ["parse:", "visit:"]}),
  1013. smalltalk.SemanticAnalyzerTest);
  1014. smalltalk.addMethod(
  1015. "_testVariableShadowing2",
  1016. smalltalk.method({
  1017. selector: "testVariableShadowing2",
  1018. fn: function (){
  1019. var self=this;
  1020. var src,ast;
  1021. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1022. return smalltalk.withContext(function($ctx1) {
  1023. src="foo | a | a + 1. [ | a | a := 2 ]";
  1024. ast=_st(smalltalk)._parse_(src);
  1025. _st(self)._should_raise_((function(){
  1026. return smalltalk.withContext(function($ctx2) {
  1027. return _st(self["@analyzer"])._visit_(ast);
  1028. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  1029. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing2",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1030. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1031. smalltalk.SemanticAnalyzerTest);
  1032. smalltalk.addMethod(
  1033. "_testVariableShadowing3",
  1034. smalltalk.method({
  1035. selector: "testVariableShadowing3",
  1036. fn: function (){
  1037. var self=this;
  1038. var src,ast;
  1039. return smalltalk.withContext(function($ctx1) {
  1040. src="foo | a | a + 1. [ | b | b := 2 ]";
  1041. ast=_st(smalltalk)._parse_(src);
  1042. _st(self["@analyzer"])._visit_(ast);
  1043. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing3",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1044. messageSends: ["parse:", "visit:"]}),
  1045. smalltalk.SemanticAnalyzerTest);
  1046. smalltalk.addMethod(
  1047. "_testVariableShadowing4",
  1048. smalltalk.method({
  1049. selector: "testVariableShadowing4",
  1050. fn: function (){
  1051. var self=this;
  1052. var src,ast;
  1053. return smalltalk.withContext(function($ctx1) {
  1054. src="foo | a | a + 1. [ [ [ | b | b := 2 ] ] ]";
  1055. ast=_st(smalltalk)._parse_(src);
  1056. _st(self["@analyzer"])._visit_(ast);
  1057. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing4",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1058. messageSends: ["parse:", "visit:"]}),
  1059. smalltalk.SemanticAnalyzerTest);
  1060. smalltalk.addMethod(
  1061. "_testVariableShadowing5",
  1062. smalltalk.method({
  1063. selector: "testVariableShadowing5",
  1064. fn: function (){
  1065. var self=this;
  1066. var src,ast;
  1067. function $ShadowingVariableError(){return smalltalk.ShadowingVariableError||(typeof ShadowingVariableError=="undefined"?nil:ShadowingVariableError)}
  1068. return smalltalk.withContext(function($ctx1) {
  1069. src="foo | a | a + 1. [ [ [ | a | a := 2 ] ] ]";
  1070. ast=_st(smalltalk)._parse_(src);
  1071. _st(self)._should_raise_((function(){
  1072. return smalltalk.withContext(function($ctx2) {
  1073. return _st(self["@analyzer"])._visit_(ast);
  1074. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),$ShadowingVariableError());
  1075. return self}, function($ctx1) {$ctx1.fill(self,"testVariableShadowing5",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1076. messageSends: ["parse:", "should:raise:", "visit:"]}),
  1077. smalltalk.SemanticAnalyzerTest);
  1078. smalltalk.addMethod(
  1079. "_testVariablesLookup",
  1080. smalltalk.method({
  1081. selector: "testVariablesLookup",
  1082. fn: function (){
  1083. var self=this;
  1084. var src,ast;
  1085. return smalltalk.withContext(function($ctx1) {
  1086. src="foo | a | a + 1. [ | b | b := a ]";
  1087. ast=_st(smalltalk)._parse_(src);
  1088. _st(self["@analyzer"])._visit_(ast);
  1089. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._isTempVar());
  1090. _st(self)._assert_(_st(_st(_st(_st(_st(_st(_st(_st(ast)._nodes())._first())._nodes())._first())._receiver())._binding())._scope()).__eq_eq(_st(ast)._scope()));
  1091. _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());
  1092. _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()));
  1093. return self}, function($ctx1) {$ctx1.fill(self,"testVariablesLookup",{src:src,ast:ast},smalltalk.SemanticAnalyzerTest)})},
  1094. messageSends: ["parse:", "visit:", "assert:", "isTempVar", "binding", "receiver", "first", "nodes", "==", "scope", "left", "last"]}),
  1095. smalltalk.SemanticAnalyzerTest);