-
Notifications
You must be signed in to change notification settings - Fork 67
/
String.extension.st
36 lines (30 loc) · 1000 Bytes
/
String.extension.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Extension { #name : #String }
{ #category : #'*VMMaker-plugin generation' }
String class >> ccg: cg prolog: aBlock expr: aString index: anInteger [
^cg
ccgLoad: aBlock
expr: aString
asCharPtrFrom: anInteger
andThen: (cg ccgValBlock: 'isBytes')
]
{ #category : #'*VMMaker-plugin generation' }
String class >> ccgDeclareCForVar: aSymbolOrString [
^'char *', aSymbolOrString
]
{ #category : #'*VMMaker-translation support' }
String >> indexOfWord: aSubString [
^self indexOfWord: aSubString startingAt: 1
]
{ #category : #'*VMMaker-translation support' }
String >> indexOfWord: aSubString startingAt: startIndex [
| index |
index := startIndex.
[index <= self size] whileTrue:
[index := self indexOfSubCollection: aSubString startingAt: index ifAbsent: [^0].
((index = 1 or: [(self at: index - 1) isLetter not])
and: [index + aSubString size > self size
or: [(self at: index + aSubString size) isAlphaNumeric not]]) ifTrue:
[^index].
index := index + 1].
^0
]