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);
#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;
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;