resin 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/amber/css/amber-normalize.css +73 -73
  2. data/amber/css/amber-normalize.less +1 -1
  3. data/amber/css/amber.css +106 -106
  4. data/amber/css/helios.css +242 -0
  5. data/amber/images/hsplitter.png +0 -0
  6. data/amber/images/vsplitter.png +0 -0
  7. data/amber/js/Benchfib.deploy.js +116 -38
  8. data/amber/js/Benchfib.js +120 -42
  9. data/amber/js/Canvas.deploy.js +674 -403
  10. data/amber/js/Canvas.js +682 -411
  11. data/amber/js/Compiler-AST.deploy.js +1150 -0
  12. data/amber/js/Compiler-AST.js +1591 -0
  13. data/amber/js/Compiler-Core.deploy.js +1562 -0
  14. data/amber/js/Compiler-Core.js +1972 -0
  15. data/amber/js/Compiler-Exceptions.deploy.js +114 -0
  16. data/amber/js/Compiler-Exceptions.js +161 -0
  17. data/amber/js/Compiler-IR.deploy.js +2326 -0
  18. data/amber/js/Compiler-IR.js +3146 -0
  19. data/amber/js/Compiler-Inlining.deploy.js +1147 -0
  20. data/amber/js/Compiler-Inlining.js +1514 -0
  21. data/amber/js/Compiler-Semantic.deploy.js +1207 -0
  22. data/amber/js/Compiler-Semantic.js +1628 -0
  23. data/amber/js/Compiler-Tests.deploy.js +646 -60
  24. data/amber/js/Compiler-Tests.js +843 -82
  25. data/amber/js/Compiler.deploy.js +1097 -159
  26. data/amber/js/Compiler.js +1414 -161
  27. data/amber/js/Examples.deploy.js +31 -15
  28. data/amber/js/Examples.js +33 -17
  29. data/amber/js/Helios-Announcements.deploy.js +127 -0
  30. data/amber/js/Helios-Announcements.js +157 -0
  31. data/amber/js/Helios-Browser.deploy.js +1473 -0
  32. data/amber/js/Helios-Browser.js +1953 -0
  33. data/amber/js/Helios-Commands.deploy.js +403 -0
  34. data/amber/js/Helios-Commands.js +563 -0
  35. data/amber/js/Helios-Core.deploy.js +1070 -0
  36. data/amber/js/Helios-Core.js +1445 -0
  37. data/amber/js/Helios-Environments.deploy.js +132 -0
  38. data/amber/js/Helios-Environments.js +179 -0
  39. data/amber/js/Helios-Inspector.deploy.js +855 -0
  40. data/amber/js/Helios-Inspector.js +1155 -0
  41. data/amber/js/Helios-KeyBindings.deploy.js +753 -0
  42. data/amber/js/Helios-KeyBindings.js +1023 -0
  43. data/amber/js/Helios-Layout.deploy.js +383 -0
  44. data/amber/js/Helios-Layout.js +523 -0
  45. data/amber/js/Helios-Workspace.deploy.js +799 -0
  46. data/amber/js/Helios-Workspace.js +1074 -0
  47. data/amber/js/IDE.deploy.js +2541 -1490
  48. data/amber/js/IDE.js +2721 -1660
  49. data/amber/js/Importer-Exporter.deploy.js +671 -0
  50. data/amber/js/Importer-Exporter.js +816 -0
  51. data/amber/js/Kernel-Announcements.deploy.js +137 -20
  52. data/amber/js/Kernel-Announcements.js +176 -22
  53. data/amber/js/Kernel-Classes.deploy.js +555 -168
  54. data/amber/js/Kernel-Classes.js +662 -205
  55. data/amber/js/Kernel-Collections.deploy.js +1403 -618
  56. data/amber/js/Kernel-Collections.js +1545 -690
  57. data/amber/js/Kernel-Exceptions.deploy.js +109 -45
  58. data/amber/js/Kernel-Exceptions.js +123 -49
  59. data/amber/js/Kernel-Methods.deploy.js +196 -81
  60. data/amber/js/Kernel-Methods.js +214 -89
  61. data/amber/js/Kernel-Objects.deploy.js +1542 -1117
  62. data/amber/js/Kernel-Objects.js +1593 -1148
  63. data/amber/js/Kernel-Tests.deploy.js +1725 -772
  64. data/amber/js/Kernel-Tests.js +2301 -1123
  65. data/amber/js/Kernel-Transcript.deploy.js +23 -25
  66. data/amber/js/Kernel-Transcript.js +24 -26
  67. data/amber/js/SUnit.deploy.js +204 -131
  68. data/amber/js/SUnit.js +222 -139
  69. data/amber/js/Spaces.deploy.js +240 -0
  70. data/amber/js/Spaces.js +326 -0
  71. data/amber/js/amber.js +26 -7
  72. data/amber/js/boot.js +65 -47
  73. data/amber/js/init.js +1 -1
  74. data/amber/js/lib/CodeMirror/amber.css +21 -21
  75. data/amber/js/lib/CodeMirror/codemirror.css +119 -13
  76. data/amber/js/lib/CodeMirror/codemirror.js +2219 -1220
  77. data/amber/js/lib/CodeMirror/smalltalk.js +134 -129
  78. data/amber/js/lib/bootstrap/css/bootstrap.css +5837 -0
  79. data/amber/js/lib/bootstrap/css/bootstrap.min.css +841 -0
  80. data/amber/js/lib/bootstrap/img/glyphicons-halflings-white.png +0 -0
  81. data/amber/js/lib/bootstrap/img/glyphicons-halflings.png +0 -0
  82. data/amber/js/lib/bootstrap/js/bootstrap.js +2038 -0
  83. data/amber/js/lib/bootstrap/js/bootstrap.min.js +7 -0
  84. data/amber/js/lib/jQuery/jquery-1.8.2.min.js +2 -0
  85. data/amber/js/lib/jQuery/jquery-ui-1.8.24.custom.min.js +125 -0
  86. data/amber/st/Compiler-AST.st +505 -0
  87. data/amber/st/Compiler-Core.st +835 -0
  88. data/amber/st/Compiler-Exceptions.st +87 -0
  89. data/amber/st/Compiler-IR.st +1097 -0
  90. data/amber/st/Compiler-Inlining.st +650 -0
  91. data/amber/st/Compiler-Semantic.st +558 -0
  92. data/amber/st/Compiler-Tests.st +285 -381
  93. data/amber/st/Compiler.st +725 -2
  94. data/amber/st/Helios-Announcements.st +104 -0
  95. data/amber/st/Helios-Browser.st +708 -0
  96. data/amber/st/Helios-Commands.st +223 -0
  97. data/amber/st/Helios-Core.st +532 -0
  98. data/amber/st/Helios-Environments.st +98 -0
  99. data/amber/st/Helios-Inspector.st +367 -0
  100. data/amber/st/Helios-KeyBindings.st +337 -0
  101. data/amber/st/Helios-Layout.st +199 -0
  102. data/amber/st/Helios-Workspace.st +367 -0
  103. data/amber/st/IDE.st +75 -53
  104. data/amber/st/Importer-Exporter.st +386 -0
  105. data/amber/st/Kernel-Announcements.st +92 -0
  106. data/amber/st/Kernel-Classes.st +137 -15
  107. data/amber/st/Kernel-Collections.st +137 -47
  108. data/amber/st/Kernel-Exceptions.st +14 -0
  109. data/amber/st/Kernel-Methods.st +9 -1
  110. data/amber/st/Kernel-Objects.st +29 -5
  111. data/amber/st/Kernel-Tests.st +545 -199
  112. data/amber/st/SUnit.st +10 -0
  113. data/amber/st/Spaces.st +142 -0
  114. data/lib/resin/app.rb +1 -1
  115. metadata +86 -31
  116. data/amber/js/lib/jQuery/jquery-1.4.4.min.js +0 -167
  117. data/amber/js/lib/jQuery/jquery-1.6.4.min.js +0 -4
