Skip to content

Commit bfabc3f

Browse files
committed
stdlib: adapt to ref/own semantics
1 parent 85793d0 commit bfabc3f

12 files changed

Lines changed: 36 additions & 33 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export StandardOut: mut PrintStream = FileDescriptorPrintStream(FD_STDOUT)
1212
export StandardError: mut PrintStream = FileDescriptorPrintStream(FD_STDERR)
1313

1414
class FileDescriptorPrintStream : PrintStream {
15-
private fd: const S32 = init
15+
private fd: S32 = init
1616

1717
override fn put(self: mut _, str: String) {
1818
var bufToWrite: read Array<S8> = str.utf8Data
@@ -42,7 +42,7 @@ class FileDescriptorPrintStream : PrintStream {
4242
private intrinsic nothrow fn pureWrite(fd: S32, buf: COpaquePointer, count: UWord) -> SWord
4343

4444
private class WriteFailedException : IOException {
45-
errno: const S32 = init
45+
errno: S32 = init
4646

4747
constructor {
4848
mixin ThrowableTrait("write(2) failed, errno = " + self.errno.toString())

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,61 @@ 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+
58
class S8Box {
6-
value: const S8 = init
9+
ref value: const S8 = init
710
}
811

912
class U8Box {
10-
value: const U8 = init
13+
ref value: const U8 = init
1114
}
1215

1316
class S16Box {
14-
value: const S16 = init
17+
ref value: const S16 = init
1518
}
1619

1720
class U16Box {
18-
value: const U16 = init
21+
ref value: const U16 = init
1922
}
2023

2124
class S32Box {
22-
value: const S32 = init
25+
ref value: const S32 = init
2326
}
2427

2528
class U32Box {
26-
value: const U32 = init
29+
ref value: const U32 = init
2730
}
2831

2932
class S64Box {
30-
value: const S64 = init
33+
ref value: const S64 = init
3134
}
3235

3336
class U64Box {
34-
value: const U64 = init
37+
ref value: const U64 = init
3538
}
3639

3740
class F32Box {
38-
value: const F32 = init
41+
ref value: const F32 = init
3942
}
4043

4144
class F64Box {
42-
value: const F64 = init
45+
ref value: const F64 = init
4346
}
4447

4548
class SWordBox {
46-
value: const SWord = init
49+
ref value: const SWord = init
4750
}
4851

4952
class UWordBox {
50-
value: const UWord = init
53+
ref value: const UWord = init
5154
}
5255

5356
class BoolBox {
54-
value: const Bool = init
57+
ref value: const Bool = init
5558
}
5659

5760
class ReflectionBaseTypeBox {
58-
value: const ReflectionBaseType = init
61+
ref value: const ReflectionBaseType = init
5962
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,11 @@ mut fn printStackTraceToStandardError() -> Bool {
271271
// not used right now, but might come in handy when implementing actual unwinding/resume
272272

273273
private class UnwindProcedureInfo {
274-
private addressOfFirstInstruction: const UWord = init
275-
private addressBehindLastInstruction: const UWord = init
276-
private addressOfLanguageSpecificDataArea: const UWord = init
277-
private addressOfPersonalityFunction: const UWord = init
278-
private globalPointer: const UWord = init
274+
private addressOfFirstInstruction: UWord = init
275+
private addressBehindLastInstruction: UWord = init
276+
private addressOfLanguageSpecificDataArea: UWord = init
277+
private addressOfPersonalityFunction: UWord = init
278+
private globalPointer: UWord = init
279279

280280
private fn fromCursor(cursorPtr: read COpaquePointer) -> exclusive UnwindProcedureInfo {
281281
// there are additional members in the struct that are not mapped here

llvm-backend/src/main/kotlin/io/github/tmarsteel/emerge/backend/llvm/dsl/BasicBlockBuilder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ private open class BasicBlockBuilderImpl<C : LlvmContext, R : LlvmType>(
431431
}
432432
args.zip(function.type.parameterTypes).forEachIndexed { index, (arg, paramType) ->
433433
require(arg.isLlvmAssignableTo(paramType)) {
434-
"argument #$index to ${function.name}: ${arg.type} is not llvm-assignable to $paramType (${currentDebugLocation()}"
434+
"argument #$index to ${function.name}: ${arg.type} is not llvm-assignable to $paramType (${currentDebugLocation()})"
435435
}
436436
}
437437

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-
private _message: const String = init
4+
ref private _message: const 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
@@ -415,7 +415,7 @@ export class Bool {
415415
}
416416

417417
export class Array<Element> : Iterable<Element> {
418-
export size: const UWord = init
418+
export size: UWord = init
419419

420420
private constructor {}
421421

@@ -458,7 +458,7 @@ export class Array<Element> : Iterable<Element> {
458458
}
459459
460460
export class ArrayIndexOutOfBoundsError : Error {
461-
export invalidIndex: const UWord = init
461+
ref export invalidIndex: const UWord = init
462462
463463
export constructor {
464464
mixin ThrowableTrait(null)

stdlib/core/range/ArrayRange.em

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package emerge.core.range
33
import emerge.platform.panic
44

55
export class ArrayRange<Element> : SizedRange<Element> & RandomAccessRange<Element> & BidirectionalRange<Element> {
6-
array: read Array<Element> = init
6+
ref array: read Array<Element> = init
77
var frontIndex: UWord = 0
88
var backIndexPlus1: UWord = self.array.size
99

stdlib/core/reflection/ReflectionBaseType.em

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import emerge.core.safemath.plusModulo
66
// TODO: parameterize on type it is reflection on, like java.lang.Class<T> ?
77
export class ReflectionBaseType {
88
// points to all the DYNAMIC ReflectionBaseType infos, except Any
9-
private supertypes: const Array<ReflectionBaseType> = init
9+
ref private supertypes: const Array<ReflectionBaseType> = init
1010

11-
export canonicalName: const String = init
11+
export canonicalName: String = init
1212

1313
// for static typeinfos: points at the dynamic version; for dynamic ones: is null
1414
private dynamicInstance: ReflectionBaseType? = init

stdlib/core/throwable.em

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface Error : Throwable {}
2727
export class ThrowableTrait : Error {
2828
private _message: String? = init
2929

30-
private var _stackTrace: const Iterable<const StackTraceElement>? = null
30+
ref private var _stackTrace: const Iterable<const StackTraceElement>? = null
3131

3232
export override read fn fillStackTrace(self: mut _) {
3333
set self._stackTrace = self._stackTrace ?: collectStackTrace(3 as U32, false)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package emerge.core.unwind
22

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

0 commit comments

Comments
 (0)