Compiler-Tests.deploy.js 47 KB

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