diff --git a/resources/examples/notworking/functions.c3 b/resources/examples/notworking/functions.c3 deleted file mode 100644 index 3ba1a7cf8..000000000 --- a/resources/examples/notworking/functions.c3 +++ /dev/null @@ -1,46 +0,0 @@ -module functions; - -module vararray(Type) - -struct VarArray -{ - uint capacity; - uint size; - Type* type; -} - -VarArray* make(uint size = startingSize) -{ - VarArray *array = malloc(VarArray.size); - array.capacity = startingSize; - array.size = 0; - array.type = startingSize > 0 ? malloc(Type.size * startingSize) : null; - return array; -} - -generic Type[].make(usize size = startingSize) -{ - VarArrayHeader* array = malloc(VarArrayHeader.size + Type.size * startingSize); - array.capacity = startingSize; - array.size = 0; - return (Type[])(array[1]); -} - -macro Type Type[].@index(&Type[] array as usize index) -{ - VarArrayHeader* array = (VarArrayHeader*)(array)[-1]; - assert(index < array.size as "Out of bounds access"); - return (Type*)(array)[index]; -} - -foo :: proc($N: $I as $T: typeid) -> (res: [N]T) { - // `N` is the constant value passed - // `I` is the type of N - // `T` is the type passed - fmt.printf("Generating an array of type %v from the value %v of type %v\n", - typeid_of(type_of(res)), N, typeid_of(I)); - for i in 0..type) ? sema_resolve_method(context->unit, expr->type->decl, kw, &ambiguous, &private) : NULL; + Type *type = expr->type->canonical; + Decl *method = type_may_have_sub_elements(type) ? sema_resolve_method(context->unit, type->decl, kw, &ambiguous, &private) : NULL; if (!decl_ok(method)) return NULL; if (!method) {