Procedure literals for default values in structs

This commit is contained in:
Ginger Bill
2017-10-01 20:01:00 +01:00
parent c1e720a49b
commit 8f39ebbe5a
7 changed files with 202 additions and 95 deletions

View File

@@ -22,6 +22,7 @@ enum ExactValueKind {
ExactValue_Complex,
ExactValue_Pointer,
ExactValue_Compound, // TODO(bill): Is this good enough?
ExactValue_Procedure, // TODO(bill): Is this good enough?
ExactValue_Type,
ExactValue_Count,
@@ -37,6 +38,7 @@ struct ExactValue {
i64 value_pointer;
Complex128 value_complex;
AstNode * value_compound;
AstNode * value_procedure;
Type * value_type;
};
};
@@ -109,6 +111,12 @@ ExactValue exact_value_type(Type *type) {
return result;
}
ExactValue exact_value_procedure(AstNode *node) {
ExactValue result = {ExactValue_Procedure};
result.value_procedure = node;
return result;
}
ExactValue exact_value_integer_from_string(String string) {
return exact_value_u128(u128_from_string(string));