@@ -1,97 +1,683 @@
1
1
  smalltalk.addPackage('Compiler-Tests', {});
2
- smalltalk.addClass('ImporterTest', smalltalk.TestCase, [], 'Compiler-Tests');
2
+ smalltalk.addClass('CodeGeneratorTest', smalltalk.TestCase, ['receiver'], 'Compiler-Tests');
3
3
  smalltalk.addMethod(
4
- "_bigChunkString",
4
+ "_codeGeneratorClass",
5
5
  smalltalk.method({
6
- selector: "bigChunkString",
7
- fn: function (){
8
- var self=this;
9
- return "Smalltalk current createPackage: 'Cypress-Definitions' properties: #{}!\x0aObject subclass: #CypressSnapshot\x0a\x09instanceVariableNames: 'definitions'\x0a\x09package: 'Cypress-Definitions'!\x0a\x0a!CypressSnapshot methodsFor: 'not yet classified'!\x0a\x0adefinitions: aDefinitions\x0a\x0a\x09definitions := aDefinitions\x0a!\x0a\x0adefinitions\x0a\x0a\x09^definitions\x0a! !\x0a\x0a!CypressSnapshot class methodsFor: 'not yet classified'!\x0a\x0adefinitions: aDefinitions\x0a\x0a\x09^(self new) definitions: aDefinitions\x0a! !\x0a\x0aObject subclass: #CypressPackage\x0a\x09instanceVariableNames: 'name'\x0a\x09package: 'Cypress-Definitions'!\x0a\x0a!CypressPackage methodsFor: 'not yet classified'!\x0a\x0a= other\x0a\x09^ other species = self species and: [other name sameAs: name]\x0a!\x0a\x0aname\x0a\x09^ name\x0a!\x0a\x0aname: aString\x0a\x09name := aString\x0a!\x0a\x0asnapshot\x0a\x09| package definitions name |\x0a\x09package := Package named: self name.\x0a\x09definitions := OrderedCollection new.\x0a\x09package sortedClasses do: [:cls |\x0a \x09definitions add: cls asCypressClassDefinition.\x0a cls methodDictionary values do: [:method |\x0a\x09\x09\x09(method category match: '^\x5c*') ifFalse: [ \x0a\x09\x09\x09\x09definitions add: method asCypressMethodDefinition ]].\x0a cls class methodDictionary values do: [:method |\x0a\x09\x09\x09(method category match: '^\x5c*') ifFalse: [ \x0a\x09\x09\x09\x09definitions add: method asCypressMethodDefinition ]]].\x0a\x09name := package name.\x0a\x09Smalltalk current classes, (Smalltalk current classes collect: [:each | each class]) do: [:each |\x0a\x09\x09each methodDictionary values do: [:method |\x0a\x09\x09\x09method category = ('*', name) ifTrue: [\x0a\x09\x09\x09\x09definitions add: method asCypressMethodDefinition ]]].\x0a\x09^ CypressSnapshot definitions: definitions\x0a!\x0a\x0aprintString\x0a\x09^super printString, '(', name, ')'\x0a! !\x0a\x0aObject subclass: #CypressDefinition\x0a\x09instanceVariableNames: ''\x0a\x09package: 'Cypress-Definitions'!\x0a\x0a!CypressDefinition methodsFor: 'not yet classified'!\x0a\x0a= aDefinition\x0a\x09^(aDefinition isKindOf: CypressDefinition) and: [self isRevisionOf: aDefinition]\x0a!\x0a\x0aisRevisionOf: aDefinition\x0a\x09^ (aDefinition isKindOf: CypressDefinition) and: [aDefinition description = self description]\x0a!\x0a\x0adescription\x0a\x09self subclassResponsibility\x0a!\x0a\x0aisSameRevisionAs: aDefinition\x0a\x09^ self = aDefinition\x0a! !\x0a\x0aObject subclass: #CypressPatch\x0a\x09instanceVariableNames: 'operations'\x0a\x09package: 'Cypress-Definitions'!\x0a\x0a!CypressPatch methodsFor: 'not yet classified'!\x0a\x0afromBase: baseSnapshot toTarget: targetSnapshot\x0a\x09| base target |\x09\x0a\x09operations := OrderedCollection new.\x0a\x09base := CypressDefinitionIndex definitions: baseSnapshot definitions.\x0a\x09target := CypressDefinitionIndex definitions: targetSnapshot definitions.\x0a\x09\x0a\x09target definitions do:\x0a\x09\x09[:t |\x0a\x09\x09base\x0a\x09\x09\x09definitionLike: t\x0a\x09\x09\x09ifPresent: [:b | (b isSameRevisionAs: t) ifFalse: [operations add: (CypressModification of: b to: t)]]\x0a\x09\x09\x09ifAbsent: [operations add: (CypressAddition of: t)]].\x0a\x09\x09\x0a\x09base definitions do:\x0a\x09\x09[:b |\x0a\x09\x09target\x0a\x09\x09\x09definitionLike: b\x0a\x09\x09\x09ifPresent: [:t | ]\x0a\x09\x09\x09ifAbsent: [operations add: (CypressRemoval of: b)]]\x0a!\x0a\x0aoperations\x0a\x0a\x09^operations\x0a! !\x0a\x0a!CypressPatch class methodsFor: 'not yet classified'!\x0a\x0afromBase: baseSnapshot toTarget: targetSnapshot\x0a\x09^ (self new)\x0a\x09\x09fromBase: baseSnapshot\x0a\x09\x09toTarget: targetSnapshot\x0a! !\x0a\x0aObject subclass: #CypressDefinitionIndex\x0a\x09instanceVariableNames: 'definitionMap'\x0a\x09package: 'Cypress-Definitions'!\x0a\x0a!CypressDefinitionIndex methodsFor: 'not yet classified'!\x0a\x0aadd: aDefinition\x0a\x09^ self definitionMap at: aDefinition description put: aDefinition\x0a!\x0a\x0aaddAll: aCollection\x0a\x09aCollection do: [:ea | self add: ea]\x0a!\x0a\x0adefinitionLike: aDefinition ifPresent: foundBlock ifAbsent: errorBlock\x0a\x09| definition |\x0a\x09definition := self definitionMap at: aDefinition description ifAbsent: [].\x0a\x09^ definition\x0a\x09\x09ifNil: errorBlock\x0a\x09\x09ifNotNil: [foundBlock value: definition]\x0a!\x0a\x0adefinitions\x0a\x09^self definitionMap values\x0a!\x0a\x0adefinitionMap\x0a\x09definitionMap ifNil: [ definitionMap := Dictionary new ].\x0a\x09^ definitionMap\x0a!\x0a\x0aremove: aDefinition\x0a\x09self definitionMap removeKey: aDefinition description ifAbsent: []\x0a! !\x0a\x0a!CypressDefinitionIndex class methodsFor: 'not yet classified'!\x0a\x0adefinitions: aCollection\x0a\x09^ self new addAll: aCollection\x0a! !\x0a\x0aObject subclass: #CypressPatchOperation\x0a\x09instanceVariableNames: ''\x0a\x09package: 'Cypress-Definitions'!\x0a\x0aCypressDefinition subclass: #CypressClassDefinition\x0a\x09instanceVariableNames: 'name superclassName category comment instVarNames classInstVarNames'\x0a\x09package: 'Cypress-Definitions'!\x0a\x0a!CypressClassDefinition methodsFor: 'not yet classified'!\x0a\x0aname: aClassName superclassName: aSuperclassName category: aCategory instVarNames: anInstanceVariableNames classInstVarNames: aClassInstanceVariableNames comment: aComment\x0a\x0a\x09name := aClassName.\x0a\x09superclassName := aSuperclassName.\x0a\x09category := aCategory.\x0a\x09instVarNames := anInstanceVariableNames.\x0a\x09classInstVarNames := aClassInstanceVariableNames.\x0a\x09comment := aComment\x0a!\x0a\x0a= aDefinition\x0a\x09^(super = aDefinition)\x0a\x09\x09and: [superclassName = aDefinition superclassName\x0a\x09\x09and: [category = aDefinition category\x0a\x09\x09and: [instVarNames = aDefinition instVarNames\x0a\x09\x09and: [classInstVarNames = aDefinition classInstVarNames\x0a\x09\x09and: [comment = aDefinition comment]]]]]\x0a!\x0a\x0asuperclassName\x0a\x0a\x09^superclassName\x0a!\x0a\x0aname\x0a\x0a\x09^name\x0a!\x0a\x0acategory\x0a\x0a\x09^category\x0a!\x0a\x0acomment\x0a\x0a\x09^comment\x0a!\x0a\x0adescription\x0a\x0a\x09^ Array with: name\x0a!\x0a\x0ainstVarNames\x0a\x0a\x09^instVarNames\x0a!\x0a\x0aclassInstVarNames\x0a\x0a\x09^classInstVarNames\x0a! !\x0a\x0a!CypressClassDefinition class methodsFor: 'not yet classified'!\x0a\x0aname: aClassName \x0asuperclassName: aSuperclassName\x0acategory: aCategory\x0ainstVarNames: anInstanceVariableNames\x0aclassInstVarNames: aClassInstanceVariableNames\x0acomment: aComment\x0a\x0a\x09^(self new) \x0a\x09\x09name: aClassName \x0a\x09\x09superclassName: aSuperclassName\x0a\x09\x09category: aCategory\x0a\x09\x09instVarNames: anInstanceVariableNames\x0a\x09\x09classInstVarNames: aClassInstanceVariableNames\x0a\x09\x09comment: aComment\x0a! !\x0a\x0aCypressDefinition subclass: #CypressMethodDefinition\x0a\x09instanceVariableNames: 'classIsMeta source category selector className'\x0a\x09package: 'Cypress-Definitions'!\x0a\x0a!CypressMethodDefinition methodsFor: 'not yet classified'!\x0a\x0aclassName: aName classIsMeta: isMetaclass selector: aSelector category: aCategory source: aSource\x0a\x0a\x09className := aName.\x0a\x09classIsMeta := isMetaclass.\x0a\x09selector := aSelector.\x0a\x09category := aCategory.\x0a\x09source := aSource.\x0a!\x0a\x0a= aDefinition\x0a ^ super = aDefinition\x0a and: [ aDefinition source = self source\x0a and: [ aDefinition category = self category ] ]\x0a!\x0a\x0asource\x0a\x0a\x09^source\x0a!\x0a\x0acategory\x0a\x0a\x09^category\x0a!\x0a\x0adescription\x0a\x09^ Array\x09\x0a\x09\x09with: className\x0a\x09\x09with: selector\x0a\x09\x09with: classIsMeta\x0a! !\x0a\x0a!CypressMethodDefinition class methodsFor: 'not yet classified'!\x0a\x0aclassName: aName\x0aclassIsMeta: isMetaclass\x0aselector: aSelector\x0acategory: aCategory\x0asource: aSource\x0a\x0a\x09^(self new)\x0a\x09\x09className: aName\x0a\x09\x09classIsMeta: isMetaclass\x0a\x09\x09selector: aSelector\x0a\x09\x09category: aCategory\x0a\x09\x09source: aSource\x0a! !\x0a\x0aCypressPatchOperation subclass: #CypressAddition\x0a\x09instanceVariableNames: 'definition'\x0a\x09package: 'Cypress-Definitions'!\x0a\x0a!CypressAddition methodsFor: 'not yet classified'!\x0a\x0adefinition: aDefinition\x0a\x0a\x09definition := aDefinition\x0a! !\x0a\x0a!CypressAddition class methodsFor: 'not yet classified'!\x0a\x0aof: aDefinition\x0a\x09^ self new definition: aDefinition\x0a! !\x0a\x0aCypressPatchOperation subclass: #CypressModification\x0a\x09instanceVariableNames: 'obsoletion modification'\x0a\x09package: 'Cypress-Definitions'!\x0a\x0a!CypressModification methodsFor: 'not yet classified'!\x0a\x0abase: base target: target\x0a\x0a\x09obsoletion := base.\x0a\x09modification := target.\x0a! !\x0a\x0a!CypressModification class methodsFor: 'not yet classified'!\x0a\x0aof: base to: target\x0a\x09^ self new base: base target: target\x0a! !\x0a\x0aCypressPatchOperation subclass: #CypressRemoval\x0a\x09instanceVariableNames: 'definition'\x0a\x09package: 'Cypress-Definitions'!\x0a\x0a!CypressRemoval methodsFor: 'not yet classified'!\x0a\x0adefinition: aDefinition\x0a\x0a\x09definition := aDefinition\x0a! !\x0a\x0a!CypressRemoval class methodsFor: 'not yet classified'!\x0a\x0aof: aDefinition\x0a\x09^ self new definition: aDefinition\x0a! !\x0a\x0a!Object methodsFor: '*Cypress-Definitions'!\x0a\x0aspecies\x0a\x0a\x09^self class\x0a! !\x0a\x0a!Class methodsFor: '*Cypress-Definitions'!\x0a\x0aasCypressClassDefinition\x0a\x09^CypressClassDefinition\x0a\x09\x09name: self name\x0a\x09\x09superclassName: self superclass name\x0a\x09\x09category: self category \x0a\x09\x09instVarNames: self instanceVariableNames\x0a\x09\x09classInstVarNames: self class instanceVariableNames\x0a\x09\x09comment: self comment\x0a! !\x0a\x0a!CompiledMethod methodsFor: '*Cypress-Definitions'!\x0a\x0aasCypressMethodDefinition\x0a\x0a\x09^CypressMethodDefinition \x0a \x09className: self methodClass name\x0a\x09\x09classIsMeta: self methodClass isMetaclass\x0a\x09\x09selector: self selector\x0a\x09\x09category: self category\x0a\x09\x09source: self source\x0a! !\x0a\x0a!CharacterArray methodsFor: '*Cypress-Definitions'!\x0a\x0asameAs: aString\x0a\x0a\x09^self asUppercase = aString asUppercase\x0a! !\x0a\x0a";
10
- return self;}
6
+ selector: "codeGeneratorClass",
7
+ fn: function () {
8
+ var self = this;
9
+ return smalltalk.CodeGenerator || CodeGenerator;
10
+ }
11
11
  }),
12
- smalltalk.ImporterTest);
12
+ smalltalk.CodeGeneratorTest);
13
13
 
