summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9531d39)
raw | patch | inline | side by side (parent: 9531d39)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 17 Aug 2017 12:19:36 +0000 (15:19 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 17 Aug 2017 12:19:36 +0000 (15:19 +0300) |
diff --git a/Test.obn b/Test.obn
index c039f87259a54823da72904d8cacb593996e0b7c..69389899cad06413cb1824a0829eef066767864d 100644 (file)
--- a/Test.obn
+++ b/Test.obn
MODULE Test;
-VAR
- x : PROCEDURE(i : INTEGER);
+TYPE
+ File* = POINTER TO Handle;
-PROCEDURE X(a : INTEGER);
-END X;
+ Handle = RECORD END;
+ Rider* = RECORD
+ eof* : BOOLEAN;
+ res* : LONGINT;
+ END;
+
+PROCEDURE Old*(name : ARRAY OF CHAR) : File;
+BEGIN
+ RETURN NIL
+END Old;
+
+PROCEDURE New*(name : ARRAY OF CHAR) : File;
BEGIN
- x := X;
+ RETURN NIL
+END New;
+
END Test.
index 71ec669ef5ea5c935cc40c1546383407d7a2ec6e..3db7888cfe034e8b6d9a561489d8c581d380e4cb 100644 (file)
--- a/notes
+++ b/notes
-- Нет счёта строк / столбцов
-
- Сделать проверку повторов в CASE.
- Сделать нормальную проверку наличия RETURN.
- Нет процедур привязанных к типм
- Примеры -5 DIV 3 и -5 MOD 3 работают не так как в (8.2.2)
Нужен другой тип округления?
+- Нет счёта строк / столбцов (хрен с ними - у меня есть утилита tail!)
- Нет модуля SYSTEM (на жабе он особо и не нужен)
- Нужны средства создания биндингов. На данный момент реализуемо как пустые модули.
- Любая ошибка фатальна
index 1d634a5ea0ddfcbaad19f707f4521202389ebec6..2889ae3c718437b3220ae308ba0e446a9fec55bc 100644 (file)
case JVM_STORAGE_FRAME_VAR:
case JVM_STORAGE_FRAME_PARAM:
case JVM_STORAGE_FRAME_PARAM_VAR:
- jvm_generate(p, 0, 0, ".var %i is %s %s from start to end", reg, name, desc);
+ jvm_generate(p, 0, 0, ".var %i is '%s' %s from start to end", reg, name, desc);
break;
case JVM_STORAGE_REGISTER_VAR:
- jvm_generate(p, 0, 0, ".var %i is %s [%s from start to end", reg, name, desc);
+ jvm_generate(p, 0, 0, ".var %i is '%s' [%s from start to end", reg, name, desc);
break;
case JVM_STORAGE_PARAM_VARPTR:
case JVM_STORAGE_FRAME_PARAM_VARPTR:
- jvm_generate(p, 0, 0, ".var %i is %s [%s from start to end", reg, name, desc);
- jvm_generate(p, 0, 0, ".var %i is %s$offset I from start to end", reg + 1, name);
+ jvm_generate(p, 0, 0, ".var %i is '%s' [%s from start to end", reg, name, desc);
+ jvm_generate(p, 0, 0, ".var %i is '%s$offset' I from start to end", reg + 1, name);
break;
case JVM_STORAGE_STATIC:
- fprintf(v -> class -> fp, ".field public static %s %s\n\n", name, desc);
+ fprintf(v -> class -> fp, ".field public static '%s' %s\n\n", name, desc);
break;
case JVM_STORAGE_STATIC_VAR:
- fprintf(v -> class -> fp, ".field public static %s [%s\n\n", name, desc);
+ fprintf(v -> class -> fp, ".field public static '%s' [%s\n\n", name, desc);
break;
case JVM_STORAGE_FIELD:
- fprintf(v -> class -> fp, ".field public %s %s\n\n", name, desc);
+ fprintf(v -> class -> fp, ".field public '%s' %s\n\n", name, desc);
break;
case JVM_STORAGE_FIELD_VAR:
- fprintf(v -> class -> fp, ".field public %s [%s\n\n", name, desc);
+ fprintf(v -> class -> fp, ".field public '%s' [%s\n\n", name, desc);
break;
default:
gen_error("jvm_generate_var: invalid storage %i", storage);
|| v -> storage == JVM_STORAGE_FRAME_PARAM)
{
fprintf(fp, "; LEVEL %i\n", v -> level);
- fprintf(fp, ".field public %s %s\n\n", v -> name, v -> type -> desc);
+ fprintf(fp, ".field public '%s' %s\n\n", v -> name, v -> type -> desc);
}
else if(v -> storage == JVM_STORAGE_FRAME_VAR
|| v -> storage == JVM_STORAGE_FRAME_PARAM_VAR)
{
fprintf(fp, "; LEVEL %i\n", v -> level);
- fprintf(fp, ".field public %s [%s\n\n", v -> name, v -> type -> desc);
+ fprintf(fp, ".field public '%s' [%s\n\n", v -> name, v -> type -> desc);
}
else if(v -> storage == JVM_STORAGE_FRAME_PARAM_VARPTR)
{
fprintf(fp, "; LEVEL %i\n", v -> level);
- fprintf(fp, ".field public %s [%s\n", v -> name, v -> type -> desc);
- fprintf(fp, ".field public %s$offset I\n\n", v -> name);
+ fprintf(fp, ".field public '%s' [%s\n", v -> name, v -> type -> desc);
+ fprintf(fp, ".field public '%s$offset' I\n\n", v -> name);
}
}
var = var -> next;
v = jvm_create_function_var(p, JVM_STORAGE_REGISTER, "$FP$", t);
p -> frame_v = v;
- printf("jvm_generate_procedure_frame: %p level %i\n", p -> reg_frame, p -> level);
p -> reg_frame[p -> level] = v -> reg;
}
prc = prc -> parent;
}
+ size_t sz = sizeof(*p -> reg_frame) * max_frames;
p -> max_frames = max_frames;
- p -> reg_frame = GC_MALLOC(sizeof *p -> reg_frame);
- memset(p -> reg_frame, 0, max_frames * sizeof *p -> reg_frame);
+ p -> reg_frame = GC_MALLOC(sz);
+ memset(p -> reg_frame, 0, sz);
p -> level = max_frames - 1;
jvm_create_staticlinks_recursive(p, proc -> parent, p -> level);
index 9c8b78c598e73aaacc9644309c4e5a654146ad44..27f1c56390802b409621ef18779d6781c6f10595 100644 (file)
int num = type -> num_decl;
oberon_object_t * arg = type -> decl;
+
for(int i = 0; i < num; i++)
{
desc = jvm_get_descriptor_safe(arg -> type);
index e897f6e98cb64913f5e58b9612ad8be3e7ef1c9c..24268e178a7474cf893ec5836b437fedc6197bcf 100644 (file)
case OBERON_CLASS_VAR_PARAM:
case OBERON_CLASS_PARAM:
case OBERON_CLASS_VAR:
- jvm_generate_var(v);
jvm_generate_var_initialization(p, v);
break;
case OBERON_CLASS_PROC:
diff --git a/src/oberon.c b/src/oberon.c
index 3b8a6b14846e593d9bbaf7b31385993475362a8c..0fff8d7ba4c791846d662f1a6e728c6b2fbfe883 100644 (file)
--- a/src/oberon.c
+++ b/src/oberon.c
#include <math.h>
#include <float.h>
+#include <gc.h>
+
#include "../include/oberon.h"
#include "oberon-internals.h"
static oberon_type_t *
oberon_new_type_ptr(int class)
{
- oberon_type_t * x = malloc(sizeof *x);
+ oberon_type_t * x = GC_MALLOC(sizeof *x);
memset(x, 0, sizeof *x);
x -> class = class;
return x;
oberon_new_operator(int op, oberon_type_t * result, oberon_expr_t * left, oberon_expr_t * right)
{
oberon_oper_t * operator;
- operator = malloc(sizeof *operator);
+ operator = GC_MALLOC(sizeof *operator);
memset(operator, 0, sizeof *operator);
operator -> is_item = 0;
oberon_new_item(int mode, oberon_type_t * result, int read_only)
{
oberon_item_t * item;
- item = malloc(sizeof *item);
+ item = GC_MALLOC(sizeof *item);
memset(item, 0, sizeof *item);
item -> is_item = 1;
static oberon_scope_t *
oberon_open_scope(oberon_context_t * ctx)
{
- oberon_scope_t * scope = calloc(1, sizeof *scope);
- oberon_object_t * list = calloc(1, sizeof *list);
+ oberon_scope_t * scope = GC_MALLOC(sizeof *scope);
+ memset(scope, 0, sizeof *scope);
+
+ oberon_object_t * list = GC_MALLOC(sizeof *list);
+ memset(list, 0, sizeof *list);
scope -> ctx = ctx;
scope -> list = list;
static oberon_object_t *
oberon_create_object(oberon_scope_t * scope, char * name, int class, bool export, bool read_only)
{
- oberon_object_t * newvar = malloc(sizeof *newvar);
+ oberon_object_t * newvar = GC_MALLOC(sizeof *newvar);
memset(newvar, 0, sizeof *newvar);
newvar -> name = name;
newvar -> class = class;
c = ctx -> code[i];
}
- char * ident = malloc(len + 1);
+ char * ident = GC_MALLOC(len + 1);
memcpy(ident, &ctx->code[ctx->code_index], len);
ident[len] = 0;
}
int len = end_i - start_i;
- ident = malloc(len + 1);
+ ident = GC_MALLOC(len + 1);
memcpy(ident, &ctx -> code[start_i], len);
ident[len] = 0;
oberon_get_char(ctx);
- char * string = calloc(1, end - start + 1);
+ char * string = GC_MALLOC(end - start + 1);
strncpy(string, &ctx -> code[start], end - start);
+ string[end] = 0;
ctx -> token = STRING;
ctx -> string = string;
@@ -4524,7 +4530,8 @@ oberon_new_intrinsic(oberon_context_t * ctx, char * name, GenerateFuncCallback f
oberon_context_t *
oberon_create_context(ModuleImportCallback import_module)
{
- oberon_context_t * ctx = calloc(1, sizeof *ctx);
+ oberon_context_t * ctx = GC_MALLOC(sizeof *ctx);
+ memset(ctx, 0, sizeof *ctx);
oberon_scope_t * world_scope;
world_scope = oberon_open_scope(ctx);
oberon_destroy_context(oberon_context_t * ctx)
{
oberon_generator_destroy_context(ctx);
- free(ctx);
}
oberon_module_t *
module_scope = oberon_open_scope(ctx);
oberon_module_t * module;
- module = calloc(1, sizeof *module);
+ module = GC_MALLOC(sizeof *module);
+ memset(module, 0, sizeof *module);
module -> decl = module_scope;
module -> next = ctx -> module_list;