summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 879793e)
raw | patch | inline | side by side (parent: 879793e)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 9 Aug 2017 17:17:37 +0000 (20:17 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 9 Aug 2017 17:17:37 +0000 (20:17 +0300) |
Test.obn | patch | blob | history | |
src/backends/jvm/generator-jvm.c | patch | blob | history | |
src/oberon-internals.h | patch | blob | history | |
src/oberon.c | patch | blob | history |
diff --git a/Test.obn b/Test.obn
index 0b020f71a79862e5a3510e07528b982ea6a21749..682b0a049b547a2b7d2497bb118f985e1492fafa 100644 (file)
--- a/Test.obn
+++ b/Test.obn
BEGIN
Out.Open;
- Out.String("Hello World!"); Out.Ln;
+ IF FALSE THEN
+ Out.String("Hello World!"); Out.Ln;
+ END;
System.Halt(1);
END Test.
index 1ec731f8eb37d275a3114ed050bbd262fd2a9615..065d9634c48a73b4b3900e63a17fd3e6f5a7ff6e 100644 (file)
}
break;
case MODE_INTEGER:
+ case MODE_BOOLEAN:
case MODE_CHAR:
case MODE_SET:
jvm_generate_push_int_size(p, item -> integer, item -> result -> size);
break;
- case MODE_BOOLEAN:
- jvm_generate_push_int_size(p, item -> boolean, item -> result -> size);
- break;
case MODE_CALL:
jvm_generate_call_proc(p, item);
break;
diff --git a/src/oberon-internals.h b/src/oberon-internals.h
index 3963146d4ee87f2d1cb65c0ecb807ffbde9f4e8d..fa9b5d5280903bf0ea16496170cb3e81fcb69045 100644 (file)
--- a/src/oberon-internals.h
+++ b/src/oberon-internals.h
enum oberon_mode_kind mode;
long integer;
double real;
- int boolean;
char * string;
oberon_object_t * var;
diff --git a/src/oberon.c b/src/oberon.c
index 064cfb10bd0b24955eb0b23655c12ee68d62cf52..f1fe4518a135c6e9369e877ac2c08d13575fb12a 100644 (file)
--- a/src/oberon.c
+++ b/src/oberon.c
BEGIN,
ASSIGN,
INTEGER,
- TRUE,
- FALSE,
LPAREN,
RPAREN,
EQUAL,
{
ctx -> token = BEGIN;
}
- else if(strcmp(ident, "TRUE") == 0)
- {
- ctx -> token = TRUE;
- }
- else if(strcmp(ident, "FALSE") == 0)
- {
- ctx -> token = FALSE;
- }
else if(strcmp(ident, "OR") == 0)
{
ctx -> token = OR;
@@ -1364,9 +1354,7 @@ oberon_make_call_proc(oberon_context_t * ctx, oberon_item_t * item, int num_args
|| ((x) == STRING) \
|| ((x) == NIL) \
|| ((x) == LPAREN) \
- || ((x) == NOT) \
- || ((x) == TRUE) \
- || ((x) == FALSE))
+ || ((x) == NOT))
static oberon_expr_t *
oberno_make_dereferencing(oberon_context_t * ctx, oberon_expr_t * expr)
return set;
}
+static oberon_expr_t *
+oberon_make_boolean(oberon_context_t * ctx, bool cond)
+{
+ oberon_expr_t * expr;
+ expr = oberon_new_item(MODE_BOOLEAN, ctx -> bool_type, true);
+ expr -> item.integer = cond;
+ return expr;
+}
+
static oberon_expr_t *
oberon_factor(oberon_context_t * ctx)
{
expr -> item.real = ctx -> real;
oberon_assert_token(ctx, REAL);
break;
- case TRUE:
- expr = oberon_new_item(MODE_BOOLEAN, ctx -> bool_type, true);
- expr -> item.boolean = true;
- oberon_assert_token(ctx, TRUE);
- break;
- case FALSE:
- expr = oberon_new_item(MODE_BOOLEAN, ctx -> bool_type, true);
- expr -> item.boolean = false;
- oberon_assert_token(ctx, FALSE);
- break;
case LBRACE:
expr = oberon_set(ctx);
break;
@@ -4038,6 +4025,15 @@ oberon_make_new_call(oberon_context_t * ctx, int num_args, oberon_expr_t * list_
oberon_assign(ctx, src, dst);
}
+static void
+oberon_new_const(oberon_context_t * ctx, char * name, oberon_expr_t * expr)
+{
+ oberon_object_t * constant;
+ constant = oberon_define_object(ctx -> decl, name, OBERON_CLASS_CONST, true, false, false);
+ oberon_check_const(ctx, expr);
+ constant -> value = (oberon_item_t *) expr;
+}
+
oberon_context_t *
oberon_create_context(ModuleImportCallback import_module)
{
register_default_types(ctx);
+ /* Constants */
+ oberon_new_const(ctx, "TRUE", oberon_make_boolean(ctx, true));
+ oberon_new_const(ctx, "FALSE", oberon_make_boolean(ctx, false));
+
/* Functions */
oberon_new_intrinsic(ctx, "ABS", oberon_make_abs_call, NULL);
oberon_new_intrinsic(ctx, "MIN", oberon_make_min_call, NULL);