/* send global tuple information */ void FixedTupleListAdress::beforeSendParticles (ParticleList& pl, OutBuffer& buf) { std::vector<longint> atpl; // loop over the particle list for (ParticleList::Iterator pit(pl); pit.isValid(); ++pit) { longint pidK = pit->id(); LOG4ESPP_DEBUG(theLogger, "send particle with pid " << pidK << ", find tuples"); // find particle that involves this particle id GlobalTuples::const_iterator it = globalTuples.find(pidK); if (it != globalTuples.end()) { // first write the pid of the first particle //toSend.push_back(pidK); //std::cout << "write pidK "<< pidK << "\n"; buf.write(pidK); // write the size of the vector int s = it->second.size(); //toSend.push_back(s); //std::cout << "write s "<< s << "\n"; buf.write(s); atpl.reserve(s); // iterate through vector and add pids //std::cout << storage->getRank() << ": removing AT particles "; for (tuple::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { //toSend.push_back(*it2); //std::cout << " write pid "<< *it2 << " ("; Particle* tp = storage->lookupAdrATParticle(*it2); //std::cout << " write " << tp->getId() << " (" << tp->getPos() << ")\n"; buf.write(*tp); atpl.push_back(*it2); // remove AT particle from storage storage->removeAdrATParticle(*it2); //std::cout << " " << *it2; } //std::cout << "\n"; // delete this pid from the global list globalTuples.erase(pidK); } } beforeSendATParticles(atpl, buf); }
void StaticAssert::semantic2(Scope *sc) { //printf("StaticAssert::semantic2() %s\n", toChars()); ScopeDsymbol *sd = new ScopeDsymbol(); sc = sc->push(sd); sc->flags |= SCOPEstaticassert; ++sc->ignoreTemplates; Expression *e = exp->ctfeSemantic(sc); e = resolveProperties(sc, e); sc = sc->pop(); if (!e->type->checkBoolean()) { if (e->type->toBasetype() != Type::terror) exp->error("expression %s of type %s does not have a boolean value", exp->toChars(), e->type->toChars()); return; } unsigned olderrs = global.errors; e = e->ctfeInterpret(); if (global.errors != olderrs) { errorSupplemental(loc, "while evaluating: static assert(%s)", exp->toChars()); } else if (e->isBool(FALSE)) { if (msg) { HdrGenState hgs; OutBuffer buf; msg = msg->ctfeSemantic(sc); msg = resolveProperties(sc, msg); msg = msg->ctfeInterpret(); hgs.console = 1; StringExp * s = msg->toString(); if (s) { s->postfix = 0; // Don't display a trailing 'c' msg = s; } msg->toCBuffer(&buf, &hgs); error("%s", buf.toChars()); } else error("(%s) is false", exp->toChars()); if (sc->tinst) sc->tinst->printInstantiationTrace(); if (!global.gag) fatal(); } else if (!e->isBool(TRUE)) { error("(%s) is not evaluatable at compile time", exp->toChars()); } }
Type *TupleDeclaration::getType() { /* If this tuple represents a type, return that type */ //printf("TupleDeclaration::getType() %s\n", toChars()); if (isexp) return NULL; if (!tupletype) { /* It's only a type tuple if all the Object's are types */ for (size_t i = 0; i < objects->dim; i++) { Object *o = (Object *)objects->data[i]; if (o->dyncast() != DYNCAST_TYPE) { //printf("\tnot[%d], %p, %d\n", i, o, o->dyncast()); return NULL; } } /* We know it's a type tuple, so build the TypeTuple */ Parameters *args = new Parameters(); args->setDim(objects->dim); OutBuffer buf; int hasdeco = 1; for (size_t i = 0; i < objects->dim; i++) { Type *t = (Type *)objects->data[i]; //printf("type = %s\n", t->toChars()); #if 0 buf.printf("_%s_%d", ident->toChars(), i); char *name = (char *)buf.extractData(); Identifier *id = new Identifier(name, TOKidentifier); Parameter *arg = new Parameter(STCin, t, id, NULL); #else Parameter *arg = new Parameter(STCin, t, NULL, NULL); #endif args->data[i] = (void *)arg; if (!t->deco) hasdeco = 0; } tupletype = new TypeTuple(args); if (hasdeco) return tupletype->semantic(0, NULL); } return tupletype; }
void visit(BinExp *e) { /* Evaluate assign expressions left to right */ const char *s = NULL; switch(e->op) { case TOKadd: s = "Add"; break; case TOKmin: s = "Min"; break; case TOKmul: s = "Mul"; break; case TOKdiv: s = "Div"; break; case TOKmod: s = "Mod"; break; case TOKxor: s = "Xor"; break; case TOKand: s = "And"; break; case TOKor: s = "Or"; break; case TOKpow: s = "Pow"; break; default: break; } if (s) { Type *tb = e->type->toBasetype(); Type *t1 = e->e1->type->toBasetype(); Type *t2 = e->e2->type->toBasetype(); e->e1->accept(this); if (t1->ty == Tarray && ((t2->ty == Tarray && !t1->equivalent(tb)) || (t2->ty != Tarray && !t1->nextOf()->equivalent(e->e2->type)))) { // Bugzilla 12780: if A is narrower than B // A[] op B[] // A[] op B buf->writestring("Of"); buf->writestring(t1->nextOf()->mutableOf()->deco); } e->e2->accept(this); if (t2->ty == Tarray && ((t1->ty == Tarray && !t2->equivalent(tb)) || (t1->ty != Tarray && !t2->nextOf()->equivalent(e->e1->type)))) { // Bugzilla 12780: if B is narrower than A: // A[] op B[] // A op B[] buf->writestring("Of"); buf->writestring(t2->nextOf()->mutableOf()->deco); } buf->writestring(s); } else visit((Expression *)e); }
void visit(TypeSArray *t) { if (!substitute(t)) store(t); if (t->isImmutable() || t->isShared()) { visit((Type *)t); } if (t->isConst()) buf.writeByte('K'); buf.printf("A%llu_", t->dim ? t->dim->toInteger() : 0); t->next->accept(this); }
// Adds new contact DWORD CMraProto::MraAddContact(MCONTACT hContact, DWORD dwContactFlag, DWORD dwGroupID, const CMStringA &szEmail, const CMStringW &wszCustomName, const CMStringA *szPhones, const CMString* wszAuthMessage) { if (szEmail.GetLength() <= 4 && !(dwContactFlag & CONTACT_FLAG_GROUP)) return 0; dwContactFlag |= CONTACT_FLAG_UNICODE_NAME; if (dwGroupID == -1) dwGroupID = 0; OutBuffer buf; buf.SetUL(dwContactFlag); buf.SetUL(dwGroupID); buf.SetLPSLowerCase(szEmail); buf.SetLPSW(wszCustomName); buf.SetLPS((szPhones == NULL) ? "" : *szPhones); // pack auth message OutBuffer buf2; buf2.SetUL(2); buf2.SetLPSW(_T(""));//***deb possible nick here buf2.SetLPSW((wszAuthMessage == NULL) ? _T("") : *wszAuthMessage); buf.SetLPS(CMStringA(ptrA(mir_base64_encode(buf2.Data(), (int)buf2.Len())))); buf.SetUL(0); return MraSendQueueCMD(hSendQueueHandle, 0, hContact, ACKTYPE_ADDED, NULL, 0, MRIM_CS_ADD_CONTACT, buf.Data(), buf.Len()); }
void argsCppMangle(Parameters *arguments, int varargs) { size_t n = 0; if (arguments) { ArgsCppMangleCtx ctx = { this, 0 }; Parameter::foreach(arguments, &argsCppMangleDg, &ctx); n = ctx.cnt; } if (varargs) buf.writestring("z"); else if (!n) buf.writeByte('v'); // encode ( ) arguments }
void writeBase36(size_t i) { if (i >= 36) { writeBase36(i / 36); i %= 36; } if (i < 10) buf.writeByte((char)(i + '0')); else if (i < 36) buf.writeByte((char)(i - 10 + 'A')); else assert(0); }
char *Loc::toChars() { OutBuffer buf; if (filename) { buf.printf("%s", filename); } if (linnum) buf.printf("(%d)", linnum); buf.writeByte(0); return (char *)buf.extractData(); }
void TypeInfoDeclaration_codegen(TypeInfoDeclaration *decl, IRState *p) { IF_LOG Logger::println("TypeInfoDeclaration_codegen(%s)", decl->toPrettyChars()); LOG_SCOPE; if (decl->ir->isDefined()) { return; } decl->ir->setDefined(); OutBuffer mangleBuf; mangleToBuffer(decl, &mangleBuf); const char *mangled = mangleBuf.peekString(); IF_LOG { Logger::println("type = '%s'", decl->tinfo->toChars()); Logger::println("typeinfo mangle: %s", mangled); } // Only declare the symbol if it isn't yet, otherwise the subtype of built-in // TypeInfos (rt.typeinfo.*) may clash with the base type when compiling the // rt.typeinfo.* modules. const auto irMangle = getIRMangledVarName(mangled, LINKd); llvm::GlobalVariable *gvar = gIR->module.getGlobalVariable(irMangle); if (!gvar) { LLType *type = DtoType(decl->type)->getPointerElementType(); // We need to keep the symbol mutable as the type is not declared as // immutable on the D side, and e.g. synchronized() can be used on the // implicit monitor. gvar = declareGlobal(decl->loc, gIR->module, type, irMangle, false); } IrGlobal *irg = getIrGlobal(decl, true); irg->value = gvar; emitTypeMetadata(decl); // check if the definition can be elided if (!global.params.useTypeInfo || !Type::dtypeinfo || isSpeculativeType(decl->tinfo) || builtinTypeInfo(decl->tinfo)) { return; } // define the TypeInfo global LLVMDefineVisitor v(gvar); decl->accept(&v); setLinkage({TYPEINFO_LINKAGE_TYPE, supportsCOMDAT()}, gvar); }
void visit(TypePointer *t) { if (substitute(t)) return; if (t->isImmutable() || t->isShared()) { visit((Type *)t); } if (t->isConst()) buf.writeByte('K'); buf.writeByte('P'); t->next->accept(this); store(t); }
// Ответ на соединение с прокси DWORD CMraProto::MraProxyAck(DWORD dwStatus, const CMStringA &szEmail, DWORD dwIDRequest, DWORD dwDataType, const CMStringA &lpszData, const CMStringA &szAddresses, MRA_GUID mguidSessionID) { if (szEmail.GetLength() <= 4) return 0; OutBuffer buf; buf.SetUL(dwStatus); buf.SetLPSLowerCase(szEmail); buf.SetUL(dwIDRequest); buf.SetUL(dwDataType); buf.SetLPS(lpszData); buf.SetLPS(szAddresses); buf.SetGUID(mguidSessionID); return MraSendCMD(MRIM_CS_PROXY_ACK, buf.Data(), buf.Len()); }
void JsonOut::objectEnd() { indentLevel--; removeComma(); if (buf->offset >= 2 && buf->data[buf->offset - 2] == '{' && buf->data[buf->offset - 1] == '\n') buf->offset -= 1; else { buf->writestring("\n"); indent(); } buf->writestring("}"); comma(); }
// Отправка SMS DWORD CMraProto::MraSMSW(MCONTACT hContact, const CMStringA &lpszPhone, const CMStringW &lpwszMessage) { CMStringA szPhoneLocal = "+" + CopyNumber(lpszPhone); OutBuffer buf; buf.SetUL(0); buf.SetLPS(szPhoneLocal); buf.SetLPSW(lpwszMessage); /* Save phone number for ack notify after send. */ LPBYTE lpbData = (LPBYTE)mir_calloc(lpszPhone.GetLength() + sizeof(size_t)); if (NULL == lpbData) return (0); memcpy(lpbData, lpszPhone, lpszPhone.GetLength()); return MraSendQueueCMD(hSendQueueHandle, 0, hContact, ICQACKTYPE_SMS, lpbData, lpszPhone.GetLength(), MRIM_CS_SMS, buf.Data(), buf.Len()); }
void JsonOut::propertyStorageClass(const char *name, StorageClass stc) { stc &= STCStorageClass; if (stc) { propertyStart(name); arrayStart(); while (stc) { char tmp[20]; const char *p = StorageClassDeclaration::stcToChars(tmp, stc); assert(p); assert(strlen(p) < sizeof(tmp) / sizeof(tmp[0])); if (p[0] == '@') { indent(); stringStart(); buf->writestring(p); stringEnd(); comma(); } else item(p); } arrayEnd(); } }
void JsonOut::indent() { if (buf->offset >= 1 && buf->data[buf->offset - 1] == '\n') for (int i = 0; i < indentLevel; i++) buf->writeByte(' '); }
void visit(BinExp *e) { /* Evaluate assign expressions left to right */ const char *s = NULL; switch(e->op) { case TOKadd: s = "Add"; break; case TOKmin: s = "Sub"; break; case TOKmul: s = "Mul"; break; case TOKdiv: s = "Div"; break; case TOKmod: s = "Mod"; break; case TOKxor: s = "Xor"; break; case TOKand: s = "And"; break; case TOKor: s = "Or"; break; case TOKpow: s = "Pow"; break; default: break; } if (s) { e->e1->accept(this); e->e2->accept(this); buf->writestring(s); } else visit((Expression *)e); }
char *ModuleDeclaration::toChars() { OutBuffer buf; if (packages && packages->dim) { for (size_t i = 0; i < packages->dim; i++) { Identifier *pid = (*packages)[i]; buf.writestring(pid->toChars()); buf.writeByte('.'); } } buf.writestring(id->toChars()); return buf.extractString(); }
void beforeResort(ParticleList &pl, OutBuffer& out) { if (pl.size() == 1) { beforeResortCalled = true; int res = 42; out.write(res); } }
void visit(TypeReference *t) { if (substitute(t)) return; buf.writeByte('R'); t->next->accept(this); store(t); }
char *mangle(Declaration *sthis) { OutBuffer buf; char *id; Dsymbol *s; //printf("::mangle(%s)\n", sthis->toChars()); s = sthis; do { //printf("mangle: s = %p, '%s', parent = %p\n", s, s->toChars(), s->parent); if (s->ident) { FuncDeclaration *fd = s->isFuncDeclaration(); if (s != sthis && fd) { id = mangle(fd); buf.prependstring(id); goto L1; } else { id = s->ident->toChars(); int len = strlen(id); char tmp[sizeof(len) * 3 + 1]; buf.prependstring(id); sprintf(tmp, "%d", len); buf.prependstring(tmp); } } else buf.prependstring("0"); s = s->parent; } while (s); // buf.prependstring("_D"); L1: //printf("deco = '%s'\n", sthis->type->deco ? sthis->type->deco : "null"); //printf("sthis->type = %s\n", sthis->type->toChars()); FuncDeclaration *fd = sthis->isFuncDeclaration(); if (fd && (fd->needThis() || fd->isNested())) buf.writeByte(Type::needThisPrefix()); if (sthis->type->deco) buf.writestring(sthis->type->deco); else { #ifdef DEBUG if (!fd->inferRetType) printf("%s\n", fd->toChars()); #endif assert(fd && fd->inferRetType); } id = buf.toChars(); buf.data = NULL; return id; }
void visit(TypePointer *t) { if (substitute(t)) return; buf.writeByte('P'); t->next->accept(this); store(t); }
int substitute(RootObject *p) { for (size_t i = 0; i < components.dim; i++) { if (p == components[i]) { /* Sequence is S_, S0_, .., S9_, SA_, ..., SZ_, S10_, ... */ buf.writeByte('S'); if (i) writeBase36(i - 1); buf.writeByte('_'); return 1; } } return 0; }
void JsonOut::arrayEnd() { indentLevel--; removeComma(); if (buf->offset >= 2 && buf->data[buf->offset - 2] == '[' && buf->data[buf->offset - 1] == '\n') buf->offset -= 1; else if (!(buf->offset >= 1 && buf->data[buf->offset - 1] == '[')) { buf->writestring("\n"); indent(); } buf->writestring("]"); comma(); }
void visit(TypeSArray *t) { if (substitute(t)) return; buf.printf("A%llu_", t->dim ? t->dim->toInteger() : 0); t->next->accept(this); store(t); }
void visit(AssignExp *e) { /* Evaluate assign expressions right to left */ e->e2->accept(this); e->e1->accept(this); buf->writestring("Assign"); }
void visit(TypeVector *t) { if (substitute(t)) return; store(t); if (t->isImmutable() || t->isShared()) { visit((Type *)t); } if (t->isConst()) buf.writeByte('K'); assert(t->basetype && t->basetype->ty == Tsarray); assert(((TypeSArray *)t->basetype)->dim); //buf.printf("Dv%llu_", ((TypeSArray *)t->basetype)->dim->toInteger());// -- Gnu ABI v.4 buf.writestring("U8__vector"); //-- Gnu ABI v.3 t->basetype->nextOf()->accept(this); }
void LibOMF::write() { if (global.params.verbose) fprintf(global.stdmsg, "library %s\n", libfile->name->toChars()); OutBuffer libbuf; WriteLibToBuffer(&libbuf); // Transfer image to file libfile->setbuffer(libbuf.data, libbuf.offset); libbuf.extractData(); FileName::ensurePathToNameExists(libfile->name->toChars()); libfile->writev(); }
void visit(TypeVector *t) { if (substitute(t)) return; buf.writestring("U8__vector"); t->basetype->accept(this); store(t); }
// change status DWORD CMraProto::MraChangeStatus(DWORD dwStatus, const CMStringA &szStatusUri, const CMStringW &wszStatusTitle, const CMStringW &wszStatusDesc, DWORD dwFutureFlags) { OutBuffer buf; buf.SetUL(dwStatus); buf.SetLPS(szStatusUri); buf.SetLPSW(wszStatusTitle); buf.SetLPSW(wszStatusDesc); buf.SetUL(dwFutureFlags); return MraSendCMD(MRIM_CS_CHANGE_STATUS, buf.Data(), buf.Len()); }