pike.git / lib / modules / Tools.pmod / Standalone.pmod / precompile.pike

version» Context lines:

pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:530:    if (!args) return 0;    array(PikeType) a = ({});    foreach (args, PikeType arg)    if (arg->basetype() != "zero") a += ({arg});    if (!sizeof (a) && sizeof (args))    // Make sure we don't strip away the entire type.    a = ({args[0]});    return a;    }    +  protected void replace_names(array tok, mapping(string:string) names) +  { +  int scoped = 0; +  foreach(tok; int i; object(PC.Token)|array t) +  if (arrayp(t)) { +  replace_names(t, names); +  scoped = 0; +  } else if (((string)t) == "::" || ((string)t) == ".") +  scoped = 1; +  else if (scoped) +  scoped = 0; +  else if (names[(string)t]) +  t->text = names[(string)t]; +  } +     /*    * return the 'one-word' description of this type    */    string basetype()    {    string ret=(string)t;    switch(ret)    {    case "CTYPE":    return args[1]->basetype();
pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:1058:    /*    * Possible ways to initialize a PikeType:    * PikeType("array(array(int))")    * PikeType("CTYPE char *")    * PikeType( ({ PC.Token("array"), ({ PC.Token("("),PC.Token("int"),PC.Token(")"), }) }) )    *    * And this way is for internal use only:    * PikeType( PC.Token("array"), ({ PikeType("int") }) )    */    void create(string|array(PC.Token)|PC.Token|array(array) tok, -  void|array(PikeType) a) +  void|array(PikeType)|mapping(string:string) a)    {    switch(sprintf("%t",tok))    {    case "object":    t=tok;    args=a;    break;       case "string":    tok=convert_comments(PC.tokenize(split(tok),"piketype"));    tok=PC.group(PC.hide_whitespaces(tok));       case "array":    /* strip parenthesis */    while(sizeof(tok) == 1 && arrayp(tok[0]))    tok=tok[0][1..sizeof(tok[0])-2];    -  +  if (a) +  replace_names(tok, a); +     array(array(PC.Token|array(PC.Token|array))) tmp;    tmp=tok/({"|"});       if(sizeof(tmp) >1)    {    t=PC.Token("|");    args=map(tmp,PikeType);    return;    }   
pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:1371:    return _c_type = type()->c_storage_type();    }       string typename()    {    if(_typename) return _typename;    return _typename=    type()->copy_and_strip_type_assignments (1)->output_pike_type(0);    }    -  void create(array x) +  void create(array x, void|mapping(string:string) names)    {    PC.Token t;    if( arrayp(x[-1]) )    {    // Nameless argument prototype    t = x[0];    }    else    {    _name=(string)x[-1];    t = x[-1];    }    _file=t->file;    _line=t->line; -  _type=PikeType(x[..sizeof(x)-2]); +  _type=PikeType(x[..sizeof(x)-2], names);    }       string _sprintf(int how)    {    return type()->output_pike_type(0)+" "+name();    }   };      /*    * This function takes a bunch of strings an makes
pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:1881:   // Parses a block of cmod code, separating it into declarations,   // functions to add, exit functions and other code.   class ParseBlock   {    array code=({});    array addfuncs=({});    array exitfuncs=({});    array declarations=({});    int local_id = ++gid;    -  void create(array(array|PC.Token) x, string base, string class_name) +  void create(array(array|PC.Token) x, string base, string class_name, +  mapping(string:string) names)    {    array(array|PC.Token) ret=({});    array thestruct=({});       // FIXME: Consider generating code in the order it appears in    // the source file.    // /grubba 2004-12-10       string gc_live_obj_define = make_unique_name (base, "gc", "live", "obj");   
pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:1909:    switch((string)t) {    default:    ret += ({ t });    break;    case "extern":    ret += ({ t });       if ((e+2 < sizeof(x)) && (((string)x[e+1])[0] == '\"') &&    arrayp(x[e+2])) {    // C++ syntax support... -  create(x[e+2], base, class_name); +  create(x[e+2], base, class_name, names);    ret += ({ x[e+1], code });    code = ({});    e += 2;    }    break;    case "INHERIT":    {    int pos=search(x,PC.Token(";",0),e);       string p;
pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:2006:    PC.Token(" yyerror(\"Inherit failed.\");\n"    " }\n"    " } while(0);", x[e]->line),    });    if (api < 5) {    warn("%s:%d: API level 5 (or higher) is required "    "for inherit of strings.\n",    name->file, name->line);    }    } else if (name) { -  p = mkname((string)name, "program"); +  p = mkname(names[(string)name]||(string)name, "program");    }    addfuncs +=    IFDEF(define,    ({    PC.Token(    sprintf(" %s = Pike_compiler->new_program->"    "num_inherits;\n",    inh_num),    x[e]->line),    }) + pre + ({
pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:2057:    for(p=e+1;p<sizeof(x);p++)    if(arrayp(x[p]) && x[p][0]=="{")    break;       array proto = x[e+1..p-1];    array body = x[p];       string name=(string)proto[0];    string lname = mkname(base, name);    mapping attributes=parse_attributes(proto[1..]); -  +  names[name] = lname;    ParseBlock subclass = ParseBlock(body[1..sizeof(body)-2], -  mkname(base, name), name); +  mkname(base, name), name, +  copy_value(names));    string program_var = mkname(base, name, "program");       string define = make_unique_name("class", base, name, "defined");       ret+=DEFINE(define);    global_declarations +=    ({sprintf("DEFAULT_CMOD_STORAGE struct program *%s=NULL;\n",    program_var)});    global_declarations +=    IFDEF(program_var+"_fun_num_used",
pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:2144:    }));    e = p;    break;    }       case "PIKEVAR":    {    int pos = search(x, PC.Token(";",0), e);    int pos2 = parse_type(x, e+1);    mixed name = x[pos2]; -  PikeType type = PikeType(x[e+1..pos2-1]); +  PikeType type = PikeType(x[e+1..pos2-1], names);    string define = make_unique_name("var",name,base,"defined");    while( x[pos2+1] == "." )    {    name = (string)name + (string)x[pos2+1]+ (string)x[pos2+2];    pos2+=2;    }    mapping attributes = parse_attributes(x[pos2+1..pos]);   // werror("type: %O\n",type);    mixed csym = attributes->c_name || name;    if( !has_value( csym, "." ) )
pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:2398:       // Not all versions of Pike allow Token objects    // to be indexed.    catch {    foreach(Array.flatten(proto), string t)    if(has_prefix((string)t, "/*!"))    body = ({t})+body;    };       p=parse_type(proto,0); -  PikeType rettype=PikeType(proto[..p-1]); +  PikeType rettype=PikeType(proto[..p-1], names);       if(arrayp(proto[p]))    {    error("%s:%d: Missing type?\n",    proto[p][0]->file||"-",    proto[p][0]->line);    }    string location=proto[p]->file+":"+proto[p]->line;       string name="";
pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:2478:    if (!arrayp(last_arg[0]) && "..." == (string)last_arg[0]) {    ignore_more_args = 1;    args_tmp = args_tmp[..sizeof (args_tmp) - 2];    }    }    else    {    warn("%s:%s Failed to parse types\n", location,name);    }    } -  array(Argument) args=map(args_tmp,Argument); +  array(Argument) args=map(args_tmp,Argument,names);    // werror("%O %O\n",proto,args);    // werror("parsed args: %O\n", args);       if((<"`<", "`>", "`==", "_equal">)[name])    {    if(sizeof(args) != 1)    {    warn("%s must take one argument.\n");    }    if(sprintf("%s",args[0]->type()) != "mixed")
pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:2503:    }       // FIXME: support ... types    PikeType type;       if(attributes->rawtype)    type = CType(attributes->rawtype);    else if(attributes->type)    {    mixed err=catch { -  type=PikeType(attributes->type); +  type=PikeType(attributes->type, names);    };    if(err)    {    werror("%s: Something went wrong when parsing type: %s\n",    location,    attributes->type);    throw(err);    }    }else{    if(last_argument_repeats)
pike.git/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike:3295: Inside #if constant(Pike.__HAVE_CPP_PREFIX_SUPPORT__)
   })   #if constant(Pike.__HAVE_CPP_PREFIX_SUPPORT__)    + DEFINE("cmod___CMOD__", "1")   #endif    + x;      // werror("%O\n",x);       x = recursive(allocate_strings, x);    -  ParseBlock tmp=ParseBlock(x, base, ""); +  ParseBlock tmp=ParseBlock(x, base, "", ([]));       tmp->declarations += ({    "\n\n"    "#ifndef PIKE_UNUSED_ATTRIBUTE\n"    "#define PIKE_UNUSED_ATTRIBUTE\n"    "#endif\n"    "#define CMOD_MAP_PROGRAM_IDS_DEFINED 1\n"    "static int ___cmod_map_program_ids(int id) PIKE_UNUSED_ATTRIBUTE;\n"    "#ifndef TYPEOF\n"    "/* Compat with older Pikes. */\n"