VM Maker: VMMakerCompatibilityForPharo6-GuillermoPolito.12.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: VMMakerCompatibilityForPharo6-GuillermoPolito.12.mcz

commits-2
 
Guillermo Polito uploaded a new version of VMMakerCompatibilityForPharo6 to project VM Maker:
http://source.squeak.org/VMMaker/VMMakerCompatibilityForPharo6-GuillermoPolito.12.mcz

==================== Summary ====================

Name: VMMakerCompatibilityForPharo6-GuillermoPolito.12
Author: GuillermoPolito
Time: 9 May 2019, 5:44:58.893868 pm
UUID: 9f94c311-d844-0d00-b3c4-7c560f1a7e9a
Ancestors: VMMakerCompatibilityForPharo6-GuillermoPolito.11

Moved tests to Pharo compatibility package

=============== Diff against VMMakerCompatibilityForPharo6-GuillermoPolito.11 ===============

Item was changed:
  SystemOrganization addCategory: #VMMakerCompatibilityForPharo6!
  SystemOrganization addCategory: 'VMMakerCompatibilityForPharo6-FileDirectoryToFileSystem'!
  SystemOrganization addCategory: 'VMMakerCompatibilityForPharo6-Kernel-Methods'!
  SystemOrganization addCategory: 'VMMakerCompatibilityForPharo6-PackageOrganizer'!
  SystemOrganization addCategory: 'VMMakerCompatibilityForPharo6-SUnit-Extensions'!
  SystemOrganization addCategory: 'VMMakerCompatibilityForPharo6-System'!
+ SystemOrganization addCategory: 'VMMakerCompatibilityForPharo6-Tests'!

Item was changed:
  DisplayObject subclass: #DisplayText
  instanceVariableNames: 'text textStyle offset form foreColor backColor'
  classVariableNames: ''
  poolDictionaries: 'TextConstants'
+ category: 'VMMakerCompatibilityForPharo6-System'!
- category: 'VMMakerCompatibilityForPharo6'!
 
  !DisplayText commentStamp: '<historical>' prior: 0!
  I represent Text whose emphasis changes are mapped to a set of fonts. My instances have an offset used in determining screen placement for displaying. They get used two different ways in the system. In the user interface, they mainly hold onto some text which is viewed by some form of ParagraphEditor. However, as a DisplayObject, they may need to display efficiently, so my instances have a cache for the bits.!

Item was changed:
  WriteStream subclass: #TranscriptStream
  instanceVariableNames: 'lastChar'
  classVariableNames: 'AccessSema CharacterLimit ForceUpdate RedirectToStdOut'
  poolDictionaries: ''
+ category: 'VMMakerCompatibilityForPharo6-System'!
- category: 'VMMakerCompatibilityForPharo6'!
 
  !TranscriptStream commentStamp: 'fbs 12/30/2013 09:53' prior: 0!
  This class is a much simpler implementation of Transcript protocol that supports multiple views and very simple conversion to morphic.  Because it inherits from Stream, it is automatically compatible with code that is designed to write to streams.!

Item was added:
+ TestCase subclass: #VMCodeGenerationTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'VMMakerCompatibilityForPharo6-Tests'!

Item was added:
+ ----- Method: VMCodeGenerationTest>>methodWithIfNil (in category 'generation-targets') -----
+ methodWithIfNil
+
+ self something
+ ifNil: [ 1 ]
+ ifNotNil: [ 2 ]!

Item was added:
+ ----- Method: VMCodeGenerationTest>>methodWithIfNilAssignment (in category 'generation-targets') -----
+ methodWithIfNilAssignment
+
+ | variable |
+ variable := self something
+ ifNil: [ 1 ]
+ ifNotNil: [ 2 ]!

Item was added:
+ ----- Method: VMCodeGenerationTest>>methodWithIfNilAssignmentOfComplexStatements (in category 'generation-targets') -----
+ methodWithIfNilAssignmentOfComplexStatements
+
+ | variable |
+ variable := self something
+ ifNil: [ | temp |
+ temp := 1.
+ temp := temp + 1.
+ temp * 3 ]
+ ifNotNil: [ | temp |
+ temp := 2.
+ temp := temp + 5.
+ temp * 3 ]!

Item was added:
+ ----- Method: VMCodeGenerationTest>>methodWithLoop (in category 'generation-targets') -----
+ methodWithLoop
+
+ 1 to: 10 do: [ :i | self foo: i ]!

