void JObjectStreamField::setTypeString(){ if (isPrimitive()){ typeString=new JString(""); }else{ typeString=new JString(signature); } }
AST::TYPE::TYPE(std::string ID, std::vector< boost::shared_ptr<TYPE> > types) { _id = ID; // int, bool and string are keywords, so ignore types if (!isPrimitive()) { _types = types; } }
void CJString:: print(std::ostream &os) const { if (! isPrimitive()) os << "[String: '" << encodeText() << "']"; else os << "'" << encodeText() << "'"; }
LISP_DATA* eval(LISP_DATA* exp, LISP_DATA* env) { printf("eval: "); printLispData(exp); printf("\n"); if (exp->type == LIST) { if (!exp->data.list) return exp; LISP_DATA* car = exp->data.list->head; if (isPrimitive(car)) { return apply(car, evlist(exp->data.list->tail, env)); } else if (car->type == SYMBOL && !stricmp(car->data.symbol, "define")) { LISP_DATA_LIST* toBind = exp->data.list->tail->head->data.list; env = bindIdentifier(env, toBind->head, eval(toBind->tail->head, env)); return 0; } else if (car->type == SYMBOL && !stricmp(car->data.symbol, "let")) { LISP_DATA_LIST* toBind = exp->data.list->tail->head->data.list; env = bindIdentifier(env, toBind->head, eval(toBind->tail->head, env)); LISP_DATA* body = eval(exp->data.list->tail->tail->head, env); env = popBinding(env); return body; } else if (car->type == SYMBOL && !stricmp(car->data.symbol, "lambda")) { return makeClosure(exp->data.list->tail, env); } else { return apply(eval(car, env), evlist(exp->data.list->tail, env)); } } if (exp->type == SYMBOL) { return lookup(exp, env); } if (exp->type == QUOTED) { return exp->data.quoted; } return exp; }
bool addrDesc::verify(nmethod* m) { bool flag = true; if (offset() >= m->instsLen() + m->scopes->length()) { error1("bad offset in addrDesc at %#lx", (long)this); flag = false; } if (isSendDesc()) { flag = asSendDesc(m)->verify() && flag; } else if (isDIDesc()) { flag = asDIDesc(m)->dependency()->verify_list_integrity() && flag; } else if (isPrimitive()) ; else flag = oop(referent(m))->verify_oop() && flag; inst_t* instp = (inst_t*)addr(m); return flag; }
Def* IdentityAnalyzer::do_toprimitive(UnaryStmt* instr) { if (isPrimitive(type(instr->value_in()))) return identity(instr); return def_; }
LISP_DATA* apply(LISP_DATA* proc, LISP_DATA_LIST* args) { printf("apply: "); printLispData(proc); printf(" to "); LISP_DATA* wrappedArgs = (LISP_DATA*)malloc(sizeof(LISP_DATA)); wrappedArgs->type = LIST; wrappedArgs->data.list = args; printLispData(wrappedArgs); printf("\n"); if (proc->type == LIST && proc->data.list->head->type == SYMBOL && !stricmp(proc->data.list->head->data.symbol, "closure")) { LISP_DATA_LIST* nameToBind = proc->data.list->tail->head->data.list->head->data.list; LISP_DATA_LIST* valueToBind = args; LISP_DATA* env = proc->data.list->tail->tail->head; LISP_DATA* body = proc->data.list->tail->head->data.list->tail->head; while (nameToBind) { env = bindIdentifier(env, nameToBind->head, valueToBind->head); nameToBind = nameToBind->tail; valueToBind = valueToBind->tail; } return eval(body, env); } if (isPrimitive(proc)) { LISP_DATA* newNumber = (LISP_DATA*)malloc(sizeof(LISP_DATA)); newNumber->type = NUMERIC; LISP_DATA_LIST* arg = args; switch (proc->data.symbol[0]) { case '+': newNumber->data.numeric = 0; while (arg) { newNumber->data.numeric += arg->head->data.numeric; arg = arg->tail; } break; case '*': newNumber->data.numeric = 1; while (arg) { newNumber->data.numeric *= arg->head->data.numeric; arg = arg->tail; } break; case '-': newNumber->data.numeric = arg->head->data.numeric; arg = arg->tail; while (arg) { newNumber->data.numeric -= arg->head->data.numeric; arg = arg->tail; } break; case '/': newNumber->data.numeric = arg->head->data.numeric; arg = arg->tail; while (arg) { newNumber->data.numeric /= arg->head->data.numeric; arg = arg->tail; } break; } //printf("operator: %c left: %f right:%f new number: %f\n", // proc->data.string[0], // args->head->data.numeric, // args->tail->head->data.numeric, // newNumber->data.numeric); return newNumber; } return 0; }
void CLASS::xdlDefs(){ if(isPrimitive()){ //fprintf(stderr," xdlDefs %p \n",loc); //loc->dump(stderr); char* primsite = loc->outputLoc(); const char* tile = pDevice->tileFor(primsite); //leaf node (primitive). Output it. fputs("inst \"",fout); hierName(fout); fprintf(fout,"\" \"%s\", placed %s %s,\n", hero->type->name, tile, primsite //name like SLICE_XY ); // now output the cfgs. They are in a TYPE_CFG collection datatype. //pparams->dump(stderr,"PARAMETERS:"); fprintf(fout," cfg \"" ); if(pparams){ int i; for(i=0;i<pparams->size;i++){ // if(0==strncmp("loc",pparams->name[i],3)) continue; //do not output loc as cfg //else if(0==strcmp("cfg",pparams->name[i])){ cCollection* cfgs = pparams->data[i]->valCfgs; int j; for(j=0;j<cfgs->size;j++){ fprintf(fout,"%s::%s ",cfgs->name[j],cfgs->data[j]->valStr); } } else { // loc is not interesting to us. if(0==strncmp("loc",pparams->name[i],3)) continue; // cfgfile is of interest here if(0==strncmp("cfgfile",pparams->name[i],7)){ FILE*f=fopen(pparams->data[i]->valStr,"r"); if(!f){ errorIn("expandFile"); fprintf(stderr,"Trying to open cfgfile \"%s\"\n",pparams->data[i]->valStr); error(-1); } char buf[256]; while(fgets(buf,256,f)){ fputs(buf,fout); } fclose(f); continue; } errorIn("xdlDefs()"); fprintf(stderr,"encountered parameter named '%s' in primitive '%s'\n", pparams->name[i], hero->name); //fprintf(stderr,"dumping parameters:\n"); //pparams->dump(stderr,"xxx"); throw(1); } } } fprintf(fout,"\";\n"); // } else { int i; for(i=0;i<psubcnt;i++){ ((CLASS*)psubs[i])->xdlDefs(); } } }
sendDesc* addrDesc::asPrimitiveSendDesc(OopNCode* m) { // note that it's not really an inline cache, just a primitive call assert(isPrimitive(), "not a primitive location"); return sendDesc::sendDesc_from_addrDesc_addr(addr(m)); }
ir::Type* TypeParser::_parseType() { std::string nextToken = _lexer->peek(); ir::Type* type = nullptr; if(isFunction(nextToken)) { type = _parseFunction(); } else if(isStructure(nextToken)) { type = _parseStructure(); } else if(isPrimitive(_compiler, nextToken)) { type = _parsePrimitive(); nextToken = _lexer->peek(); if(isFunction(nextToken)) { type = _parseFunction(type); } } else if(isArray(nextToken)) { type = _parseArray(); } else if(isVariadic(nextToken)) { _lexer->scan("..."); type = *_compiler->getOrInsertType(ir::VariadicType(_compiler)); } else if(isTypeAlias(nextToken)) { type = _parseTypeAlias(); } else if(isOpaqueType(nextToken)) { _lexer->scan("opaque"); type = *_compiler->getOrInsertType(ir::OpaqueType(_compiler)); } nextToken = _lexer->peek(); while(isPointer(nextToken)) { _lexer->scan("*"); type = *_compiler->getOrInsertType(ir::PointerType(_compiler, type)); nextToken = _lexer->peek(); } if(type == nullptr) { throw std::runtime_error("Failed to parse type."); } hydrazine::log("TypeParser::Parser") << "Parsed type " << type->name << ".\n"; return type; }