compiler/benchmarks/PPCBenchmarkResources.st
changeset 452 9f4558b3be66
parent 438 20598d7ce9fa
child 453 bd5107faf4d6
child 459 4751c407bb40
equal deleted inserted replaced
438:20598d7ce9fa 452:9f4558b3be66
     1 "{ Package: 'stx:goodies/petitparser/compiler/benchmarks' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 Object subclass:#PPCBenchmarkResources
       
     6 	instanceVariableNames:''
       
     7 	classVariableNames:'javaCache'
       
     8 	poolDictionaries:''
       
     9 	category:'PetitCompiler-Benchmarks-Core'
       
    10 !
       
    11 
       
    12 
       
    13 !PPCBenchmarkResources methodsFor:'as yet unclassified'!
       
    14 
       
    15 changesSized: size
       
    16 	| string changes |
       
    17 	changes := PharoFilesOpener default changesFileOrNil contents.
       
    18 	string :=  changes copyFrom: 1 to: size.
       
    19 	^ string
       
    20 	
       
    21 !
       
    22 
       
    23 javaInDirectory: directory
       
    24 	| files |
       
    25 	files := self readDirectory: directory.
       
    26 	files := self files: files withExtension: 'java'.
       
    27 	
       
    28 	^ files collect: [ :f | (FileStream fileNamed: f) contents ]
       
    29 !
       
    30 
       
    31 javaLangMath
       
    32 	^ (FileStream fileNamed: '../java-src/java/lang/Math.java') contents
       
    33 !
       
    34 
       
    35 javaSourcesBig
       
    36 	^ self javaInDirectory: '../java-src/java/util'.
       
    37 	"^ self workingJavaInDirectory: '../java-src/java/util'"
       
    38 !
       
    39 
       
    40 smalltalkInDirectory: directory
       
    41 	| files |
       
    42 	files := self readDirectory: directory.
       
    43 	files := self files: files withExtension: 'st'.
       
    44 	
       
    45 	^ files collect: [ :f | (FileStream fileNamed: f) contents ]
       
    46 !
       
    47 
       
    48 smalltalkObjectMethods
       
    49 	^ Object allMethods collect: [ :m | m sourceCode ].
       
    50 !
       
    51 
       
    52 smalltalkSourcesBig
       
    53 	^ self smalltalkInDirectory: '../smalltalk-src/'
       
    54 !
       
    55 
       
    56 smalltalkSourcesBig_old
       
    57 	^ ((Smalltalk allClasses copyFrom: 1 to: 30) collect: [ :c |
       
    58 			c allMethods collect: [ :m | m sourceCode ]
       
    59 	  ]) gather: [:each | each ].
       
    60 !
       
    61 
       
    62 workingJavaInDirectory: directory
       
    63 	| sources parser |
       
    64 	"return only such a files, that can be parsed by PPJavaSyntax"
       
    65 
       
    66 	javaCache ifNil: [ javaCache := Dictionary new ].
       
    67 	
       
    68 	^ javaCache at: directory ifAbsentPut: [ 
       
    69 		sources := self javaInDirectory: directory.
       
    70 		parser := PPJavaSyntax new.
       
    71 	
       
    72 		sources select: [ :source | ([parser parse: source ] on: Error do: [ PPFailure new ]) isPetitFailure not ]	
       
    73 	]
       
    74 ! !
       
    75 
       
    76 !PPCBenchmarkResources methodsFor:'private utilities'!
       
    77 
       
    78 files: files withExtension: extension
       
    79 	^ files select: [ :f | f extension = extension ] 
       
    80 !
       
    81 
       
    82 readDirectory: directory
       
    83 	| file |
       
    84 	file := directory asFileReference.
       
    85 	file exists ifTrue: [ 
       
    86 		^ file allFiles
       
    87 	].
       
    88 	^ #()
       
    89 ! !
       
    90 
       
    91 !PPCBenchmarkResources class methodsFor:'documentation'!
       
    92 
       
    93 version_HG
       
    94 
       
    95     ^ '$Changeset: <not expanded> $'
       
    96 ! !
       
    97