Item was added:
+ ----- Method: VMCodeGenerationTest>>methodWithNilIfNil (in category 'generation-targets') -----
+ methodWithNilIfNil
+
+ ^ nil
+ ifNil: [ 1 ]
+ ifNotNil: [ 2 ]!

Item was added:
+ ----- Method: VMCodeGenerationTest>>testComplexIfNilAssignment (in category 'tests') -----
+ testComplexIfNilAssignment
+
+ | translation method codeGenerator result |
+ method := self class >> #methodWithIfNilAssignmentOfComplexStatements.
+ translation := method asTranslationMethodOfClass: TMethod.
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator addMethod: translation.
+ codeGenerator doInlining: true.
+
+ result := String streamContents: [ :stream |
+ translation parseTree statements first emitCCodeOn: stream level: 0 generator: codeGenerator.
+ ].
+
+ self assert: result equals: 'if ((something()) == null) {
+ temp = 1;
+ temp += 1;
+ variable = temp * 3;
+ }
+ else {
+ temp = 2;
+ temp += 5;
+ variable = temp * 3;
+ }'!

Item was added:
+ ----- Method: VMCodeGenerationTest>>testLoopVariableIsTemp (in category 'tests') -----
+ testLoopVariableIsTemp
+
+ | translation method codeGenerator result |
+ method := self class >> #methodWithLoop.
+ translation := method asTranslationMethodOfClass: TMethod.
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator doInlining: true.
+
+ result := String streamContents: [ :stream |
+ translation emitCCodeOn: stream generator: codeGenerator.
+ ].
+
+ self assert: result equals: '
+ /* VMCodeGenerationTest>>#methodWithLoop */
+ static sqInt
+ methodWithLoop(void)
+ {
+     sqInt i;
+
+ for (i = 1; i <= 10; i += 1) {
+ foo(i);
+ }
+ return self;
+ }
+ '!

Item was added:
+ ----- Method: VMCodeGenerationTest>>testNilIfNilGeneratesOnlyFirstBranch (in category 'tests') -----
+ testNilIfNilGeneratesOnlyFirstBranch
+
+ | translation method codeGenerator result |
+ method := self class >> #methodWithNilIfNil.
+ translation := method asTranslationMethodOfClass: TMethod.
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator generateDeadCode: false.
+ codeGenerator addMethod: translation.
+ codeGenerator doInlining: true.
+
+ result := String streamContents: [ :stream |
+ translation parseTree statements first emitCCodeOn: stream level: 0 generator: codeGenerator.
+ ].
+
+ self assert: result equals: 'return 1'!

Item was added:
+ ----- Method: VMCodeGenerationTest>>testSimpleIfNil (in category 'tests') -----
+ testSimpleIfNil
+
+ | translation method codeGenerator result |
+ method := self class >> #methodWithIfNilAssignment.
+ translation := method asTranslationMethodOfClass: TMethod.
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator generateDeadCode: false.
+ codeGenerator addMethod: translation.
+ codeGenerator doInlining: true.
+
+ result := String streamContents: [ :stream |
+ translation parseTree statements first emitCCodeOn: stream level: 0 generator: codeGenerator.
+ ].
+
+ self assert: result equals: 'variable = ((something()) == null
+ ? 1
+ : 2)'!

Item was added:
+ ----- Method: VMCodeGenerationTest>>testSimpleIfNilAssignment (in category 'tests') -----
+ testSimpleIfNilAssignment
+
+ | translation method codeGenerator result |
+ method := self class >> #methodWithIfNil.
+ translation := method asTranslationMethodOfClass: TMethod.
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator generateDeadCode: false.
+ codeGenerator addMethod: translation.
+ codeGenerator doInlining: true.
+
+ result := String streamContents: [ :stream |
+ translation parseTree statements first emitCCodeOn: stream level: 0 generator: codeGenerator.
+ ].
+
+ self assert: result equals: 'if ((something()) == null) {
+ }
+ else {
+ }'!

Item was added:
+ TestCase subclass: #VMMASTTranslationTest
+ instanceVariableNames: ''
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'VMMakerCompatibilityForPharo6-Tests'!

Item was added:
+ ----- Method: VMMASTTranslationTest>>+ (in category 'generation-targets') -----
+ + arg!

Item was added:
+ ----- Method: VMMASTTranslationTest>>emptyBlockHasSingleNilStatement (in category 'generation-targets') -----
+ emptyBlockHasSingleNilStatement
+
+ [  ] value!