14
14
  smalltalk.addMethod(
15
- "_chunkString",
15
+ "_compiler",
16
16
  smalltalk.method({
17
- selector: "chunkString",
18
- fn: function (){
19
- var self=this;
20
- return "!Object methodsFor: 'importer test method'!\x0a\x0aimporterTestMethod\x0a\x0a\x09^'success'\x0a! !\x0a";
21
- return self;}
17
+ selector: "compiler",
18
+ fn: function () {
19
+ var self = this;
20
+ var $2, $3, $1;
21
+ $2 = smalltalk.send(smalltalk.Compiler || Compiler, "_new", []);
22
+ smalltalk.send($2, "_codeGeneratorClass_", [smalltalk.send(self, "_codeGeneratorClass", [])]);
23
+ $3 = smalltalk.send($2, "_yourself", []);
24
+ $1 = $3;
25
+ return $1;
26
+ }
22
27
  }),
23
- smalltalk.ImporterTest);
28
+ smalltalk.CodeGeneratorTest);
24
29
 
25
30
  smalltalk.addMethod(
26
- "_cleanUp",
31
+ "_setUp",
27
32
  smalltalk.method({
28
- selector: "cleanUp",
29
- fn: function (){
30
- var self=this;
31
- ((($receiver = smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_methodDictionary", []), "_includesKey_", [smalltalk.symbolFor("importerTestMethod")])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send((smalltalk.Object || Object), "_removeCompiledMethod_", [smalltalk.send((smalltalk.Object || Object), "_methodAt_", [smalltalk.symbolFor("importerTestMethod")])]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send((smalltalk.Object || Object), "_removeCompiledMethod_", [smalltalk.send((smalltalk.Object || Object), "_methodAt_", [smalltalk.symbolFor("importerTestMethod")])]);})]));
32
- return self;}
33
+ selector: "setUp",
34
+ fn: function () {
35
+ var self = this;
36
+ self['@receiver'] = smalltalk.send(smalltalk.send(self, "_targetClass", []), "_new", []);
37
+ return self;
38
+ }
33
39
  }),
34
- smalltalk.ImporterTest);
40
+ smalltalk.CodeGeneratorTest);
35
41
 
36
42
  smalltalk.addMethod(
37
- "_setUp",
43
+ "_should_return_",
38
44
  smalltalk.method({
39
- selector: "setUp",
40
- fn: function (){
41
- var self=this;
42
- smalltalk.send(self, "_setUp", [], smalltalk.ImporterTest.superclass || nil);
43
- smalltalk.send(self, "_cleanUp", []);
44
- return self;}
45
+ selector: "should:return:",
46
+ fn: function (aString, anObject) {
47
+ var self = this;
48
+ var method;
49
+ var result;
50
+ method = smalltalk.send(smalltalk.send(self, "_compiler", []), "_install_forClass_category_", [aString, smalltalk.send(self, "_targetClass", []), "tests"]);
51
+ result = smalltalk.send(self['@receiver'], "_perform_", [smalltalk.send(method, "_selector", [])]);
52
+ smalltalk.send(smalltalk.send(self, "_targetClass", []), "_removeCompiledMethod_", [method]);
53
+ smalltalk.send(self, "_assert_equals_", [anObject, result]);
54
+ return self;
55
+ }
56
+ }),
57
+ smalltalk.CodeGeneratorTest);
58
+
59
+ smalltalk.addMethod(
60
+ "_targetClass",
61
+ smalltalk.method({
62
+ selector: "targetClass",
63
+ fn: function () {
64
+ var self = this;
65
+ return smalltalk.DoIt || DoIt;
66
+ }
45
67
  }),
46
- smalltalk.ImporterTest);
68
+ smalltalk.CodeGeneratorTest);
47
69
 
48
70
  smalltalk.addMethod(
49
71
  "_tearDown",
50
72
  smalltalk.method({
51
73
  selector: "tearDown",
52
- fn: function (){
53
- var self=this;
54
- smalltalk.send(self, "_tearDown", [], smalltalk.ImporterTest.superclass || nil);
55
- smalltalk.send(self, "_cleanUp", []);
56
- return self;}
74
+ fn: function () {
75
+ var self = this;
76
+ return self;
77
+ }
78
+ }),
79
+ smalltalk.CodeGeneratorTest);
80
+
81
+ smalltalk.addMethod(
82
+ "_testAssignment",
83
+ smalltalk.method({
84
+ selector: "testAssignment",
85
+ fn: function () {
86
+ var self = this;
87
+ smalltalk.send(self, "_should_return_", ["foo | a | a := true ifTrue: [ 1 ]. ^ a", 1]);
88
+ smalltalk.send(self, "_should_return_", ["foo | a | a := false ifTrue: [ 1 ]. ^ a", nil]);
89
+ smalltalk.send(self, "_should_return_", ["foo | a | ^ a := true ifTrue: [ 1 ]", 1]);
90
+ return self;
91
+ }
92
+ }),
93
+ smalltalk.CodeGeneratorTest);
94
+
95
+ smalltalk.addMethod(
96
+ "_testBlockReturn",
97
+ smalltalk.method({
98
+ selector: "testBlockReturn",
99
+ fn: function () {
100
+ var self = this;
101
+ smalltalk.send(self, "_should_return_", ["foo ^ #(1 2 3) collect: [ :each | true ifTrue: [ each + 1 ] ]", [2, 3, 4]]);
102
+ smalltalk.send(self, "_should_return_", ["foo ^ #(1 2 3) collect: [ :each | false ifFalse: [ each + 1 ] ]", [2, 3, 4]]);
103
+ smalltalk.send(self, "_should_return_", ["foo ^ #(1 2 3) collect: [ :each | each odd ifTrue: [ each + 1 ] ifFalse: [ each - 1 ] ]", [2, 1, 4]]);
104
+ return self;
105
+ }
106
+ }),
107
+ smalltalk.CodeGeneratorTest);
108
+
109
+ smalltalk.addMethod(
110
+ "_testCascades",
111
+ smalltalk.method({
112
+ selector: "testCascades",
113
+ fn: function () {
114
+ var self = this;
115
+ smalltalk.send(self, "_should_return_", ["foo ^ Array new add: 3; add: 4; yourself", [3, 4]]);
116
+ return self;
117
+ }
118
+ }),
119
+ smalltalk.CodeGeneratorTest);
120
+
121
+ smalltalk.addMethod(
122
+ "_testLiterals",
123
+ smalltalk.method({
124
+ selector: "testLiterals",
125
+ fn: function () {
126
+ var self = this;
127
+ smalltalk.send(self, "_should_return_", ["foo ^ 1", 1]);
128
+ smalltalk.send(self, "_should_return_", ["foo ^ 'hello'", "hello"]);
129
+ smalltalk.send(self, "_should_return_", ["foo ^ #(1 2 3 4)", [1, 2, 3, 4]]);
130
+ smalltalk.send(self, "_should_return_", ["foo ^ {1. [:x | x ] value: 2. 3. [4] value}", [1, 2, 3, 4]]);
131
+ smalltalk.send(self, "_should_return_", ["foo ^ true", true]);
132
+ smalltalk.send(self, "_should_return_", ["foo ^ false", false]);
133
+ smalltalk.send(self, "_should_return_", ["foo ^ #{1->2. 3->4}", smalltalk.HashedCollection._fromPairs_([smalltalk.send(1, "__minus_gt", [2]), smalltalk.send(3, "__minus_gt", [4])])]);
134
+ smalltalk.send(self, "_should_return_", ["foo ^ #hello", smalltalk.symbolFor("hello")]);
135
+ smalltalk.send(self, "_should_return_", ["foo ^ -123.456", -123.456]);
136
+ return self;
137
+ }
138
+ }),
139
+ smalltalk.CodeGeneratorTest);
140
+
141
+ smalltalk.addMethod(
142
+ "_testLocalReturn",
143
+ smalltalk.method({
144
+ selector: "testLocalReturn",
145
+ fn: function () {
146
+ var self = this;
147
+ smalltalk.send(self, "_should_return_", ["foo ^ 1", 1]);
148
+ smalltalk.send(self, "_should_return_", ["foo ^ 1 + 1", 2]);
149
+ smalltalk.send(self, "_should_return_", ["foo ", self['@receiver']]);
150
+ smalltalk.send(self, "_should_return_", ["foo self asString", self['@receiver']]);
151
+ smalltalk.send(self, "_should_return_", ["foo | a b | a := 1. b := 2. ^ a + b", 3]);
152
+ return self;
153
+ }
154
+ }),
155
+ smalltalk.CodeGeneratorTest);
156
+
157
+ smalltalk.addMethod(
158
+ "_testMessageSends",
159
+ smalltalk.method({
160
+ selector: "testMessageSends",
161
+ fn: function () {
162
+ var self = this;
163
+ smalltalk.send(self, "_should_return_", ["foo ^ 1 asString", "1"]);
164
+ smalltalk.send(self, "_should_return_", ["foo ^ 1 + 1", 2]);
165
+ smalltalk.send(self, "_should_return_", ["foo ^ 1 + 2 * 3", 9]);
166
+ smalltalk.send(self, "_should_return_", ["foo ^ 1 to: 3", [1, 2, 3]]);
167
+ smalltalk.send(self, "_should_return_", ["foo ^ 1 to: 5 by: 2", [1, 3, 5]]);
168
+ return self;
169
+ }
170
+ }),
171
+ smalltalk.CodeGeneratorTest);
172
+
173
+ smalltalk.addMethod(
174
+ "_testNestedIfTrue",
175
+ smalltalk.method({
176
+ selector: "testNestedIfTrue",
177
+ fn: function () {
178
+ var self = this;
179
+ smalltalk.send(self, "_should_return_", ["foo ^ true ifTrue: [ false ifFalse: [ 1 ] ]", 1]);
180
+ smalltalk.send(self, "_should_return_", ["foo ^ true ifTrue: [ false ifTrue: [ 1 ] ]", nil]);
181
+ smalltalk.send(self, "_should_return_", ["foo true ifTrue: [ false ifFalse: [ ^ 1 ] ]", 1]);
182
+ smalltalk.send(self, "_should_return_", ["foo true ifTrue: [ false ifTrue: [ ^ 1 ] ]", self['@receiver']]);
183
+ return self;
184
+ }
185
+ }),
186
+ smalltalk.CodeGeneratorTest);
187
+
188
+ smalltalk.addMethod(
189
+ "_testNonLocalReturn",
190
+ smalltalk.method({
191
+ selector: "testNonLocalReturn",
192
+ fn: function () {
193
+ var self = this;
194
+ smalltalk.send(self, "_should_return_", ["foo [ ^ 1 ] value", 1]);
195
+ smalltalk.send(self, "_should_return_", ["foo [ ^ 1 + 1 ] value", 2]);
196
+ smalltalk.send(self, "_should_return_", ["foo | a b | a := 1. b := 2. [ ^ a + b ] value. self halt", 3]);
197
+ smalltalk.send(self, "_should_return_", ["foo [ :x | ^ x + x ] value: 4. ^ 2", 8]);
198
+ return self;
199
+ }
200
+ }),
201
+ smalltalk.CodeGeneratorTest);
202
+
203
+ smalltalk.addMethod(
204
+ "_testifFalse",
205
+ smalltalk.method({
206
+ selector: "testifFalse",
207
+ fn: function () {
208
+ var self = this;
209
+ smalltalk.send(self, "_should_return_", ["foo true ifFalse: [ ^ 1 ]", self['@receiver']]);
210
+ smalltalk.send(self, "_should_return_", ["foo false ifFalse: [ ^ 2 ]", 2]);
211
+ smalltalk.send(self, "_should_return_", ["foo ^ true ifFalse: [ 1 ]", nil]);
212
+ smalltalk.send(self, "_should_return_", ["foo ^ false ifFalse: [ 2 ]", 2]);
213
+ return self;
214
+ }
215
+ }),
216
+ smalltalk.CodeGeneratorTest);
217
+
218
+ smalltalk.addMethod(
219
+ "_testifFalseIfTrue",
220
+ smalltalk.method({
221
+ selector: "testifFalseIfTrue",
222
+ fn: function () {
223
+ var self = this;
224
+ smalltalk.send(self, "_should_return_", ["foo true ifFalse: [ ^ 1 ] ifTrue: [ ^ 2 ]", 2]);
225
+ smalltalk.send(self, "_should_return_", ["foo false ifFalse: [ ^ 2 ] ifTrue: [ ^1 ]", 2]);
226
+ smalltalk.send(self, "_should_return_", ["foo ^ true ifFalse: [ 1 ] ifTrue: [ 2 ]", 2]);
227
+ smalltalk.send(self, "_should_return_", ["foo ^ false ifFalse: [ 2 ] ifTrue: [ 1 ]", 2]);
228
+ return self;
229
+ }
230
+ }),
231
+ smalltalk.CodeGeneratorTest);
232
+
233
+ smalltalk.addMethod(
234
+ "_testifNil",
235
+ smalltalk.method({
236
+ selector: "testifNil",
237
+ fn: function () {
238
+ var self = this;
239
+ smalltalk.send(self, "_should_return_", ["foo ^ 1 ifNil: [ 2 ]", 1]);
240
+ smalltalk.send(self, "_should_return_", ["foo ^ nil ifNil: [ 2 ]", 2]);
241
+ smalltalk.send(self, "_should_return_", ["foo 1 ifNil: [ ^ 2 ]", self['@receiver']]);
242
+ smalltalk.send(self, "_should_return_", ["foo nil ifNil: [ ^ 2 ]", 2]);
243
+ return self;
244
+ }
245
+ }),
246
+ smalltalk.CodeGeneratorTest);
247
+
248
+ smalltalk.addMethod(
249
+ "_testifNilIfNotNil",
250
+ smalltalk.method({
251
+ selector: "testifNilIfNotNil",
252
+ fn: function () {
253
+ var self = this;
254
+ smalltalk.send(self, "_should_return_", ["foo ^ 1 ifNil: [ 2 ] ifNotNil: [ 3 ]", 3]);
255
+ smalltalk.send(self, "_should_return_", ["foo ^ nil ifNil: [ 2 ] ifNotNil: [ 3 ]", 2]);
256
+ smalltalk.send(self, "_should_return_", ["foo 1 ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]", 3]);
257
+ smalltalk.send(self, "_should_return_", ["foo nil ifNil: [ ^ 2 ] ifNotNil: [ ^3 ]", 2]);
258
+ return self;
259
+ }
260
+ }),
261
+ smalltalk.CodeGeneratorTest);
262
+
263
+ smalltalk.addMethod(
264
+ "_testifNotNil",
265
+ smalltalk.method({
266
+ selector: "testifNotNil",
267
+ fn: function () {
268
+ var self = this;
269
+ smalltalk.send(self, "_should_return_", ["foo ^ 1 ifNotNil: [ 2 ]", 2]);
270
+ smalltalk.send(self, "_should_return_", ["foo ^ nil ifNotNil: [ 2 ]", nil]);
271
+ smalltalk.send(self, "_should_return_", ["foo 1 ifNotNil: [ ^ 2 ]", 2]);
272
+ smalltalk.send(self, "_should_return_", ["foo nil ifNotNil: [ ^ 2 ]", self['@receiver']]);
273
+ return self;
274
+ }
275
+ }),
276
+ smalltalk.CodeGeneratorTest);
277
+
278
+ smalltalk.addMethod(
279
+ "_testifTrue",
280
+ smalltalk.method({
281
+ selector: "testifTrue",
282
+ fn: function () {
283
+ var self = this;
284
+ smalltalk.send(self, "_should_return_", ["foo false ifTrue: [ ^ 1 ]", self['@receiver']]);
285
+ smalltalk.send(self, "_should_return_", ["foo true ifTrue: [ ^ 2 ]", 2]);
286
+ smalltalk.send(self, "_should_return_", ["foo ^ false ifTrue: [ 1 ]", nil]);
287
+ smalltalk.send(self, "_should_return_", ["foo ^ true ifTrue: [ 2 ]", 2]);
288
+ return self;
289
+ }
290
+ }),
291
+ smalltalk.CodeGeneratorTest);
292
+
293
+ smalltalk.addMethod(
294
+ "_testifTrueIfFalse",
295
+ smalltalk.method({
296
+ selector: "testifTrueIfFalse",
297
+ fn: function () {
298
+ var self = this;
299
+ smalltalk.send(self, "_should_return_", ["foo false ifTrue: [ ^ 1 ] ifFalse: [ ^2 ]", 2]);
300
+ smalltalk.send(self, "_should_return_", ["foo true ifTrue: [ ^ 1 ] ifFalse: [ ^ 2 ]", 1]);
301
+ smalltalk.send(self, "_should_return_", ["foo ^ false ifTrue: [ 2 ] ifFalse: [ 1 ]", 1]);
302
+ smalltalk.send(self, "_should_return_", ["foo ^ true ifTrue: [ 2 ] ifFalse: [ 1 ]", 2]);
303
+ return self;
304
+ }
305
+ }),
306
+ smalltalk.CodeGeneratorTest);
307
+
308
+
309
+
310
+ smalltalk.addClass('InliningCodeGeneratorTest', smalltalk.CodeGeneratorTest, [], 'Compiler-Tests');
311
+ smalltalk.addMethod(
312
+ "_codeGeneratorClass",
313
+ smalltalk.method({
314
+ selector: "codeGeneratorClass",
315
+ fn: function () {
316
+ var self = this;
317
+ return smalltalk.InliningCodeGenerator || InliningCodeGenerator;
318
+ }
319
+ }),
320
+ smalltalk.InliningCodeGeneratorTest);
321
+
322
+
323
+
324
+ smalltalk.addClass('ScopeVarTest', smalltalk.TestCase, [], 'Compiler-Tests');
325
+ smalltalk.addMethod(
326
+ "_testClassRefVar",
327
+ smalltalk.method({
328
+ selector: "testClassRefVar",
329
+ fn: function () {
330
+ var self = this;
331
+ var $1, $2;
332
+ var node;
333
+ $1 = smalltalk.send(smalltalk.ClassReferenceNode || ClassReferenceNode, "_new", []);
334
+ smalltalk.send($1, "_value_", ["Object"]);
335
+ $2 = smalltalk.send($1, "_yourself", []);
336
+ node = $2;
337
+ smalltalk.send(smalltalk.send(smalltalk.SemanticAnalyzer || SemanticAnalyzer, "_new", []), "_visit_", [node]);
338
+ smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(node, "_binding", []), "_isClassRefVar", [])]);
339
+ return self;
340
+ }
341
+ }),
342
+ smalltalk.ScopeVarTest);
343
+
344
+ smalltalk.addMethod(
345
+ "_testInstanceVar",
346
+ smalltalk.method({
347
+ selector: "testInstanceVar",
348
+ fn: function () {
349
+ var self = this;
350
+ var $1, $2;
351
+ var node;
352
+ var scope;
353
+ $1 = smalltalk.send(smalltalk.VariableNode || VariableNode, "_new", []);
354
+ smalltalk.send($1, "_value_", ["bzzz"]);
355
+ $2 = smalltalk.send($1, "_yourself", []);
356
+ node = $2;
357
+ scope = smalltalk.send(smalltalk.MethodLexicalScope || MethodLexicalScope, "_new", []);
358
+ smalltalk.send(scope, "_addIVar_", ["bzzz"]);
359
+ smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(scope, "_bindingFor_", [node]), "_isInstanceVar", [])]);
360
+ return self;
361
+ }
362
+ }),
363
+ smalltalk.ScopeVarTest);
364
+
365
+ smalltalk.addMethod(
366
+ "_testPseudoVar",
367
+ smalltalk.method({
368
+ selector: "testPseudoVar",
369
+ fn: function () {
370
+ var self = this;
371
+ var $1, $2;
372
+ var node;
373
+ var pseudoVars;
374
+ pseudoVars = ["self", "super", "true", "false", "nil"];
375
+ smalltalk.send(pseudoVars, "_do_", [function (each) {$1 = smalltalk.send(smalltalk.VariableNode || VariableNode, "_new", []);smalltalk.send($1, "_value_", [each]);$2 = smalltalk.send($1, "_yourself", []);node = $2;node;return smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.MethodLexicalScope || MethodLexicalScope, "_new", []), "_bindingFor_", [node]), "_isPseudoVar", [])]);}]);
376
+ return self;
377
+ }
378
+ }),
379
+ smalltalk.ScopeVarTest);
380
+
381
+ smalltalk.addMethod(
382
+ "_testTempVar",
383
+ smalltalk.method({
384
+ selector: "testTempVar",
385
+ fn: function () {
386
+ var self = this;
387
+ var $1, $2;
388
+ var node;
389
+ var scope;
390
+ $1 = smalltalk.send(smalltalk.VariableNode || VariableNode, "_new", []);
391
+ smalltalk.send($1, "_value_", ["bzzz"]);
392
+ $2 = smalltalk.send($1, "_yourself", []);
393
+ node = $2;
394
+ scope = smalltalk.send(smalltalk.MethodLexicalScope || MethodLexicalScope, "_new", []);
395
+ smalltalk.send(scope, "_addTemp_", ["bzzz"]);
396
+ smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(scope, "_bindingFor_", [node]), "_isTempVar", [])]);
397
+ return self;
398
+ }
399
+ }),
400
+ smalltalk.ScopeVarTest);
401
+
402
+ smalltalk.addMethod(
403
+ "_testUnknownVar",
404
+ smalltalk.method({
405
+ selector: "testUnknownVar",
406
+ fn: function () {
407
+ var self = this;
408
+ var $1, $2;
409
+ var node;
410
+ $1 = smalltalk.send(smalltalk.VariableNode || VariableNode, "_new", []);
411
+ smalltalk.send($1, "_value_", ["bzzz"]);
412
+ $2 = smalltalk.send($1, "_yourself", []);
413
+ node = $2;
414
+ smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.MethodLexicalScope || MethodLexicalScope, "_new", []), "_bindingFor_", [node]), "_isNil", [])]);
415
+ return self;
416
+ }
417
+ }),
418
+ smalltalk.ScopeVarTest);
419
+
420
+
421
+
422
+ smalltalk.addClass('SemanticAnalyzerTest', smalltalk.TestCase, ['analyzer'], 'Compiler-Tests');
423
+ smalltalk.addMethod(
424
+ "_setUp",
425
+ smalltalk.method({
426
+ selector: "setUp",
427
+ fn: function () {
428
+ var self = this;
429
+ self['@analyzer'] = smalltalk.send(smalltalk.SemanticAnalyzer || SemanticAnalyzer, "_on_", [smalltalk.Object || Object]);
430
+ return self;
431
+ }
432
+ }),
433
+ smalltalk.SemanticAnalyzerTest);
434
+
435
+ smalltalk.addMethod(
436
+ "_testAssignment",
437
+ smalltalk.method({
438
+ selector: "testAssignment",
439
+ fn: function () {
440
+ var self = this;
441
+ var src;
442
+ var ast;
443
+ src = "foo self := 1";
444
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
445
+ smalltalk.send(self, "_should_raise_", [function () {return smalltalk.send(self['@analyzer'], "_visit_", [ast]);}, smalltalk.InvalidAssignmentError || InvalidAssignmentError]);
446
+ return self;
447
+ }
448
+ }),
449
+ smalltalk.SemanticAnalyzerTest);
450
+
451
+ smalltalk.addMethod(
452
+ "_testNonLocalReturn",
453
+ smalltalk.method({
454
+ selector: "testNonLocalReturn",
455
+ fn: function () {
456
+ var self = this;
457
+ var src;
458
+ var ast;
459
+ src = "foo | a | a + 1. ^ a";
460
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
461
+ smalltalk.send(self['@analyzer'], "_visit_", [ast]);
462
+ smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(ast, "_scope", []), "_hasNonLocalReturn", [])]);
463
+ return self;
464
+ }
465
+ }),
466
+ smalltalk.SemanticAnalyzerTest);
467
+
468
+ smalltalk.addMethod(
469
+ "_testNonLocalReturn2",
470
+ smalltalk.method({
471
+ selector: "testNonLocalReturn2",
472
+ fn: function () {
473
+ var self = this;
474
+ var src;
475
+ var ast;
476
+ src = "foo | a | a + 1. [\xA0[ ^ a]\xA0]";
477
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
478
+ smalltalk.send(self['@analyzer'], "_visit_", [ast]);
479
+ smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(ast, "_scope", []), "_hasNonLocalReturn", [])]);
480
+ return self;
481
+ }
482
+ }),
483
+ smalltalk.SemanticAnalyzerTest);
484
+
485
+ smalltalk.addMethod(
486
+ "_testScope",
487
+ smalltalk.method({
488
+ selector: "testScope",
489
+ fn: function () {
490
+ var self = this;
491
+ var src;
492
+ var ast;
493
+ src = "foo | a | a + 1. [ | b | b := a ]";
494
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
495
+ smalltalk.send(self['@analyzer'], "_visit_", [ast]);
496
+ smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(ast, "_nodes", []), "_first", []), "_nodes", []), "_last", []), "_scope", []), "__eq_eq", [smalltalk.send(ast, "_scope", [])])]);
497
+ return self;
498
+ }
499
+ }),
500
+ smalltalk.SemanticAnalyzerTest);
501
+
502
+ smalltalk.addMethod(
503
+ "_testScope2",
504
+ smalltalk.method({
505
+ selector: "testScope2",
506
+ fn: function () {
507
+ var self = this;
508
+ var src;
509
+ var ast;
510
+ src = "foo | a | a + 1. [ [ | b | b := a\xA0] ]";
511
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
512
+ smalltalk.send(self['@analyzer'], "_visit_", [ast]);
513
+ smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(ast, "_nodes", []), "_first", []), "_nodes", []), "_last", []), "_nodes", []), "_first", []), "_nodes", []), "_first", []), "_scope", []), "__eq_eq", [smalltalk.send(ast, "_scope", [])])]);
514
+ return self;
515
+ }
516
+ }),
517
+ smalltalk.SemanticAnalyzerTest);
518
+
519
+ smalltalk.addMethod(
520
+ "_testScopeLevel",
521
+ smalltalk.method({
522
+ selector: "testScopeLevel",
523
+ fn: function () {
524
+ var self = this;
525
+ var src;
526
+ var ast;
527
+ src = "foo | a | a + 1. [ [ | b | b := a\xA0] ]";
528
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
529
+ smalltalk.send(self['@analyzer'], "_visit_", [ast]);
530
+ smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(ast, "_scope", []), "_scopeLevel", []), "__eq", [1])]);
531
+ smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(ast, "_nodes", []), "_first", []), "_nodes", []), "_last", []), "_nodes", []), "_first", []), "_nodes", []), "_first", []), "_scope", []), "_scopeLevel", []), "__eq", [3])]);
532
+ return self;
533
+ }
534
+ }),
535
+ smalltalk.SemanticAnalyzerTest);
536
+
537
+ smalltalk.addMethod(
538
+ "_testUnknownVariables",
539
+ smalltalk.method({
540
+ selector: "testUnknownVariables",
541
+ fn: function () {
542
+ var self = this;
543
+ var src;
544
+ var ast;
545
+ src = "foo | a | b + a";
546
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
547
+ smalltalk.send(self, "_should_raise_", [function () {return smalltalk.send(self['@analyzer'], "_visit_", [ast]);}, smalltalk.UnknownVariableError || UnknownVariableError]);
548
+ return self;
549
+ }
550
+ }),
551
+ smalltalk.SemanticAnalyzerTest);
552
+
553
+ smalltalk.addMethod(
554
+ "_testUnknownVariablesDefinedInJS",
555
+ smalltalk.method({
556
+ selector: "testUnknownVariablesDefinedInJS",
557
+ fn: function () {
558
+ var self = this;
559
+ var someVariable = 1;
560
+ smalltalk.send(self, "_shouldnt_raise_", [function () {return smalltalk.send(smalltalk, "_parse_", ["foo someVariable"]);}, smalltalk.UnknownVariableError || UnknownVariableError]);
561
+ return self;
562
+ }
57
563
  }),
58
- smalltalk.ImporterTest);
564
+ smalltalk.SemanticAnalyzerTest);
59
565
 
