DEADSOFTWARE

Добавлен тип REAL
[dsw-obn.git] / generator.c
index 179320aef7df8ffb4cf1aa4a6ecc3b4df4250f17..d54bbfdb408ad0dc720b6095e7b99f8e878ac4a9 100644 (file)
@@ -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);