2
0

Compiler-Tests.deploy.js 13 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. smalltalk.addPackage('Compiler-Tests', {});
  2. smalltalk.addClass('ImporterTest', smalltalk.TestCase, [], 'Compiler-Tests');
  3. smalltalk.addMethod(
  4. "_bigChunkString",
  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;}
  11. }),
  12. smalltalk.ImporterTest);
  13. smalltalk.addMethod(
  14. "_chunkString",
  15. smalltalk.method({
  16. selector: "chunkString",
  17. fn: function (){
  18. var self=this;
  19. return "!Object methodsFor: 'importer test method'!\x0a\x0aimporterTestMethod\x0a\x0a\x09^'success'\x0a! !\x0a";
  20. return self;}
  21. }),
  22. smalltalk.ImporterTest);
  23. smalltalk.addMethod(
  24. "_cleanUp",
  25. smalltalk.method({
  26. selector: "cleanUp",
  27. fn: function (){
  28. var self=this;
  29. ((($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")])]);})]));
  30. return self;}
  31. }),
  32. smalltalk.ImporterTest);
  33. smalltalk.addMethod(
  34. "_setUp",
  35. smalltalk.method({
  36. selector: "setUp",
  37. fn: function (){
  38. var self=this;
  39. smalltalk.send(self, "_setUp", [], smalltalk.ImporterTest.superclass || nil);
  40. smalltalk.send(self, "_cleanUp", []);
  41. return self;}
  42. }),
  43. smalltalk.ImporterTest);
  44. smalltalk.addMethod(
  45. "_tearDown",
  46. smalltalk.method({
  47. selector: "tearDown",
  48. fn: function (){
  49. var self=this;
  50. smalltalk.send(self, "_tearDown", [], smalltalk.ImporterTest.superclass || nil);
  51. smalltalk.send(self, "_cleanUp", []);
  52. return self;}
  53. }),
  54. smalltalk.ImporterTest);
  55. smalltalk.addMethod(
  56. "_testBigChunkString",
  57. smalltalk.method({
  58. selector: "testBigChunkString",
  59. fn: function (){
  60. var self=this;
  61. smalltalk.send(smalltalk.send((smalltalk.Importer || Importer), "_new", []), "_import_", [smalltalk.send(smalltalk.send(self, "_bigChunkString", []), "_readStream", [])]);
  62. smalltalk.send(smalltalk.send((smalltalk.CypressPackage || CypressPackage), "_new", []), "_species", []);
  63. return self;}
  64. }),
  65. smalltalk.ImporterTest);
  66. smalltalk.addMethod(
  67. "_testChunkString",
  68. smalltalk.method({
  69. selector: "testChunkString",
  70. fn: function (){
  71. var self=this;
  72. smalltalk.send(smalltalk.send((smalltalk.Importer || Importer), "_new", []), "_import_", [smalltalk.send(smalltalk.send(self, "_chunkString", []), "_readStream", [])]);
  73. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_methodDictionary", []), "_includesKey_", ["importerTestMethod"])]);
  74. smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.Object || Object), "_new", []), "_importerTestMethod", []), "__eq", ["success"])]);
  75. return self;}
  76. }),
  77. smalltalk.ImporterTest);
  78. smalltalk.addMethod(
  79. "_importerLoadMethod",
  80. smalltalk.method({
  81. selector: "importerLoadMethod",
  82. fn: function (){
  83. var self=this;
  84. return "success";
  85. return self;}
  86. }),
  87. smalltalk.Object);