From 076f87361dd4bb6fcafbe5468353dfa7804d3636 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 29 Sep 2024 20:19:46 -0400 Subject: Support using DateTime() as a constructor --- compile.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 328dfdf6..f1c27328 100644 --- a/compile.c +++ b/compile.c @@ -2967,6 +2967,11 @@ CORD compile(env_t *env, ast_t *ast) return compile_string_literal(Match(Match(call->args->value, TextJoin)->children->ast, TextLiteral)->cord); type_t *actual = get_type(env, call->args->value); return CORD_all("Text$as_c_string(", expr_as_text(env, compile(env, call->args->value), actual, "no"), ")"); + } else if (t->tag == DateTimeType) { + // DateTime constructor: + binding_t *new_binding = get_binding(Match(fn_t, TypeInfoType)->env, "new"); + CORD arg_code = compile_arguments(env, ast, Match(new_binding->type, FunctionType)->args, call->args); + return CORD_all(new_binding->code, "(", arg_code, ")"); } else { code_err(call->fn, "This is not a type that has a constructor"); } -- cgit v1.2.3