Changeset aa4d31 in git for ppcc/src/parser.cc


Ignore:
Timestamp:
Feb 7, 2019, 1:18:27 PM (5 years ago)
Author:
Reimer Behrends <behrends@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
098784114c00a08a4d18cf392c0f2411aa0d007ed669f7b103e531e130535f2141dd1d77cfa31a81
Parents:
54b24c79febc0e79ee3f9c6a86b7c4d505c69a43
Message:
parallel preprocessor-related fixes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ppcc/src/parser.cc

    r54b24c raa4d31  
    11#include "adlib/lib.h"
    22#include "adlib/map.h"
     3#include "adlib/set.h"
    34#include "pplex.h"
    45
     
    1819static Dict *class_vars;
    1920static Dict *class_types;
     21static StrSet *type_prefix_set;
     22static Dict *namespaced;
    2023
    2124enum DeclType {
     
    3740  GCVar(class_vars, new Dict());
    3841  GCVar(class_types, new Dict());
     42  GCVar(type_prefix_set, new StrSet());
     43  type_prefix_set->add(S("class"));
     44  type_prefix_set->add(S("struct"));
     45  type_prefix_set->add(S("typedef"));
     46  // special treatment for some gfanlib variables for now.
     47  GCVar(namespaced, new Dict());
     48  namespaced->add(S("MVMachineIntegerOverflow"), S("gfan"));
     49  namespaced->add(S("lpSolver"), S("gfan"));
    3950});
    4051
     
    244255  }
    245256  if ((is_class && !is_extern) || init_start >= 0) {
    246     if (is_toplevel)
     257    if (is_toplevel) {
    247258      init_list->add(var_name);
     259    }
    248260    Token var_init = Token(SymGen, var_name->clone()->add("__INIT__"));
    249261    parser->emit(static_token);
     
    262274      parser->init_count++;
    263275      parser->emit(Token(SymGen, S(
    264         "static pSingular_register_init_var(void *, void *, long);"
     276        "void pSingular_register_init_var(void *, void *, long);"
    265277        "class %s__CONSTR__ {\n"
    266         "  %s__CONSTR__() {\n"
     278        "  public: %s__CONSTR__() {\n"
    267279        "    pSingular_register_init_var(&%s, &%s__INIT__, sizeof(%s));\n"
    268280        "  }\n"
     
    281293    Token &token = output->at(i);
    282294    if (token.sym == SymIdent && class_vars->contains(token.str)) {
    283       token.str = class_vars->at(token.str);
     295      Int j = i-1;
     296      while (j >= 0 && TEST(SymsWS | BIT(SymAst), output->at(j).sym))
     297        j--;
     298      if (j < 0 || !type_prefix_set->contains(output->at(j).str))
     299        token.str = class_vars->at(token.str);
    284300    }
    285301  }
     
    318334    if (class_vars->contains(var_name)) {
    319335      Str *type = class_types->at(var_name);
     336      if (namespaced->contains(var_name)) {
     337        type = namespaced->at(var_name)->clone()->add("::")->add(type);
     338        var_name = namespaced->at(var_name)->clone()->add("::")->add(var_name);
     339      }
    320340      init_part->add(S(
    321341        "  %s = (%c *)pSingular_alloc_var((long)sizeof(%c));\n"
     
    374394    Int var_pos = -1, var_start = -1, var_end = -1;
    375395    var_start = parser->current_pos();
    376     parser->skip_while(SymsTypePrefix | BIT(SymWS));
     396    parser->skip_while(SymsTypePrefix | BIT(SymWS) | BIT(SymClass));
    377397    if (TEST(SymsEndDecl | BIT(SymLBrkt), parser->current_sym())) {
    378398      // We are one symbol past the initial variable identifier.
     
    481501        if (toplevel->len() > 0)
    482502          toplevel->pop();
     503        tl = 0;
    483504        parser->advance();
    484505        break;
Note: See TracChangeset for help on using the changeset viewer.