compiler/PPCCompilationOptions.st
changeset 538 16e8536f5cfb
parent 535 a8feb0f47574
equal deleted inserted replaced
537:fb212e14d1f4 538:16e8536f5cfb
     7 	classVariableNames:''
     7 	classVariableNames:''
     8 	poolDictionaries:''
     8 	poolDictionaries:''
     9 	category:'PetitCompiler-Core'
     9 	category:'PetitCompiler-Core'
    10 !
    10 !
    11 
    11 
    12 !PPCCompilationOptions class methodsFor:'as yet unclassified'!
    12 !PPCCompilationOptions class methodsFor:'instance creation'!
    13 
    13 
    14 default
    14 from: aCollection
    15     ^ self new
    15     "Initialized options from an array containing option: value pairs.
       
    16      Example:
       
    17 
       
    18          PPCCompilationOptions from: { #tokenize: true }
       
    19     "
       
    20     ^ self new initializeFrom: aCollection
       
    21 
       
    22     "
       
    23         PPCCompilationOptions from: #( tokenize: true )
       
    24     "
       
    25 
       
    26     "Created: / 07-09-2015 / 10:25:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    16 !
    27 !
    17 
    28 
    18 new
    29 new
    19     ^ self basicNew 
    30     "return an initialized instance"
    20         initialize;
    31 
    21         yourself
    32     ^ self basicNew initialize.
    22 ! !
    33 ! !
    23 
    34 
    24 !PPCCompilationOptions methodsFor:'initialization'!
    35 !PPCCompilationOptions methodsFor:'initialization'!
    25 
    36 
    26 initialize
    37 initialize
    27     super initialize.
    38     super initialize.
    28     options := IdentityDictionary new
    39     options := IdentityDictionary new
       
    40 !
       
    41 
       
    42 initializeFrom: aSequenceableCollection
       
    43     aSequenceableCollection size even ifFalse:[ 
       
    44         self error: 'Invalid options'
       
    45     ].
       
    46     1 to: aSequenceableCollection size by: 2 do:[:i |  
       
    47         | option value |
       
    48 
       
    49         option := aSequenceableCollection at: i.
       
    50         value  := aSequenceableCollection at: i + 1.
       
    51 
       
    52         [ 
       
    53             self perform: option asSymbol with: value
       
    54         ] on: MessageNotUnderstood do:[:ex |    
       
    55             self error: 'Invalid option: ', option storeString.
       
    56         ]
       
    57     ].
       
    58 
       
    59     "Created: / 07-09-2015 / 10:36:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    29 ! !
    60 ! !
    30 
    61 
    31 !PPCCompilationOptions methodsFor:'options'!
    62 !PPCCompilationOptions methodsFor:'options'!
    32 
    63 
    33 mode
    64 mode