author | Jan Vrany <jan.vrany@labware.com> |
Wed, 22 Mar 2023 13:57:18 +0000 | |
branch | jv |
changeset 25445 | 1623217d2268 |
parent 25420 | a18d0d048b1f |
permissions | -rw-r--r-- |
12469 | 1 |
" |
2 |
COPYRIGHT (c) 2009 by eXept Software AG |
|
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
3 |
All Rights Reserved |
12469 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
12 |
"{ Package: 'stx:libbasic' }" |
12456 | 13 |
|
17374 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
12456 | 16 |
ByteArray variableByteSubclass:#ImmutableByteArray |
17 |
instanceVariableNames:'' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'System-Compiler-Support' |
|
21 |
! |
|
22 |
||
12465 | 23 |
!ImmutableByteArray class methodsFor:'documentation'! |
24 |
||
12469 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 2009 by eXept Software AG |
|
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
28 |
All Rights Reserved |
12469 | 29 |
|
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
12465 | 39 |
documentation |
40 |
" |
|
41 |
By default, byte array literals in smalltalk are mutable objects. That |
|
42 |
may lead to some subtle (and hard to find errors), if some method passes |
|
43 |
a literal byte-array object as argument to someone else, who changes the |
|
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
44 |
bytearray using at:put: like messages. Since the bytearray object is kept in |
12465 | 45 |
the first methods literals, the bytearray constant has now been changed without |
46 |
having the method's sourcecode reflect this. Thus, the method will |
|
47 |
behave differently from what its source may make you think. |
|
48 |
||
49 |
To help finding this kind of 'feature/bug', the compiler can be |
|
50 |
configured to create instances of this ImmutableByteArray instead of ByteArrays |
|
51 |
for literals. Instances of ImmutableByteArray catch storing accesses and |
|
52 |
enter the debugger. Although useful, this feature is disabled by default |
|
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
53 |
for compatibility to other smalltalk implementations. |
12465 | 54 |
(Also, if turned on, this makes inspecting bytearray literals entered in |
55 |
a workspace somewhat strange: you cannot modify it any longer). |
|
56 |
||
57 |
Turn the ImmutableArray feature on, by setting the Parser's class variable |
|
58 |
'ArraysAreImmutable' to true or use the new launchers settings menu. |
|
59 |
||
18545 | 60 |
This class should be used only by the compiler. |
61 |
||
12472 | 62 |
ATTENTION: |
14223 | 63 |
there may be still code around which checks for explicit class being ByteArray |
64 |
(both in Smalltalk and in primitive code). All code like foo 'class == ByteArray' |
|
65 |
or '__isByteArray()' will not work with ImmutableByteArrays - consider using '__isByteArrayLike()'. |
|
66 |
A somewhat better approach would be to either add a flag to the object (mutability) |
|
67 |
and check this dynamically (expensive) or to place immutable objects into a readonly |
|
68 |
memory segment (the good solution). We will eventually implement the second in the future... |
|
12472 | 69 |
|
12465 | 70 |
[see also:] |
14223 | 71 |
ImmutableString |
72 |
ImmutableArray |
|
73 |
Parser Scanner |
|
12465 | 74 |
|
75 |
[author:] |
|
14223 | 76 |
Claus Gittinger |
12465 | 77 |
" |
78 |
! ! |
|
12456 | 79 |
|
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
80 |
!ImmutableByteArray class methodsFor:'instance creation'! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
81 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
82 |
fromPackedString:aString |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
83 |
^ (ByteArray fromPackedString:aString) beImmutable. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
84 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
85 |
"Created: / 15-03-2017 / 17:55:57 / stefan" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
86 |
! ! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
87 |
|
17374 | 88 |
!ImmutableByteArray class methodsFor:'queries'! |
89 |
||
90 |
mutableClass |
|
91 |
"answer an equivalent mustable class" |
|
92 |
||
93 |
^ ByteArray |
|
94 |
! ! |
|
95 |
||
96 |
!ImmutableByteArray class methodsFor:'testing'! |
|
97 |
||
98 |
hasImmutableInstances |
|
99 |
^ true |
|
100 |
! ! |
|
101 |
||
12456 | 102 |
!ImmutableByteArray methodsFor:'accessing'! |
103 |
||
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
104 |
at:index put:value |
12456 | 105 |
"Trigger an error if an immutable bytearray is stored into. |
106 |
The store will be performed (for compatibility reasons) if you continue |
|
19421 | 107 |
in the debugger (or proceed in an exception handler)." |
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
108 |
|
12493 | 109 |
self noModificationError. |
12456 | 110 |
^ super at:index put:value |
111 |
! |
|
112 |
||
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
113 |
basicAt:index put:value |
12456 | 114 |
"Trigger an error if an immutable bytearray is stored into. |
115 |
The store will be performed (for compatibility reasons) if you continue |
|
19421 | 116 |
in the debugger (or proceed in an exception handler)." |
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
117 |
|
12493 | 118 |
self noModificationError. |
12456 | 119 |
^ super basicAt:index put:value |
19421 | 120 |
! |
121 |
||
122 |
byteAt:index put:value |
|
123 |
"Trigger an error if an immutable bytearray is stored into. |
|
124 |
The store will be performed (for compatibility reasons) if you continue |
|
125 |
in the debugger (or proceed in an exception handler)." |
|
126 |
||
127 |
self noModificationError. |
|
128 |
^ super byteAt:index put:value |
|
129 |
! |
|
130 |
||
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
131 |
doubleAt:index put:anInteger |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
132 |
"Trigger an error if an immutable bytearray is stored into. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
133 |
The store will be performed (for compatibility reasons) if you continue |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
134 |
in the debugger (or proceed in an exception handler)." |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
135 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
136 |
self noModificationError. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
137 |
^ super doubleAt:index put:anInteger |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
138 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
139 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
140 |
doubleAt:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
141 |
"Trigger an error if an immutable bytearray is stored into. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
142 |
The store will be performed (for compatibility reasons) if you continue |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
143 |
in the debugger (or proceed in an exception handler)." |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
144 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
145 |
self noModificationError. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
146 |
^ super doubleAt:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
147 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
148 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
149 |
floatAt:index put:anInteger |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
150 |
"Trigger an error if an immutable bytearray is stored into. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
151 |
The store will be performed (for compatibility reasons) if you continue |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
152 |
in the debugger (or proceed in an exception handler)." |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
153 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
154 |
self noModificationError. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
155 |
^ super floatAt:index put:anInteger |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
156 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
157 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
158 |
floatAt:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
159 |
"Trigger an error if an immutable bytearray is stored into. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
160 |
The store will be performed (for compatibility reasons) if you continue |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
161 |
in the debugger (or proceed in an exception handler)." |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
162 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
163 |
self noModificationError. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
164 |
^ super floatAt:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
165 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
166 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
167 |
signedInt128At:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
168 |
"Trigger an error if an immutable bytearray is stored into. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
169 |
The store will be performed (for compatibility reasons) if you continue |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
170 |
in the debugger (or proceed in an exception handler)." |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
171 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
172 |
self noModificationError. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
173 |
^ super signedInt128At:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
174 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
175 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
176 |
signedInt16At:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
177 |
"Trigger an error if an immutable bytearray is stored into. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
178 |
The store will be performed (for compatibility reasons) if you continue |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
179 |
in the debugger (or proceed in an exception handler)." |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
180 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
181 |
self noModificationError. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
182 |
^ super signedInt16At:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
183 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
184 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
185 |
signedInt32At:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
186 |
"Trigger an error if an immutable bytearray is stored into. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
187 |
The store will be performed (for compatibility reasons) if you continue |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
188 |
in the debugger (or proceed in an exception handler)." |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
189 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
190 |
self noModificationError. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
191 |
^ super signedInt32At:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
192 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
193 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
194 |
signedInt64At:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
195 |
"Trigger an error if an immutable bytearray is stored into. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
196 |
The store will be performed (for compatibility reasons) if you continue |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
197 |
in the debugger (or proceed in an exception handler)." |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
198 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
199 |
self noModificationError. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
200 |
^ super signedInt64At:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
201 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
202 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
203 |
unsignedInt128At:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
204 |
"Trigger an error if an immutable bytearray is stored into. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
205 |
The store will be performed (for compatibility reasons) if you continue |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
206 |
in the debugger (or proceed in an exception handler)." |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
207 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
208 |
self noModificationError. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
209 |
^ super unsignedInt128At:index put:anInteger MSB:msb |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
210 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
211 |
|
19421 | 212 |
unsignedInt16At:index put:anInteger |
213 |
"Trigger an error if an immutable bytearray is stored into. |
|
214 |
The store will be performed (for compatibility reasons) if you continue |
|
215 |
in the debugger (or proceed in an exception handler)." |
|
216 |
||
217 |
self noModificationError. |
|
218 |
^ super unsignedInt16At:index put:anInteger |
|
219 |
! |
|
220 |
||
221 |
unsignedInt16At:index put:anInteger MSB:msb |
|
222 |
"Trigger an error if an immutable bytearray is stored into. |
|
223 |
The store will be performed (for compatibility reasons) if you continue |
|
224 |
in the debugger (or proceed in an exception handler)." |
|
225 |
||
226 |
self noModificationError. |
|
227 |
^ super unsignedInt16At:index put:anInteger MSB:msb |
|
228 |
! |
|
229 |
||
230 |
unsignedInt32At:index put:anInteger |
|
231 |
"Trigger an error if an immutable bytearray is stored into. |
|
232 |
The store will be performed (for compatibility reasons) if you continue |
|
233 |
in the debugger (or proceed in an exception handler)." |
|
234 |
||
235 |
self noModificationError. |
|
236 |
^ super unsignedInt32At:index put:anInteger |
|
237 |
! |
|
238 |
||
239 |
unsignedInt32At:index put:anInteger MSB:msb |
|
240 |
"Trigger an error if an immutable bytearray is stored into. |
|
241 |
The store will be performed (for compatibility reasons) if you continue |
|
242 |
in the debugger (or proceed in an exception handler)." |
|
243 |
||
244 |
self noModificationError. |
|
245 |
^ super unsignedInt32At:index put:anInteger MSB:msb |
|
246 |
! |
|
247 |
||
248 |
unsignedInt64At:index put:anInteger |
|
249 |
"Trigger an error if an immutable bytearray is stored into. |
|
250 |
The store will be performed (for compatibility reasons) if you continue |
|
251 |
in the debugger (or proceed in an exception handler)." |
|
252 |
||
253 |
self noModificationError. |
|
254 |
^ super unsignedInt64At:index put:anInteger |
|
255 |
! |
|
256 |
||
257 |
unsignedInt64At:index put:anInteger MSB:msb |
|
258 |
"Trigger an error if an immutable bytearray is stored into. |
|
259 |
The store will be performed (for compatibility reasons) if you continue |
|
260 |
in the debugger (or proceed in an exception handler)." |
|
261 |
||
262 |
self noModificationError. |
|
263 |
^ super unsignedInt64At:index put:anInteger MSB:msb |
|
12456 | 264 |
! ! |
265 |
||
266 |
!ImmutableByteArray methodsFor:'converting'! |
|
267 |
||
12488 | 268 |
asByteArray |
269 |
"return the receiver as a (mutable) byteArray" |
|
270 |
||
19421 | 271 |
^ self shallowCopy |
12488 | 272 |
|
273 |
" |
|
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
274 |
#[1 2 3 4] asImmutableByteArray asByteArray |
12488 | 275 |
" |
276 |
! |
|
277 |
||
12456 | 278 |
asImmutableByteArray |
19421 | 279 |
"that's what I am-" |
280 |
||
12456 | 281 |
^ self |
16823 | 282 |
! |
283 |
||
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
284 |
asImmutableCollection |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
285 |
^ self |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
286 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
287 |
"Created: / 15-03-2019 / 13:53:07 / Stefan Vogel" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
288 |
! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
289 |
|
16823 | 290 |
asMutableCollection |
291 |
"return a writable copy of myself" |
|
292 |
||
19421 | 293 |
^ self shallowCopy |
19175 | 294 |
! |
295 |
||
296 |
beImmutable |
|
297 |
"that's what I am" |
|
298 |
||
299 |
^ self |
|
300 |
! |
|
301 |
||
20524 | 302 |
beMutable |
303 |
"you never go back" |
|
304 |
||
305 |
^ self shouldNotImplement |
|
306 |
! |
|
307 |
||
19175 | 308 |
beUnsigned |
309 |
"that's what I am-" |
|
310 |
||
311 |
^ self. |
|
312 |
||
313 |
" |
|
314 |
#[1 2 3 128 255] asImmutableByteArray beUnsigned |
|
315 |
" |
|
12456 | 316 |
! ! |
317 |
||
318 |
!ImmutableByteArray methodsFor:'copying'! |
|
319 |
||
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
320 |
shallowCopy |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
321 |
"when copying, return a real (mutable) ByteArray" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
322 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
323 |
|sz| |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
324 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
325 |
sz := self size. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
326 |
^ (ByteArray new:sz) replaceBytesFrom:1 to:sz with:self startingAt:1 |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
327 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
328 |
" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
329 |
#[1 2 3 4] asImmutableByteArray shallowCopy |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
330 |
" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
331 |
! ! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
332 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
333 |
!ImmutableByteArray methodsFor:'copying-private'! |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
334 |
|
12456 | 335 |
postCopy |
336 |
"when copied, make me a real (mutable) ByteArray" |
|
337 |
||
338 |
self changeClassTo:ByteArray. |
|
339 |
! |
|
340 |
||
341 |
postDeepCopy |
|
342 |
"when copied, make me a real (mutable) ByteArray" |
|
343 |
||
344 |
self changeClassTo:ByteArray. |
|
345 |
||
346 |
" |
|
347 |
#[1 2 3 4] asImmutableByteArray copy class |
|
348 |
#[1 2 3 4] asImmutableByteArray shallowCopy class |
|
349 |
#[1 2 3 4] asImmutableByteArray deepCopy class |
|
350 |
" |
|
351 |
! ! |
|
352 |
||
16749 | 353 |
!ImmutableByteArray methodsFor:'printing & storing'! |
354 |
||
355 |
displayOn:aGCOrStream |
|
17536 | 356 |
"/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
357 |
"/ old ST80 means: draw-yourself on a GC. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
358 |
aGCOrStream isStream ifFalse:[ |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
359 |
^ super displayOn:aGCOrStream. |
16749 | 360 |
]. |
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
361 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
362 |
self storeOn:aGCOrStream. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
363 |
self size > 0 ifTrue:[ |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
364 |
aGCOrStream nextPutAll:' "immutable"'. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
365 |
]. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
366 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
367 |
"Modified (format): / 22-02-2017 / 16:58:38 / cg" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
368 |
"Modified: / 21-07-2019 / 08:31:13 / Claus Gittinger" |
16749 | 369 |
! ! |
370 |
||
12456 | 371 |
!ImmutableByteArray methodsFor:'private'! |
372 |
||
373 |
species |
|
374 |
"Copies should be mutable" |
|
375 |
||
376 |
^ ByteArray |
|
16399 | 377 |
! |
378 |
||
379 |
speciesForCopy |
|
380 |
"Copies should be mutable" |
|
381 |
||
382 |
^ ByteArray |
|
12456 | 383 |
! ! |
384 |
||
385 |
!ImmutableByteArray methodsFor:'queries'! |
|
386 |
||
14388 | 387 |
isImmutable |
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
388 |
"return true, if the receiver is immutable. |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
389 |
Since I am an immutable byte array, return always true here" |
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
390 |
|
14388 | 391 |
^ true |
25420
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
392 |
|
a18d0d048b1f
Cherry-picked changes from eXept, part 4
Jan Vrany <jan.vrany@labware.com>
parents:
23547
diff
changeset
|
393 |
"Modified (comment): / 09-06-2019 / 14:54:36 / Claus Gittinger" |
14388 | 394 |
! |
395 |
||
12456 | 396 |
isLiteral |
397 |
"return true, if the receiver can be used as a literal constant in ST syntax |
|
398 |
(i.e. can be used in constant arrays)" |
|
399 |
||
400 |
"yes, I must be" |
|
401 |
^ true |
|
402 |
||
403 |
! ! |
|
404 |
||
405 |
!ImmutableByteArray methodsFor:'specials'! |
|
406 |
||
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
407 |
become:anotherObject |
12456 | 408 |
"trigger an error if I should become something else |
409 |
(this would be an even more tricky manipulation)" |
|
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
410 |
|
12493 | 411 |
self noModificationError. |
12456 | 412 |
^ super become:anotherObject |
413 |
! |
|
414 |
||
415 |
becomeNil |
|
416 |
"trigger an error if I should become nil |
|
417 |
(this would be an even more tricky manipulation)" |
|
12538
e6bf8c42e1d4
Moved to libbasic from libcomp - change package name
Stefan Vogel <sv@exept.de>
parents:
12493
diff
changeset
|
418 |
|
12493 | 419 |
self noModificationError. |
12456 | 420 |
^ super becomeNil |
18703 | 421 |
! |
422 |
||
423 |
becomeSameAs:anotherObject |
|
424 |
"trigger an error if I should become something else |
|
425 |
(this would be an even more tricky manipulation)" |
|
426 |
||
427 |
self noModificationError. |
|
428 |
^ super becomeSameAs:anotherObject |
|
12456 | 429 |
! ! |
430 |
||
431 |
!ImmutableByteArray class methodsFor:'documentation'! |
|
432 |
||
433 |
version_CVS |
|
18545 | 434 |
^ '$Header$' |
12456 | 435 |
! ! |
16399 | 436 |