Exemplo n.º 1
0
void dump_defmethod(struct id *name, struct component *c)
{
    if (!ModuleDumped) {
        dump_op(fop_IN_MODULE);
        dump_symbol(ModuleName);
        ModuleDumped = true;
    }

    dump_op(fop_DEFINE_METHOD);
    dump_symbol(name->symbol);
    dump_component(c);
}
Exemplo n.º 2
0
void dump_defgeneric(struct id *name, struct component *tlf)
{
    if (!ModuleDumped) {
        dump_op(fop_IN_MODULE);
        dump_symbol(ModuleName);
        ModuleDumped = true;
    }

    dump_op(fop_DEFINE_GENERIC);
    dump_symbol(name->symbol);
    dump_component(tlf);
}
Exemplo n.º 3
0
static void dump_vars(struct scope_info *scope)
{
    struct var_info *var_info;

    if (scope->handle != -1)
        dump_ref(scope->handle);
    else {
        scope->handle = dump_store();

        if (scope->outer)
            dump_op(fop_DOTTED_LIST1);
        else
            dump_op(fop_LIST1);

        dump_vector_header(scope->nvars);
        for (var_info=scope->vars; var_info != NULL; var_info=var_info->next) {
            int loc_info = var_info->offset << 2;
            if (var_info->indirect)
                loc_info |= 2;
            if (var_info->argument)
                loc_info |= 1;

            dump_op(fop_VECTOR2);
            dump_symbol(var_info->var->symbol);
            dump_integer(loc_info);
        }

        if (scope->outer)
            dump_vars(scope->outer);
    }
}
Exemplo n.º 4
0
static void dump_symboltable_rec (FILE* outfile, astree* root,
                             int depth) {
  if (root == NULL) return;
  //fprintf (outfile, "%*s%s ", depth * 3, "",
  //         root->lexinfo->c_str());
  dump_symbol (root, depth);
  fprintf (outfile, "\n");
  for (size_t child = 0; child < root->children.size();
      ++child) {
    //print after all children have 
    symbol_stack.push_back(nullptr);
    next_block++;
    //print here
    dump_symboltable_rec_helper(outfile, symbol_stack.back()); 
    //tabLinesSym.erase(tabLinesSym.end()-4,tabLinesSym.end());
    next_block--;
    symbol_stack.pop_back();
  }
  printf("TEST3\n");

  //type_check(root, *symbol_stack.back());
   printf("TEST4\n"); 
  dump_symboltable_rec_helper(outfile, symbol_stack.back());
  //tabLinesSym.erase(tabLinesSym.end()-4,tabLinesSym.end());
    printf("TEST5\n");

  next_block--;
  symbol_stack.pop_back();
    printf("TEST6\n");


   // dump_symboltable_rec (outfile, root->children[child],depth + 1);
  //delete root;

}
Exemplo n.º 5
0
static void dump_defconst_or_var(struct param_list *params)
{
    int count;
    struct param *p;

    count = 0;
    for (p = params->required_params; p != NULL; p = p->next)
        count++;
    if (params->rest_param)
        count++;

    dump_integer(count);
    for (p = params->required_params; p != NULL; p = p->next)
        dump_symbol(p->id->symbol);
    if (params->rest_param)
        dump_symbol(params->rest_param->symbol);
}
Exemplo n.º 6
0
void dump_setup_output(char *source, FILE *file)
{
    struct stat buf;
    time_t tv;
    int statres;

    File = file;

#if ! NO_SHARP_BANG
    fprintf(File, "#! /usr/bin/env mindy -x\n");
#endif
    fprintf(File, "# %s (%d.%d) of %s\n", "compilation",
            file_MajorVersion, file_MinorVersion, source);
    statres = stat(source, &buf);
    if (statres >= 0)
        fprintf(File, "# last modified on %s", ctime(&buf.st_mtime));
    fprintf(File, "# produced with the %s version of mindycomp\n", Version);
    time(&tv);
    fprintf(File, "# at %s", ctime(&tv));

    dump_op(fop_HEADER);
    dump_byte(file_MajorVersion);
    dump_byte(file_MinorVersion);
    dump_byte(sizeof(short));
    dump_byte(sizeof(int));
    dump_byte(sizeof(long));
    dump_byte(sizeof(float));
    dump_byte(sizeof(double));
    dump_byte(sizeof(long double));
    dump_short(1);
    dump_int(dbc_MagicNumber);
    dump_op(fop_IN_LIBRARY);
    if (LibraryName)
        dump_symbol(LibraryName);
    else
        dump_symbol(sym_DylanUser);
    if (source != NULL) {
        dump_op(fop_SOURCE_FILE);
        if (statres >= 0)
            dump_integer(buf.st_mtime);
        else
            dump_integer(0);
        dump_string_guts(fop_SHORT_STRING, fop_STRING, source, strlen(source));
    }
}
Exemplo n.º 7
0
void dump_top_level_form(struct component *c)
{
    if (!ModuleDumped) {
        dump_op(fop_IN_MODULE);
        dump_symbol(ModuleName);
        ModuleDumped = true;
    }

    dump_op(fop_TOP_LEVEL_FORM);
    dump_component(c);
}
Exemplo n.º 8
0
void dump_defvar(struct param_list *params, struct component *initializer)
{
    if (!ModuleDumped) {
        dump_op(fop_IN_MODULE);
        dump_symbol(ModuleName);
        ModuleDumped = true;
    }

    dump_op(fop_DEFINE_VARIABLE);
    dump_defconst_or_var(params);
    dump_component(initializer);
}
Exemplo n.º 9
0
void dump_defclass(struct id *name, struct slot_spec *slots,
                   struct component *tlf1, struct component *tlf2)
{
    struct slot_spec *slot;