Item was added:
+ ----- Method: VMMASTTranslationTest>>inlineMethodWithLoop (in category 'generation-targets') -----
+ inlineMethodWithLoop
+
+ self methodWithLoop!

Item was added:
+ ----- Method: VMMASTTranslationTest>>inlineSecondLevelMethodWithLoop (in category 'generation-targets') -----
+ inlineSecondLevelMethodWithLoop
+
+ self inlineMethodWithLoop!

Item was added:
+ ----- Method: VMMASTTranslationTest>>inlineTwiceMethodWithLoop (in category 'generation-targets') -----
+ inlineTwiceMethodWithLoop
+
+ self methodWithLoop.
+ self methodWithLoop!

Item was added:
+ ----- Method: VMMASTTranslationTest>>inlineTwiceSecondLevelMethodWithLoop (in category 'generation-targets') -----
+ inlineTwiceSecondLevelMethodWithLoop
+
+ self inlineMethodWithLoop.
+ self inlineMethodWithLoop!

Item was added:
+ ----- Method: VMMASTTranslationTest>>methodWithArgument: (in category 'generation-targets') -----
+ methodWithArgument: anArgument!

Item was added:
+ ----- Method: VMMASTTranslationTest>>methodWithIfNil (in category 'generation-targets') -----
+ methodWithIfNil
+
+ self something
+ ifNil: [ 1 ]
+ ifNotNil: [ 2 ]!

Item was added:
+ ----- Method: VMMASTTranslationTest>>methodWithIfNilIfNotNil (in category 'generation-targets') -----
+ methodWithIfNilIfNotNil
+
+ self something
+ ifNil: [ 1 ]
+ ifNotNil: [ 2 ]
+ !

Item was added:
+ ----- Method: VMMASTTranslationTest>>methodWithIfNilIfNotNilWithArgument (in category 'generation-targets') -----
+ methodWithIfNilIfNotNilWithArgument
+
+ self something
+ ifNil: [ ]
+ ifNotNil: [ :soSomething | self lala: soSomething ]!

Item was added:
+ ----- Method: VMMASTTranslationTest>>methodWithIfNotNilIfNil (in category 'generation-targets') -----
+ methodWithIfNotNilIfNil
+
+ self something
+ ifNotNil: [ 1 ]
+ ifNil: [ 2 ]!

Item was added:
+ ----- Method: VMMASTTranslationTest>>methodWithIfNotNilIfNilWithArgument (in category 'generation-targets') -----
+ methodWithIfNotNilIfNilWithArgument
+
+ self something
+ ifNotNil: [ :soSomething | self lala: soSomething ]
+ ifNil: [ ]!

Item was added:
+ ----- Method: VMMASTTranslationTest>>methodWithIfNotNilWithArgument (in category 'generation-targets') -----
+ methodWithIfNotNilWithArgument
+
+ self something ifNotNil: [ :soSomething |
+ self lala: soSomething ]!

Item was added:
+ ----- Method: VMMASTTranslationTest>>methodWithLoop (in category 'generation-targets') -----
+ methodWithLoop
+
+ 1 to: 10 do: [ :i | self foo: i ]!

