compiler/PPCBenchmarkResources.st
changeset 414 0eaf09920532
parent 413 5389e6fbb3bc
equal deleted inserted replaced
413:5389e6fbb3bc 414:0eaf09920532
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
     1 "{ Package: 'stx:goodies/petitparser/compiler' }"
     2 
     2 
     3 Object subclass:#PPCBenchmarkResources
     3 Object subclass:#PPCBenchmarkResources
     4 	instanceVariableNames:''
     4 	instanceVariableNames:''
     5 	classVariableNames:''
     5 	classVariableNames:'javaCache'
     6 	poolDictionaries:''
     6 	poolDictionaries:''
     7 	category:'PetitCompiler-Benchmarks'
     7 	category:'PetitCompiler-Benchmarks'
     8 !
     8 !
     9 
     9 
    10 !PPCBenchmarkResources methodsFor:'as yet unclassified'!
    10 !PPCBenchmarkResources methodsFor:'as yet unclassified'!
       
    11 
       
    12 changesSized: size
       
    13 	| string changes |
       
    14 	changes := PharoFilesOpener default changesFileOrNil contents.
       
    15 	string :=  changes copyFrom: 1 to: size.
       
    16 	^ string
       
    17 	
       
    18 !
       
    19 
       
    20 javaInDirectory: directory
       
    21 	| files |
       
    22 	files := self readDirectory: directory.
       
    23 	files := self files: files withExtension: 'java'.
       
    24 	
       
    25 	^ files collect: [ :f | (FileStream fileNamed: f) contents ]
       
    26 !
    11 
    27 
    12 javaLangClass
    28 javaLangClass
    13 !
    29 !
    14 
    30 
    15 javaLangMath
    31 javaLangMath
  1234     }
  1250     }
  1235 }
  1251 }
  1236 '
  1252 '
  1237 !
  1253 !
  1238 
  1254 
       
  1255 javaSourcesBig
       
  1256 	^ self workingJavaInDirectory: '../java-src/java/util'
       
  1257 !
       
  1258 
  1239 petitParserPackage
  1259 petitParserPackage
  1240 ^ '
  1260 ^ '
  1241 Object subclass: #PPCharSetPredicate
  1261 Object subclass: #PPCharSetPredicate
  1242 	instanceVariableNames: ''block classification''
  1262 	instanceVariableNames: ''block classification''
  1243 	classVariableNames: ''''
  1263 	classVariableNames: ''''
  5161 
  5181 
  5162 smalltalkSourcesBig
  5182 smalltalkSourcesBig
  5163 	^ ((Smalltalk allClasses copyFrom: 1 to: 30) collect: [ :c |
  5183 	^ ((Smalltalk allClasses copyFrom: 1 to: 30) collect: [ :c |
  5164 			c allMethods collect: [ :m | m sourceCode ]
  5184 			c allMethods collect: [ :m | m sourceCode ]
  5165 	  ]) gather: [:each | each ].
  5185 	  ]) gather: [:each | each ].
       
  5186 !
       
  5187 
       
  5188 workingJavaInDirectory: directory
       
  5189 	| sources parser |
       
  5190 	"return only such a files, that can be parsed by PPJavaSyntax"
       
  5191 
       
  5192 	javaCache ifNil: [ javaCache := Dictionary new ].
       
  5193 	
       
  5194 	^ javaCache at: directory ifAbsentPut: [ 
       
  5195 		sources := self javaInDirectory: directory.
       
  5196 		parser := PPJavaSyntax new.
       
  5197 	
       
  5198 		sources select: [ :source | ([parser parse: source ] on: Error do: [ PPFailure new ]) isPetitFailure not ]	
       
  5199 	]
  5166 ! !
  5200 ! !
  5167 
  5201 
       
  5202 !PPCBenchmarkResources methodsFor:'private utilities'!
       
  5203 
       
  5204 files: files withExtension: extension
       
  5205 	^ files select: [ :f | f extension = extension ] 
       
  5206 !
       
  5207 
       
  5208 readDirectory: directory
       
  5209 	| file |
       
  5210 	file := directory asFileReference.
       
  5211 	file exists ifTrue: [ 
       
  5212 		^ file allFiles
       
  5213 	].
       
  5214 	^ #()
       
  5215 ! !
       
  5216