Skip to content

Commit 650ca3c

Browse files
committed
stdlib: utilize fixed mutability of core types
1 parent 179cfbd commit 650ca3c

8 files changed

Lines changed: 38 additions & 41 deletions

File tree

llvm-backend/src/main/emerge-platform-linux/boxes.em

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,58 @@ package emerge.platform
22

33
import emerge.core.reflection.ReflectionBaseType
44

5-
// TODO: change all builtin numeric-types and the boxes to be subtypes of const Any
6-
// TODO: change all boxes to use owned member vars
7-
8-
class S8Box {
9-
ref value: const S8 = init
5+
class S8Box : const Any {
6+
ref value: S8 = init
107
}
118

12-
class U8Box {
13-
ref value: const U8 = init
9+
class U8Box : const Any {
10+
ref value: U8 = init
1411
}
1512

16-
class S16Box {
17-
ref value: const S16 = init
13+
class S16Box : const Any {
14+
ref value: S16 = init
1815
}
1916

20-
class U16Box {
21-
ref value: const U16 = init
17+
class U16Box : const Any {
18+
ref value: U16 = init
2219
}
2320

24-
class S32Box {
25-
ref value: const S32 = init
21+
class S32Box : const Any {
22+
ref value: S32 = init
2623
}
2724

28-
class U32Box {
29-
ref value: const U32 = init
25+
class U32Box : const Any {
26+
ref value: U32 = init
3027
}
3128

32-
class S64Box {
33-
ref value: const S64 = init
29+
class S64Box : const Any {
30+
ref value: S64 = init
3431
}
3532

36-
class U64Box {
37-
ref value: const U64 = init
33+
class U64Box : const Any {
34+
ref value: U64 = init
3835
}
3936

40-
class F32Box {
41-
ref value: const F32 = init
37+
class F32Box : const Any {
38+
ref value: F32 = init
4239
}
4340

44-
class F64Box {
45-
ref value: const F64 = init
41+
class F64Box : const Any {
42+
ref value: F64 = init
4643
}
4744

48-
class SWordBox {
49-
ref value: const SWord = init
45+
class SWordBox : const Any {
46+
ref value: SWord = init
5047
}
5148

52-
class UWordBox {
53-
ref value: const UWord = init
49+
class UWordBox : const Any {
50+
ref value: UWord = init
5451
}
5552

56-
class BoolBox {
57-
ref value: const Bool = init
53+
class BoolBox : const Any {
54+
ref value: Bool = init
5855
}
5956

60-
class ReflectionBaseTypeBox {
61-
ref value: const ReflectionBaseType = init
57+
class ReflectionBaseTypeBox : const Any {
58+
ref value: ReflectionBaseType = init
6259
}

llvm-backend/src/main/emerge-platform-linux/unwind.em

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private read nothrow fn unwindCursorGetInstructionPointer(cursorPtr: COpaquePoin
178178
}
179179

180180
// returns the name of the function belonging to the stack frame this cursor is currently pointing at
181-
private read fn unwindCursorGetProcedureName(cursorPtr: COpaquePointer) -> const String {
181+
private read fn unwindCursorGetProcedureName(cursorPtr: COpaquePointer) -> String {
182182
var nameBuf = Array.new::<S8>(256, 0 as S8)
183183
offpBuf = Array.new::<UWord>(1, 0 as UWord)
184184

stdlib/core/ArithmeticError.em

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package emerge.core
22

33
export class ArithmeticError : Error {
4-
ref private _message: const String = init
4+
private _message: String = init
55

66
constructor {
77
mixin ThrowableTrait(self._message)

stdlib/core/intrinsic_types.em

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export class U64 : const Any & Printable {
306306
stream.put(self.toString(addMinusSign))
307307
}
308308

309-
private fn toString(self: U64, addMinusSign: Bool) -> const String {
309+
private fn toString(self: U64, addMinusSign: Bool) -> String {
310310
if self == 0 {
311311
return "0"
312312
}
@@ -458,7 +458,7 @@ export class Array<Element> : Iterable<Element> {
458458
}
459459
460460
export class ArrayIndexOutOfBoundsError : Error {
461-
ref export invalidIndex: const UWord = init
461+
export invalidIndex: UWord = init
462462
463463
export constructor {
464464
mixin ThrowableTrait(null)

stdlib/core/range/ArrayRange.em

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import emerge.platform.panic
55
export class ArrayRange<Element> : SizedRange<Element> & RandomAccessRange<Element> & BidirectionalRange<Element> {
66
// TODO: change this to owned once the compiler can handle it
77
ref array: read Array<Element> = init
8-
ref var frontIndex: UWord = 0
9-
ref var backIndexPlus1: UWord = self.array.size
8+
var frontIndex: UWord = 0
9+
var backIndexPlus1: UWord = self.array.size
1010

1111
export override get fn size(self) = self.backIndexPlus1 - self.frontIndex
1212

stdlib/core/string.em

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import emerge.core.safemath.plusModulo
44
import emerge.core.utf8.rejectInvalidUtf8
55

66
export class String : const Any {
7-
ref export utf8Data: const Array<S8> = init
7+
export utf8Data: const Array<S8> = init
88

99
export constructor {
1010
rejectInvalidUtf8(self.utf8Data)

stdlib/core/unwind/StackTraceElement.em

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ package emerge.core.unwind
22

33
export class StackTraceElement : const Any {
44
export address: UWord = init
5-
ref export procedureName: const String = init
5+
export procedureName: String = init
66
}

stdlib/std/collections/ArrayList.em

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export class ArrayList<X : Any> : Iterable<X> {
5050

5151
private class ArrayListRange<T : Any> : SizedRange<T> & RandomAccessRange<T> & BidirectionalRange<T> {
5252
ref list: read ArrayList<T> = init
53-
ref var frontIndex: UWord = 0
54-
ref var backIndexPlus1: UWord = self.list.size
53+
var frontIndex: UWord = 0
54+
var backIndexPlus1: UWord = self.list.size
5555

5656
override get fn size(self) = self.backIndexPlus1 - self.frontIndex
5757

0 commit comments

Comments
 (0)