diff --git a/projects/compiler/src/compiler.abra b/projects/compiler/src/compiler.abra index 157a2a70..1d00d95b 100644 --- a/projects/compiler/src/compiler.abra +++ b/projects/compiler/src/compiler.abra @@ -2531,6 +2531,8 @@ export type Compiler { curVal = try self._compileFunctionValue(label.position, fn, targetParamTypes, capturesMem, selfVal) } AccessorPathSegment.Field(label, ty, field, isOptSafe) => { + val selfInstType = try self._addResolvedGenericsLayerForInstanceMethod(instType, field.name.name, label.position) + var optSafeCtx: (Label, Value, QbeFunction, Label)? = None if isOptSafe { @@ -2614,6 +2616,8 @@ export type Compiler { val (_instTy, typeArgs) = try self._getInstanceTypeForType(ty) instTy = _instTy instType = Type(kind: TypeKind.Instance(instTy, typeArgs)) + + self._resolvedGenerics.popLayer() } } } @@ -3063,6 +3067,19 @@ export type Compiler { Ok(argVal) } + "uninitialized" => { + self._currentFn.block.addComment("begin uninitialized...") + + val innerTy = if self._resolvedGenerics.resolveGeneric("T") |ty| ty else unreachable("(uninitialized) could not resolve T for uninitialized()") + val innerTySize = try self._pointerSize(innerTy) + if innerTySize != QbeType.U64.size() unreachable("innerTySize != QbeType.U64.size()") + + val res = Value.Int(0) + + self._currentFn.block.addComment("...uninitialized end") + + Ok(res) + } "u64_to_string" => { self._currentFn.block.addComment("begin u64_to_string...") val _arg = if arguments[0] |arg| arg else unreachable("'u64_to_string' has 1 required argument") diff --git a/projects/std/src/_intrinsics.abra b/projects/std/src/_intrinsics.abra index 7ff98985..cbb4e576 100644 --- a/projects/std/src/_intrinsics.abra +++ b/projects/std/src/_intrinsics.abra @@ -16,6 +16,9 @@ export func moduleNames(): Pointer @Intrinsic("functionnames") export func functionNames(): Pointer +@Intrinsic("uninitialized") +export func uninitialized(): T + @Intrinsic("u64_to_string") export func u64ToString(i: Int): String