X-Git-Url: http://deadsoftware.ru/gitweb?p=dsw-obn.git;a=blobdiff_plain;f=generator.c;h=d54bbfdb408ad0dc720b6095e7b99f8e878ac4a9;hp=179320aef7df8ffb4cf1aa4a6ecc3b4df4250f17;hb=ea5cf056abf2bf42e9f328b9c1f2d94ee96bcc4c;hpb=12ae486a18746b042fcc4ebbefc5449d4d3464af diff --git a/generator.c b/generator.c index 179320a..d54bbfd 100644 --- a/generator.c +++ b/generator.c @@ -99,7 +99,33 @@ oberon_generator_init_type(oberon_context_t * ctx, oberon_type_t * type) } else if(type -> class == OBERON_TYPE_BOOLEAN) { - gcc_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_BOOL); + if(type -> size == sizeof(bool)) + { + gcc_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_BOOL); + } + else + { + oberon_error(ctx, "generator: unsupported boolean size"); + } + } + else if(type -> class == OBERON_TYPE_REAL) + { + if(type -> size == sizeof(float)) + { + gcc_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_FLOAT); + } + else if(type -> size == sizeof(double)) + { + gcc_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_DOUBLE); + } + else if(type -> size == sizeof(long double)) + { + gcc_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_LONG_DOUBLE); + } + else + { + oberon_error(ctx, "generator: unsupported real size"); + } } else if(type -> class == OBERON_TYPE_ARRAY) { @@ -647,6 +673,11 @@ rvalue_from_item(oberon_context_t * ctx, oberon_item_t * item) right = gcc_jit_context_new_call_through_ptr(gcc_context, NULL, gcc_alloc, 1, &fnarg); right = gcc_jit_context_new_cast(gcc_context, NULL, right, result_type); } + else if(item -> mode == MODE_REAL) + { + gcc_jit_type * int_type = gcc_jit_context_get_type(gcc_context, GCC_JIT_TYPE_FLOAT); + right = gcc_jit_context_new_rvalue_from_int(gcc_context, int_type, item -> real); + } else { oberon_error(ctx, "rvalue_from_item: invalid mode %i", item -> mode);