60
566
  smalltalk.addMethod(
61
- "_testBigChunkString",
567
+ "_testUnknownVariablesWithScope",
62
568
  smalltalk.method({
63
- selector: "testBigChunkString",
64
- fn: function (){
65
- var self=this;
66
- smalltalk.send(smalltalk.send((smalltalk.Importer || Importer), "_new", []), "_import_", [smalltalk.send(smalltalk.send(self, "_bigChunkString", []), "_readStream", [])]);
67
- smalltalk.send(smalltalk.send((smalltalk.CypressPackage || CypressPackage), "_new", []), "_species", []);
68
- return self;}
569
+ selector: "testUnknownVariablesWithScope",
570
+ fn: function () {
571
+ var self = this;
572
+ var src;
573
+ var ast;
574
+ src = "foo | a b | [ c + 1. [ a + 1. d + 1 ]]";
575
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
576
+ smalltalk.send(self, "_should_raise_", [function () {return smalltalk.send(self['@analyzer'], "_visit_", [ast]);}, smalltalk.UnknownVariableError || UnknownVariableError]);
577
+ return self;
578
+ }
69
579
  }),
70
- smalltalk.ImporterTest);
580
+ smalltalk.SemanticAnalyzerTest);
71
581
 
72
582
  smalltalk.addMethod(
73
- "_testChunkString",
583
+ "_testVariableShadowing",
74
584
  smalltalk.method({
75
- selector: "testChunkString",
76
- fn: function (){
77
- var self=this;
78
- smalltalk.send(smalltalk.send((smalltalk.Importer || Importer), "_new", []), "_import_", [smalltalk.send(smalltalk.send(self, "_chunkString", []), "_readStream", [])]);
79
- smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_methodDictionary", []), "_includesKey_", ["importerTestMethod"])]);
80
- smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_new", []), "_importerTestMethod", []), "__eq", ["success"])]);
81
- return self;}
585
+ selector: "testVariableShadowing",
586
+ fn: function () {
587
+ var self = this;
588
+ var src;
589
+ var ast;
590
+ src = "foo | a | a + 1";
591
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
592
+ smalltalk.send(self['@analyzer'], "_visit_", [ast]);
593
+ return self;
594
+ }
82
595
  }),
83
- smalltalk.ImporterTest);
596
+ smalltalk.SemanticAnalyzerTest);
84
597
 
