LLVMStXMethod.st
changeset 4 d33c64726c86
child 5 3ac0c9381634
equal deleted inserted replaced
3:ddfc3a7db3a8 4:d33c64726c86
       
     1 "{ Package: 'jv:libllvms' }"
       
     2 
       
     3 "{ NameSpace: Smalltalk }"
       
     4 
       
     5 LLVMFunction subclass:#LLVMStXMethod
       
     6 	instanceVariableNames:''
       
     7 	classVariableNames:'SelectorSpecialCharMappingTable'
       
     8 	poolDictionaries:''
       
     9 	category:'LLVM-StX'
       
    10 !
       
    11 
       
    12 !LLVMStXMethod class methodsFor:'initialization'!
       
    13 
       
    14 initialize
       
    15     "Invoked at system start or when the class is dynamically loaded."
       
    16 
       
    17     "/ please change as required (and remove this comment)
       
    18 
       
    19     SelectorSpecialCharMappingTable := Dictionary withKeysAndValues:
       
    20                 #($+ 'pl'
       
    21                   $- 'mi'
       
    22                   $* 'mu'
       
    23                   $/ 'di'
       
    24                   $, 'co'
       
    25                   $@ 'at'
       
    26                   $< 'le'
       
    27                   $> 'gr'
       
    28                   $= 'eq'
       
    29                   $~ 'ne'
       
    30                   $| 'pi'
       
    31                   $\ 'mo'
       
    32                   $& 'am').
       
    33 
       
    34     "Modified: / 11-07-2015 / 09:24:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    35 ! !
       
    36 
       
    37 !LLVMStXMethod class methodsFor:'utilities'!
       
    38 
       
    39 llvmFunctionNameForClass: class selector: selector      
       
    40     "For given class name and selector, returns the name 
       
    41      used by LLVM"
       
    42 
       
    43     ^ String streamContents:[ :s|
       
    44         s nextPutAll: '__M_L_'.
       
    45         s nextPutAll: (class name copyReplaceAll: $: with: $_).
       
    46         s nextPut: $_.
       
    47         selector isBinarySelector ifTrue:[ 
       
    48             selector do:[:c |     
       
    49                 s nextPutAll: (SelectorSpecialCharMappingTable at: c)
       
    50             ].
       
    51         ] ifFalse:[ 
       
    52             selector do:[:c |  
       
    53                 c isAlphaNumeric ifTrue:[ 
       
    54                     s nextPut: c 
       
    55                 ] ifFalse:[
       
    56                     c == $: ifTrue:[ 
       
    57                         s nextPut: $_
       
    58                     ] ifFalse:[  
       
    59                         s nextPut: $_.
       
    60                         c codePoint printOn: s.
       
    61                     ]
       
    62                 ].
       
    63             ]
       
    64         ].
       
    65     ].
       
    66 
       
    67     "
       
    68     LLVMStXMethod llvmFunctionNameForClass: LLVMStXMethod selector: #llvmFunctionNameForClass:selector: 
       
    69     LLVMStXMethod llvmFunctionNameForClass: SmallInteger selector: #+
       
    70     LLVMStXMethod llvmFunctionNameForClass: Object selector: #~=
       
    71 
       
    72     "
       
    73 
       
    74     "Created: / 11-07-2015 / 09:26:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    75 ! !
       
    76 
       
    77 !LLVMStXMethod methodsFor:'accessing'!
       
    78 
       
    79 numArgs
       
    80     ^ super numArgs - 4
       
    81 
       
    82     "Created: / 11-07-2015 / 09:42:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    83 !
       
    84 
       
    85 parameterAt: index
       
    86     ^ super parameterAt: 4 + index.
       
    87 
       
    88     "Created: / 11-07-2015 / 09:39:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    89 ! !
       
    90 
       
    91 !LLVMStXMethod methodsFor:'initialization'!
       
    92 
       
    93 initialize
       
    94     super initialize.
       
    95 
       
    96     "Assign human readable names to parameters"
       
    97     (super parameterAt: 1) name: 'self'.
       
    98     (super parameterAt: 2) name: 'selector'.
       
    99     (super parameterAt: 3) name: 'searchClass'.
       
   100     (super parameterAt: 4) name: 'pIlc'.
       
   101     1 to: self numArgs do:[:numArg | 
       
   102         (super parameterAt: 4+numArg) name: 'marg', numArg printString.
       
   103     ].
       
   104 
       
   105     "Created: / 11-07-2015 / 09:41:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   106 ! !
       
   107 
       
   108 
       
   109 LLVMStXMethod initialize!