Item was added:
+ ----- Method: VMMASTTranslationTest>>methodWithNoArguments (in category 'generation-targets') -----
+ methodWithNoArguments!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testArgumentIsNoTemp (in category 'tests') -----
+ testArgumentIsNoTemp
+
+ | translation method |
+ method := (self class >> #methodWithArgument:).
+ translation := method asTranslationMethodOfClass: TMethod.
+
+ self deny: (translation locals includes: method methodNode arguments first name)!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testComplexIfNilIfNotNilWithArgument (in category 'tests') -----
+ testComplexIfNilIfNotNilWithArgument
+
+ | translation method codeGenerator assignment conditional condition |
+ method := (self class >> #methodWithIfNilIfNotNilWithArgument).
+ translation := method asTranslationMethodOfClass: TMethod.
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator addMethod: translation.
+ codeGenerator doInlining: true.
+
+ self assert: translation parseTree statements size equals: 3.
+ assignment := translation parseTree statements first.
+ self assert: assignment expression isSend.
+ self assert: assignment expression receiver name equals: 'self'.
+ self assert: assignment expression selector equals: #something.
+ self assert: assignment isAssignment.
+
+ conditional := translation parseTree statements second.
+ self assert: conditional isSend.
+ self assert: conditional selector equals: #ifTrue:ifFalse:.
+ self assert: conditional args first isStmtList.
+ self assert: conditional args second isStmtList.
+ self assert: conditional args first args isEmpty.
+ self assert: conditional args second args notEmpty.
+
+ condition := conditional receiver.
+ self assert: condition isSend.
+ self assert: condition selector equals: #==.
+ self assert: condition receiver name equals: conditional args second args first.
+ self assert: condition args first name equals: 'nil'.!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testComplexIfNotNilIfNilWithArgument (in category 'tests') -----
+ testComplexIfNotNilIfNilWithArgument
+
+ | translation method codeGenerator assignment conditional condition |
+ method := (self class >> #methodWithIfNilIfNotNilWithArgument).
+ translation := method asTranslationMethodOfClass: TMethod.
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator addMethod: translation.
+ codeGenerator doInlining: true.
+
+ self assert: translation parseTree statements size equals: 3.
+ assignment := translation parseTree statements first.
+ self assert: assignment expression isSend.
+ self assert: assignment expression receiver name equals: 'self'.
+ self assert: assignment expression selector equals: #something.
+ self assert: assignment isAssignment.
+
+ conditional := translation parseTree statements second.
+ self assert: conditional isSend.
+ self assert: conditional selector equals: #ifTrue:ifFalse:.
+ self assert: conditional args first isStmtList.
+ self assert: conditional args second isStmtList.
+ self assert: conditional args first args isEmpty.
+ self assert: conditional args second args notEmpty.
+
+ condition := conditional receiver.
+ self assert: condition isSend.
+ self assert: condition selector equals: #==.
+ self assert: condition receiver name equals: conditional args second args first.
+ self assert: condition args first name equals: 'nil'.!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testComplexIfNotNilWithArgument (in category 'tests') -----
+ testComplexIfNotNilWithArgument
+
+ | translation method codeGenerator assignment conditional condition |
+ method := (self class >> #methodWithIfNotNilWithArgument).
+ translation := method asTranslationMethodOfClass: TMethod.
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator addMethod: translation.
+ codeGenerator doInlining: true.
+
+ self assert: translation parseTree statements size equals: 3.
+ assignment := translation parseTree statements first.
+ self assert: assignment isAssignment.
+
+ conditional := translation parseTree statements second.
+ self assert: conditional isSend.
+ self assert: conditional selector equals: #ifFalse:.
+ self assert: conditional args first isStmtList.
+ self assert: conditional args first args notEmpty.
+
+ condition := conditional receiver.
+ self assert: condition isSend.
+ self assert: condition selector equals: #==.
+ self assert: condition receiver name equals: conditional args first args first.
+ self assert: condition args first name equals: 'nil'.!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testEmptyBlockGeneratesSingleNilStatement (in category 'tests') -----
+ testEmptyBlockGeneratesSingleNilStatement
+
+ | translation method codeGenerator block |
+ method := (self class >> #emptyBlockHasSingleNilStatement).
+ translation := method asTranslationMethodOfClass: TMethod.
+
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator addMethod: translation.
+ codeGenerator doInlining: true.
+
+ block := translation statements first receiver.
+ self assert: block statements size equals: 1.
+ self assert: block statements first name equals: 'nil'!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testIfNilIfNotNilBecomesIfTrueIfFalse (in category 'tests') -----
+ testIfNilIfNotNilBecomesIfTrueIfFalse
+
+ | translation |
+ translation := (self class >> #methodWithIfNil) asTranslationMethodOfClass: TMethod.
+
+ self assert: translation statements first selector equals: #ifTrue:ifFalse:!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testIfNilIfNotNilDoesNotInvertBlocks (in category 'tests') -----
+ testIfNilIfNotNilDoesNotInvertBlocks
+
+ | translation |
+ translation := (self class >> #methodWithIfNilIfNotNil) asTranslationMethodOfClass: TMethod.
+
+ self assert: translation statements first selector equals: #ifTrue:ifFalse:.
+ self assert: translation statements first args first statements first value equals: 1.
+ self assert: translation statements first args second statements first value equals: 2.!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testIfNotNilIfNilInversesBlocks (in category 'tests') -----
+ testIfNotNilIfNilInversesBlocks
+
+ | translation |
+ translation := (self class >> #methodWithIfNotNilIfNil) asTranslationMethodOfClass: TMethod.
+
+ self assert: translation statements first selector equals: #ifTrue:ifFalse:.
+ self assert: translation statements first args first statements first value equals: 2.
+ self assert: translation statements first args second statements first value equals: 1!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testInlineMethodWithLoopDeclaresLoopIndexVariable (in category 'tests') -----
+ testInlineMethodWithLoopDeclaresLoopIndexVariable
+
+ | translation codeGenerator inlinedMethod |
+ translation := (self class >> #inlineMethodWithLoop) asTranslationMethodOfClass: TMethod.
+ inlinedMethod := ((self class >> #methodWithLoop) asTranslationMethodOfClass: TMethod).
+
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator addMethod: translation.
+ codeGenerator addMethod: inlinedMethod.
+ codeGenerator doInlining: true.
+
+ self assert: (translation locals includesAll: inlinedMethod locals)!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testInlineSecondLevelMethodWithLoopDeclaresLoopIndexVariable (in category 'tests') -----
+ testInlineSecondLevelMethodWithLoopDeclaresLoopIndexVariable
+
+ | translation codeGenerator inlinedMethods |
+ translation := (self class >> #inlineSecondLevelMethodWithLoop) asTranslationMethodOfClass: TMethod.
+ inlinedMethods := #( inlineMethodWithLoop methodWithLoop ) collect: [ :s | ((self class >> s) asTranslationMethodOfClass: TMethod)].
+
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator addMethod: translation.
+ inlinedMethods do: [ :e |
+ codeGenerator addMethod: e ].
+ codeGenerator doInlining: true.
+
+ self assert: translation locals size equals: 1!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testInlineTwiceMethodWithLoopDeclaresTwiceLoopIndexVariable (in category 'tests') -----
+ testInlineTwiceMethodWithLoopDeclaresTwiceLoopIndexVariable
+
+ | translation codeGenerator inlinedMethod |
+ translation := (self class >> #inlineTwiceMethodWithLoop) asTranslationMethodOfClass: TMethod.
+ inlinedMethod := ((self class >> #methodWithLoop) asTranslationMethodOfClass: TMethod).
+
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator addMethod: translation.
+ codeGenerator addMethod: inlinedMethod.
+ codeGenerator doInlining: true.
+
+ self assert: translation locals size equals: 2!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testInlineTwiceSecondLevelMethodWithLoopDeclaresLoopIndexVariable (in category 'tests') -----
+ testInlineTwiceSecondLevelMethodWithLoopDeclaresLoopIndexVariable
+
+ | translation codeGenerator inlinedMethods |
+ translation := (self class >> #inlineTwiceSecondLevelMethodWithLoop) asTranslationMethodOfClass: TMethod.
+ inlinedMethods := #( inlineMethodWithLoop methodWithLoop ) collect: [ :s | ((self class >> s) asTranslationMethodOfClass: TMethod)].
+
+ codeGenerator := CCodeGeneratorGlobalStructure new.
+ codeGenerator addMethod: translation.
+ inlinedMethods do: [ :e |
+ codeGenerator addMethod: e ].
+ codeGenerator doInlining: true.
+
+ self assert: translation locals size equals: 2!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testKeywordMethodHasArgument (in category 'tests') -----
+ testKeywordMethodHasArgument
+
+ | translation method |
+ method := self class >> #methodWithArgument:.
+ translation := method asTranslationMethodOfClass: TMethod.
+
+ self assert: (translation args includes: method methodNode arguments first name)!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testMethodWithLoopDeclaresLoopIndexVariable (in category 'tests') -----
+ testMethodWithLoopDeclaresLoopIndexVariable
+
+ | translation method block |
+ method := self class >> #methodWithLoop.
+ translation := method asTranslationMethodOfClass: TMethod.
+
+ block := method methodNode statements first arguments second.
+ self deny: (translation locals includes: block arguments first)!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testTranslateBinaryMethodHasSameName (in category 'tests') -----
+ testTranslateBinaryMethodHasSameName
+
+ | translation |
+ translation := self class >> #+ asTranslationMethodOfClass: TMethod.
+
+ self assert: translation selector equals: #+.!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testTranslateKeywordMethodHasSameName (in category 'tests') -----
+ testTranslateKeywordMethodHasSameName
+
+ | translation method |
+ method := self class >> #methodWithArgument:.
+ translation := method asTranslationMethodOfClass: TMethod.
+
+ self assert: translation selector equals: method selector.!

Item was added:
+ ----- Method: VMMASTTranslationTest>>testTranslateUnaryMethodHasSameName (in category 'tests') -----
+ testTranslateUnaryMethodHasSameName
+
+ | translation method |
+ method := self class >> #methodWithNoArguments.
+ translation := method asTranslationMethodOfClass: TMethod.
+
+ self assert: translation selector equals: method selector.!