598
+ smalltalk.addMethod(
599
+ "_testVariableShadowing2",
600
+ smalltalk.method({
601
+ selector: "testVariableShadowing2",
602
+ fn: function () {
603
+ var self = this;
604
+ var src;
605
+ var ast;
606
+ src = "foo | a | a + 1. [ | a | a := 2 ]";
607
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
608
+ smalltalk.send(self, "_should_raise_", [function () {return smalltalk.send(self['@analyzer'], "_visit_", [ast]);}, smalltalk.ShadowingVariableError || ShadowingVariableError]);
609
+ return self;
610
+ }
611
+ }),
612
+ smalltalk.SemanticAnalyzerTest);
85
613
 
614
+ smalltalk.addMethod(
615
+ "_testVariableShadowing3",
616
+ smalltalk.method({
617
+ selector: "testVariableShadowing3",
618
+ fn: function () {
619
+ var self = this;
620
+ var src;
621
+ var ast;
622
+ src = "foo | a | a + 1. [ | b | b := 2 ]";
623
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
624
+ smalltalk.send(self['@analyzer'], "_visit_", [ast]);
625
+ return self;
626
+ }
627
+ }),
628
+ smalltalk.SemanticAnalyzerTest);
86
629
 
87
630
  smalltalk.addMethod(
88
- "_importerLoadMethod",
631
+ "_testVariableShadowing4",
89
632
  smalltalk.method({
90
- selector: "importerLoadMethod",
91
- fn: function (){
92
- var self=this;
93
- return "success";
94
- return self;}
633
+ selector: "testVariableShadowing4",
634
+ fn: function () {
635
+ var self = this;
636
+ var src;
637
+ var ast;
638
+ src = "foo | a | a + 1. [ [\xA0[ | b | b := 2 ]\xA0]\xA0]";
639
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
640
+ smalltalk.send(self['@analyzer'], "_visit_", [ast]);
641
+ return self;
642
+ }
95
643
  }),
96
- smalltalk.Object);
644
+ smalltalk.SemanticAnalyzerTest);
645
+
646
+ smalltalk.addMethod(
647
+ "_testVariableShadowing5",
648
+ smalltalk.method({
649
+ selector: "testVariableShadowing5",
650
+ fn: function () {
651
+ var self = this;
652
+ var src;
653
+ var ast;
654
+ src = "foo | a | a + 1. [ [\xA0[ | a | a := 2 ]\xA0]\xA0]";
655
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
656
+ smalltalk.send(self, "_should_raise_", [function () {return smalltalk.send(self['@analyzer'], "_visit_", [ast]);}, smalltalk.ShadowingVariableError || ShadowingVariableError]);
657
+ return self;
658
+ }
659
+ }),
660
+ smalltalk.SemanticAnalyzerTest);
661
+
662
+ smalltalk.addMethod(
663
+ "_testVariablesLookup",
664
+ smalltalk.method({
665
+ selector: "testVariablesLookup",
666
+ fn: function () {
667
+ var self = this;
668
+ var src;
669
+ var ast;
670
+ src = "foo | a | a + 1. [ | b | b := a ]";
671
+ ast = smalltalk.send(smalltalk, "_parse_", [src]);
672
+ smalltalk.send(self['@analyzer'], "_visit_", [ast]);
673
+ smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(ast, "_nodes", []), "_first", []), "_nodes", []), "_first", []), "_receiver", []), "_binding", []), "_isTempVar", [])]);
674
+ smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(ast, "_nodes", []), "_first", []), "_nodes", []), "_first", []), "_receiver", []), "_binding", []), "_scope", []), "__eq_eq", [smalltalk.send(ast, "_scope", [])])]);
675
+ smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(ast, "_nodes", []), "_first", []), "_nodes", []), "_last", []), "_nodes", []), "_first", []), "_nodes", []), "_first", []), "_left", []), "_binding", []), "_isTempVar", [])]);
676
+ smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(ast, "_nodes", []), "_first", []), "_nodes", []), "_last", []), "_nodes", []), "_first", []), "_nodes", []), "_first", []), "_left", []), "_binding", []), "_scope", []), "__eq_eq", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(ast, "_nodes", []), "_first", []), "_nodes", []), "_last", []), "_scope", [])])]);
677
+ return self;
678
+ }
679
+ }),
680
+ smalltalk.SemanticAnalyzerTest);
681
+
682
+
97
683