-Any :: struct {
+any :: struct {
data: rawptr;
type: type_expr;
}
- match: '\b(package|struct|use|global|enum|if|elseif|else|for|while|do|break|continue|fallthrough|return|as|cast|sizeof|alignof|defer|switch|case)\b'
scope: keyword.control.onyx
- - match: '\b(bool|void|i8|u8|i16|u16|i32|u32|i64|u64|f32|f64|rawptr|str|cstr|range|type_expr)\b'
+ - match: '\b(bool|void|i8|u8|i16|u16|i32|u32|i64|u64|f32|f64|rawptr|str|cstr|range|type_expr|any)\b'
scope: storage.type
- match: '\b(i8x16|i16x8|i32x4|i64x2|f32x4|f64x2|v128)\b'
syn keyword onyxType rawptr
syn keyword onyxType str cstr
syn keyword onyxType i8x16 i16x8 i32x4 i64x2 f32x4 f64x2 v128
-syn keyword onyxType type_expr
+syn keyword onyxType type_expr any
syn keyword onyxConstant true false null null_proc
return s, .None;
}
+//
+// This could be changed to use the "any" type now, which would allow for any type to be
+// represented as a json value. However, this eliminates the control that you get from
+// this way.
+//
encode :: #match {
(w: ^io.Writer, v: i32) -> Encoding_Error {
io.write_i32(w, ~~v);
}
}
+ if (to->kind == Type_Kind_Slice && from->kind == Type_Kind_VarArgs) {
+ if (!types_are_compatible(to->Slice.ptr_to_data->Pointer.elem, from->VarArgs.ptr_to_data->Pointer.elem)) {
+ *err_msg = "Variadic argument to slice cast is not valid here because the types are different.";
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+
if (from->kind == Type_Kind_Slice || to->kind == Type_Kind_Slice) {
*err_msg = "Cannot cast to or from a slice.";
return 0;
assert(condition_value->kind == Ast_Kind_NumLit); // This should be right, right?
return condition_value->value.i != 0;
-}
\ No newline at end of file
+}
return;
}
- builtin_any_type = (AstType *) symbol_raw_resolve(p->scope, "Any");
+ builtin_any_type = (AstType *) symbol_raw_resolve(p->scope, "any");
if (builtin_any_type == NULL) {
- onyx_report_error((OnyxFilePos) { 0 }, "'Any' struct not found in builtin package.");
+ onyx_report_error((OnyxFilePos) { 0 }, "'any' struct not found in builtin package.");
return;
}
return;
}
+ if (to->kind == Type_Kind_Slice && from->kind == Type_Kind_VarArgs) {
+ // Nothing needs to be done because they are identical
+ return;
+ }
+
i32 fromidx = -1, toidx = -1;
if (from->Basic.flags & Basic_Flag_Pointer || from->kind == Type_Kind_Array) {
fromidx = 10;