    if (!ModuleDumped) {
        dump_op(fop_IN_MODULE);
        dump_symbol(ModuleName);
        ModuleDumped = true;
    }

    dump_op(fop_DEFINE_CLASS);
    dump_symbol(name->symbol);
    for (slot = slots; slot != NULL; slot = slot->next) {
        dump_symbol(slot->getter->symbol);
        if (slot->setter)
            dump_symbol(slot->setter->symbol);
    }
    dump_op(fop_FALSE);
    dump_component(tlf1);
    dump_component(tlf2);
}
Exemplo n.º 10
0
static void dump_method(struct method *method)
{
    struct param_list *params = method->params;
    struct keyword_param *k;
    int param_info, nkeys;
    int nclosure_vars;
    struct closes_over *over;

    if (params->rest_param)
        param_info = 1;
    else
        param_info = 0;
    if (params->all_keys)
        param_info |= 2;
    if (params->allow_keys) {
        nkeys = 0;
        for (k = params->keyword_params; k != NULL; k = k->next)
            nkeys++;
        param_info = param_info | (nkeys+1)<<2;
    }

    nclosure_vars = 0;
    for (over = method->closes_over; over != NULL; over = over->next)
        nclosure_vars++;

    if (param_info < 256 && nclosure_vars < 256) {
        dump_op(fop_SHORT_METHOD);
        dump_byte(param_info);
        dump_byte(nclosure_vars);
    }
    else {
        dump_op(fop_METHOD);
        dump_int(param_info);
        dump_int(nclosure_vars);
    }

    for (k = params->keyword_params; k != NULL; k = k->next) {
        struct literal_expr *def = (struct literal_expr *)k->def;
        dump_symbol(k->keyword);
        if (def) {
            if (def->kind != expr_LITERAL)
                lose("non-literal keyword default made it though expand?");
            dump_literal(def->lit);
        }
        else
            dump_op(fop_FALSE);
    }

    dump_component(method->component);
}
Exemplo n.º 11
0
static void dump_param_list(struct param_list *params)
{
    struct param *p;
    int nparams = 0;

    for (p = params->required_params; p != NULL; p = p->next)
        nparams++;
    dump_integer(nparams);
    for (p = params->required_params; p != NULL; p = p->next) {
        dump_id(p->id);
        if (p->type)
            dump_expr(p->type);
        else
            dump_op(fop_FALSE);
    }

    if (params->next_param)
        dump_id(params->next_param);
    else
        dump_op(fop_FALSE);

    if (params->rest_param)
        dump_id(params->rest_param);
    else
        dump_op(fop_FALSE);

    if (params->allow_keys) {
        struct keyword_param *k;
        int nkeys = 0;

        for (k = params->keyword_params; k != NULL; k = k->next)
            nkeys++;
        dump_integer(nkeys);

        for (k = params->keyword_params; k != NULL; k = k->next) {
            dump_symbol(k->keyword);
            dump_id(k->id);
            if (k->type)
                dump_expr(k->type);
            else
                dump_op(fop_FALSE);
            if (k->def)
                dump_expr(k->def);
            else
                dump_op(fop_FALSE);
        }
    }
    else
        dump_op(fop_FALSE);
}
Exemplo n.º 12
0
static void dump_plist(struct plist *plist)
{
    if (plist) {
        struct property *p;
        int nprops = 0;

        for (p = plist->head; p != NULL; p = p->next)
            nprops++;
        dump_integer(nprops);
        for (p = plist->head; p != NULL; p = p->next) {
            dump_symbol(p->keyword);
            dump_expr(p->expr);
        }
    }
    else
        dump_integer(0);
}
Exemplo n.º 13
0
static void dump_varref(struct id *id, bool written)
{
    if (id->line) {
        dump_op(fop_NOTE_REFERENCE);
        dump_int(id->line);
    }

    if (id->internal)
        if (written)
            dump_op(fop_BUILTIN_WRITABLE_VALUE_CELL);
        else
            dump_op(fop_BUILTIN_VALUE_CELL);
    else
        if (written)
            dump_op(fop_WRITABLE_VALUE_CELL);
        else
            dump_op(fop_VALUE_CELL);

    dump_symbol(id->symbol);
}
Exemplo n.º 14
0
void dump_symbol_tables ( void ) {
  unsigned char i;
  sb_symbol_node_t *n;

  printf ( "Scope depth: %d\n", g_sb_scopemax_highest );

  for ( i = 0; i <= g_sb_scopemax_highest; i++ ) {

    printf ( "Symbol table %d\n", i );
    n = g_sb_symbolstack [ i ];

    g_sb_indent += 2;

    dump_symbol ( n );

    g_sb_indent -= 2;
    printf ( "End table %d\n", i );

  } // for

} // dump_tables
Exemplo n.º 15
0
static void dump_symbol_literal(struct symbol_literal *literal)
{
    dump_symbol(literal->symbol);
}
Exemplo n.º 16
0
static void dump_defclass_constituent(struct defclass_constituent *c)
{
    struct superclass *super;
    struct slot_spec *slot;
    struct initarg_spec *initarg;
    struct inherited_spec *inherited;
    int n;

    dump_op(fop_DEFINE_CLASS);

    n = 0;
    for (super = c->supers; super != NULL; super = super->next)
        n++;
    dump_integer(n);
    for (super = c->supers; super != NULL; super = super->next)
        dump_expr(super->expr);

    n = 0;
    for (slot = c->slots; slot != NULL; slot = slot->next)
        n++;
    dump_integer(n);
    for (slot = c->slots; slot != NULL; slot = slot->next) {
        switch (slot->alloc) {
          case alloc_INSTANCE:
            dump_symbol(sym_Instance);
            break;
          case alloc_CLASS:
            dump_symbol(sym_Class);
            break;
          case alloc_EACH_SUBCLASS:
            dump_symbol(sym_Each_Subclass);
            break;
          case alloc_VIRTUAL:
            dump_symbol(sym_Virtual);
            break;
          default:
            lose("strange slot allocation");
        }
        if (slot->name)
            dump_id(slot->name);
        else
            dump_op(fop_FALSE);
        if (slot->type)
            dump_expr(slot->type);
        else
            dump_op(fop_FALSE);
        dump_plist(slot->plist);
    }

    n = 0;
    for (initarg = c->initargs; initarg != NULL; initarg = initarg->next)
        n++;
    dump_integer(n);
    for (initarg = c->initargs; initarg != NULL; initarg = initarg->next) {
        dump_symbol(initarg->keyword);
        dump_plist(initarg->plist);
    }

    n = 0;
    for (inherited = c->inheriteds; inherited != NULL;
         inherited = inherited->next)
        n++;
    dump_integer(n);
    for (inherited = c->inheriteds; inherited != NULL;
         inherited = inherited->next) {
        dump_id(inherited->name);
        dump_plist(inherited->plist);
    }
}
Exemplo n.º 17
0
static void dump_id(struct id *id)
{
    dump_symbol(id->symbol);
    dump_op(id->internal ? fop_TRUE : fop_FALSE);
    dump_integer(id->line);
}