extensions.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 08 Aug 2015 04:43:00 +0100
changeset 22 789a35bd30ac
parent 16 23e82cf19788
child 24 7e7ddd55174c
permissions -rw-r--r--
Added example for compiling conditional. Added convenience API to simply code generation.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
f98e97fd02ef Package renamed from jv:libllvms to jv:llvm_s
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
     1
"{ Package: 'jv:llvm_s' }"!
1
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
22
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
     3
!Object methodsFor:'converting'!
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
     4
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
     5
asLLVMValue
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
     6
    "Return representation of the receiver as LLVMValue."
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
     7
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
     8
    "Raise an error - arbitrary object cannot be represented
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
     9
     as LLVM value"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    10
    self error: 'cannot be converted to an LLVM value'
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    11
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    12
    "Created: / 08-08-2015 / 02:11:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    13
! !
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    14
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    15
!Object methodsFor:'converting'!
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    16
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    17
asLLVMValueOfType: anLLVMType
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    18
    "Return representation of the receiver as LLVMValue with given LLVMType. 
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    19
     If the object cannot be converted to the balue of requested type, 
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    20
     raise an error."
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    21
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    22
    self error: 'cannot be converted to an LLVM value'
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    23
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    24
    "Created: / 08-08-2015 / 02:27:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    25
! !
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    26
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    27
!Object methodsFor:'testing'!
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    28
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    29
isLLVMType
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    30
    "Return true, if receiver represents an LLVM type"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    31
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    32
    ^ false
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    33
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    34
    "Created: / 08-08-2015 / 02:45:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    35
! !
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    36
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    37
!Object methodsFor:'testing'!
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    38
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    39
isLLVMValue
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    40
    "Return true, if receiver represents an LLVM value"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    41
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    42
    ^ false
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    43
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    44
    "Created: / 08-08-2015 / 02:21:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    45
! !
789a35bd30ac Added example for compiling conditional. Added convenience API to simply code generation.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
    46
1
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
!SequenceableCollection methodsFor:'converting'!
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
asLLVMObjectArray
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
    | array size | 
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
    size := self size.
16
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    53
    size == 0 ifTrue:[ 
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    54
        ^ nil
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    55
    ].
1
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
    array := LLVMObjectArray new: size.
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
    array replaceFrom: 1 count: size with: self.
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
    ^array
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
    "Created: / 08-07-2015 / 22:58:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
16
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    61
    "Modified: / 03-08-2015 / 17:04:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    62
! !
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    63
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    64
!stx_goodies_sunit class methodsFor:'documentation'!
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    65
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    66
version_HG
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    67
    ^ '$Changeset: <not expanded> $'
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    68
! !
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    69
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    70
!stx_libbasic class methodsFor:'documentation'!
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    71
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    72
version_HG
23e82cf19788 Tests refactored to be actually a testcase. Introduced LLVMConstant class
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    73
    ^ '$Changeset: <not expanded> $'
1
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
! !
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
12
f98e97fd02ef Package renamed from jv:libllvms to jv:llvm_s
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
    76
!jv_llvm_s class methodsFor:'documentation'!
1
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
extensionsVersion_HG
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
    ^ '$Changeset: <not expanded> $'
e3dcb6272f0b Introduced abstract superclasses LLVMObject and LLVMDisposableObject
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
! !