compose :: proc (a: $A, f: proc (A) -> $B, g: proc (B) -> $C) -> C do return g(f(a));
-specific_compose_0 :: #solidify compose { B = u32 };
+specific_compose_0 :: #solidify compose { B = f32 };
specific_compose_1 :: #solidify specific_compose_0 { A = f32 };
+specific_compose_2 :: #solidify specific_compose_1 { C = f64 };
main :: proc (args: [] cstr) {
printf("max(1, 2) = %i\n", math.max(1, 2));
// printf("max_f32(1, 2) = %i\n", max_f32(cast(u32) 1, cast(u32) 2));
- println(specific_compose_1(
+ println(specific_compose_2(
2,
- proc (a: f32) -> i32 { return ~~(a * 2); },
- proc (b: i32) -> i32 { return ~~(b + 6); }));
+ proc (a: f32) -> f32 { return ~~(a * 2); },
+ proc (b: f32) -> f64 { return ~~(b + 6); }));
}
\ No newline at end of file
#define REDUCE_BINOP_ALL(op) \
if (type_is_small_integer(res->type) || type_is_bool(res->type)) { \
res->value.i = left->value.i op right->value.i; \
- } else if (type_is_integer(res->type) || res->type->Basic.kind == Basic_Kind_Int_Unsized) { \
+ } else if (type_is_integer(res->type) \
+ || res->type->Basic.kind == Basic_Kind_Int_Unsized \
+ || res->type->kind == Type_Kind_Enum) { \
res->value.l = left->value.l op right->value.l; \
} else if (res->type->Basic.kind == Basic_Kind_F32) { \
res->value.f = left->value.f op right->value.f; \
#define REDUCE_BINOP_INT(op) \
if (type_is_small_integer(res->type) || type_is_bool(res->type)) { \
res->value.i = left->value.i op right->value.i; \
- } else if (type_is_integer(res->type) || res->type->Basic.kind == Basic_Kind_Int_Unsized) { \
+ } else if (type_is_integer(res->type) \
+ || res->type->Basic.kind == Basic_Kind_Int_Unsized \
+ || res->type->kind == Type_Kind_Enum) { \
res->value.l = left->value.l op right->value.l; \
} \
break;
case Ast_Kind_Binary_Op: return (AstTyped *) ast_reduce_binop(a, (AstBinaryOp *) node);
case Ast_Kind_Unary_Op: return (AstTyped *) ast_reduce_unaryop(a, (AstUnaryOp *) node);
case Ast_Kind_NumLit: return node;
- case Ast_Kind_Enum_Value: return (AstTyped *) ast_reduce(a, (AstTyped *) ((AstEnumValue *) node)->value);
+ case Ast_Kind_Enum_Value: return (AstTyped *) ((AstEnumValue *) node)->value;
default: return NULL;
}
}