void MCWalkerConfiguration::loadEnsemble(MCWalkerConfiguration& other) { if(SampleStack.empty()) return; Walker_t::PropertyContainer_t prop(1,PropertyList.size()); int nsamples=SampleStack.size(); for(int i=0; i<nsamples; ++i) { Walker_t* awalker=new Walker_t(getTotalNum()); // awalker->R = *(SampleStack[i]); // awalker->Drift = 0.0; awalker->R = SampleStack[i].R; awalker->Grad = SampleStack[i].G; awalker->Lap = SampleStack[i].L; // Make sure properties is resized properly first awalker->Properties.copy(prop); RealType *myprop = awalker->getPropertyBase(); myprop[LOGPSI] = SampleStack[i].LogPsi; myprop[LOCALENERGY] = SampleStack[i].KE + SampleStack[i].PE; myprop[LOCALPOTENTIAL] = SampleStack[i].PE; other.WalkerList.push_back(awalker); // delete SampleStack[i]; } SampleStack.clear(); }
void AddArbitraryPropertyToParamListBuilder( ICompoundProperty & parent, const PropertyHeader &propHeader, ISampleSelector &sampleSelector, const std::string &rmanBaseType, ParamListBuilder &ParamListBuilder ) { T prop( parent, propHeader.getName() ); if ( ! prop.valid() ) { //TODO error message? return; } std::string rmanType = GetPrmanScopeString( GetGeometryScope( propHeader.getMetaData() ) ) + " "; rmanType += rmanBaseType + " " + propHeader.getName(); typename T::sample_ptr_type propSample = prop.getValue( sampleSelector ); ParamListBuilder.add( rmanType, (RtPointer)propSample->get(), propSample ); }
void prop(Reg *r, Bits ref, Bits cal) { Reg *r1, *r2; int z; for(r1 = r; r1 != R; r1 = (Reg*)r1->f.p1) { for(z=0; z<BITS; z++) { ref.b[z] |= r1->refahead.b[z]; if(ref.b[z] != r1->refahead.b[z]) { r1->refahead.b[z] = ref.b[z]; change++; } cal.b[z] |= r1->calahead.b[z]; if(cal.b[z] != r1->calahead.b[z]) { r1->calahead.b[z] = cal.b[z]; change++; } } switch(r1->f.prog->as) { case ACALL: if(noreturn(r1->f.prog)) break; for(z=0; z<BITS; z++) { cal.b[z] |= ref.b[z] | externs.b[z]; ref.b[z] = 0; } break; case ATEXT: for(z=0; z<BITS; z++) { cal.b[z] = 0; ref.b[z] = 0; } break; case ARET: for(z=0; z<BITS; z++) { cal.b[z] = externs.b[z] | ovar.b[z]; ref.b[z] = 0; } break; default: // Work around for issue 1304: // flush modified globals before each instruction. for(z=0; z<BITS; z++) { cal.b[z] |= externs.b[z]; // issue 4066: flush modified return variables in case of panic if(hasdefer) cal.b[z] |= ovar.b[z]; } break; } for(z=0; z<BITS; z++) { ref.b[z] = (ref.b[z] & ~r1->set.b[z]) | r1->use1.b[z] | r1->use2.b[z]; cal.b[z] &= ~(r1->set.b[z] | r1->use1.b[z] | r1->use2.b[z]); r1->refbehind.b[z] = ref.b[z]; r1->calbehind.b[z] = cal.b[z]; } if(r1->f.active) break; r1->f.active = 1; } for(; r != r1; r = (Reg*)r->f.p1) for(r2 = (Reg*)r->f.p2; r2 != R; r2 = (Reg*)r2->f.p2link) prop(r2, r->refbehind, r->calbehind); }
void VCMatrix::editProperties() { VCMatrixProperties prop(this, m_doc); if (prop.exec() == QDialog::Accepted) m_doc->setModified(); }
void regopt(Prog *p) { Reg *r, *r1, *r2; Prog *p1; int i, z; int32_t initpc, val, npc; uint32_t vreg; Bits bit; struct { int32_t m; int32_t c; Reg* p; } log5[6], *lp; firstr = R; lastr = R; nvar = 0; regbits = RtoB(D_SP) | RtoB(D_AX); for(z=0; z<BITS; z++) { externs.b[z] = 0; params.b[z] = 0; consts.b[z] = 0; addrs.b[z] = 0; } /* * pass 1 * build aux data structure * allocate pcs * find use and set of variables */ val = 5L * 5L * 5L * 5L * 5L; lp = log5; for(i=0; i<5; i++) { lp->m = val; lp->c = 0; lp->p = R; val /= 5L; lp++; } val = 0; for(; p != P; p = p->link) { switch(p->as) { case ADATA: case AGLOBL: case ANAME: case ASIGNAME: continue; } r = rega(); if(firstr == R) { firstr = r; lastr = r; } else { lastr->link = r; r->p1 = lastr; lastr->s1 = r; lastr = r; } r->prog = p; r->pc = val; val++; lp = log5; for(i=0; i<5; i++) { lp->c--; if(lp->c <= 0) { lp->c = lp->m; if(lp->p != R) lp->p->log5 = r; lp->p = r; (lp+1)->c = 0; break; } lp++; } r1 = r->p1; if(r1 != R) switch(r1->prog->as) { case ARET: case AJMP: case AIRETL: r->p1 = R; r1->s1 = R; } bit = mkvar(r, &p->from, p->as==AMOVL); if(bany(&bit)) switch(p->as) { /* * funny */ case ALEAL: for(z=0; z<BITS; z++) addrs.b[z] |= bit.b[z]; break; /* * left side read */ default: for(z=0; z<BITS; z++) r->use1.b[z] |= bit.b[z]; break; } bit = mkvar(r, &p->to, 0); if(bany(&bit)) switch(p->as) { default: diag(Z, "reg: unknown op: %A", p->as); break; /* * right side read */ case ACMPB: case ACMPL: case ACMPW: for(z=0; z<BITS; z++) r->use2.b[z] |= bit.b[z]; break; /* * right side write */ case ANOP: case AMOVL: case AMOVB: case AMOVW: case AMOVBLSX: case AMOVBLZX: case AMOVWLSX: case AMOVWLZX: for(z=0; z<BITS; z++) r->set.b[z] |= bit.b[z]; break; /* * right side read+write */ case AADDB: case AADDL: case AADDW: case AANDB: case AANDL: case AANDW: case ASUBB: case ASUBL: case ASUBW: case AORB: case AORL: case AORW: case AXORB: case AXORL: case AXORW: case ASALB: case ASALL: case ASALW: case ASARB: case ASARL: case ASARW: case AROLB: case AROLL: case AROLW: case ARORB: case ARORL: case ARORW: case ASHLB: case ASHLL: case ASHLW: case ASHRB: case ASHRL: case ASHRW: case AIMULL: case AIMULW: case ANEGL: case ANOTL: case AADCL: case ASBBL: for(z=0; z<BITS; z++) { r->set.b[z] |= bit.b[z]; r->use2.b[z] |= bit.b[z]; } break; /* * funny */ case AFMOVDP: case AFMOVFP: case AFMOVLP: case AFMOVVP: case AFMOVWP: case ACALL: for(z=0; z<BITS; z++) addrs.b[z] |= bit.b[z]; break; } switch(p->as) { case AIMULL: case AIMULW: if(p->to.type != D_NONE) break; case AIDIVB: case AIDIVL: case AIDIVW: case AIMULB: case ADIVB: case ADIVL: case ADIVW: case AMULB: case AMULL: case AMULW: case ACWD: case ACDQ: r->regu |= RtoB(D_AX) | RtoB(D_DX); break; case AREP: case AREPN: case ALOOP: case ALOOPEQ: case ALOOPNE: r->regu |= RtoB(D_CX); break; case AMOVSB: case AMOVSL: case AMOVSW: case ACMPSB: case ACMPSL: case ACMPSW: r->regu |= RtoB(D_SI) | RtoB(D_DI); break; case ASTOSB: case ASTOSL: case ASTOSW: case ASCASB: case ASCASL: case ASCASW: r->regu |= RtoB(D_AX) | RtoB(D_DI); break; case AINSB: case AINSL: case AINSW: case AOUTSB: case AOUTSL: case AOUTSW: r->regu |= RtoB(D_DI) | RtoB(D_DX); break; case AFSTSW: case ASAHF: r->regu |= RtoB(D_AX); break; } } if(firstr == R) return; initpc = pc - val; npc = val; /* * pass 2 * turn branch references to pointers * build back pointers */ for(r = firstr; r != R; r = r->link) { p = r->prog; if(p->to.type == D_BRANCH) { val = p->to.offset - initpc; r1 = firstr; while(r1 != R) { r2 = r1->log5; if(r2 != R && val >= r2->pc) { r1 = r2; continue; } if(r1->pc == val) break; r1 = r1->link; } if(r1 == R) { nearln = p->lineno; diag(Z, "ref not found\n%P", p); continue; } if(r1 == r) { nearln = p->lineno; diag(Z, "ref to self\n%P", p); continue; } r->s2 = r1; r->p2link = r1->p2; r1->p2 = r; } } if(debug['R']) { p = firstr->prog; print("\n%L %D\n", p->lineno, &p->from); } /* * pass 2.5 * find looping structure */ for(r = firstr; r != R; r = r->link) r->active = 0; change = 0; loopit(firstr, npc); if(debug['R'] && debug['v']) { print("\nlooping structure:\n"); for(r = firstr; r != R; r = r->link) { print("%ld:%P", r->loop, r->prog); for(z=0; z<BITS; z++) bit.b[z] = r->use1.b[z] | r->use2.b[z] | r->set.b[z]; if(bany(&bit)) { print("\t"); if(bany(&r->use1)) print(" u1=%B", r->use1); if(bany(&r->use2)) print(" u2=%B", r->use2); if(bany(&r->set)) print(" st=%B", r->set); } print("\n"); } } /* * pass 3 * iterate propagating usage * back until flow graph is complete */ loop1: change = 0; for(r = firstr; r != R; r = r->link) r->active = 0; for(r = firstr; r != R; r = r->link) if(r->prog->as == ARET) prop(r, zbits, zbits); loop11: /* pick up unreachable code */ i = 0; for(r = firstr; r != R; r = r1) { r1 = r->link; if(r1 && r1->active && !r->active) { prop(r, zbits, zbits); i = 1; } } if(i) goto loop11; if(change) goto loop1; /* * pass 4 * iterate propagating register/variable synchrony * forward until graph is complete */ loop2: change = 0; for(r = firstr; r != R; r = r->link) r->active = 0; synch(firstr, zbits); if(change) goto loop2; /* * pass 5 * isolate regions * calculate costs (paint1) */ r = firstr; if(r) { for(z=0; z<BITS; z++) bit.b[z] = (r->refahead.b[z] | r->calahead.b[z]) & ~(externs.b[z] | params.b[z] | addrs.b[z] | consts.b[z]); if(bany(&bit)) { nearln = r->prog->lineno; warn(Z, "used and not set: %B", bit); if(debug['R'] && !debug['w']) print("used and not set: %B\n", bit); } } if(debug['R'] && debug['v']) print("\nprop structure:\n"); for(r = firstr; r != R; r = r->link) r->act = zbits; rgp = region; nregion = 0; for(r = firstr; r != R; r = r->link) { if(debug['R'] && debug['v']) { print("%P\t", r->prog); if(bany(&r->set)) print("s:%B ", r->set); if(bany(&r->refahead)) print("ra:%B ", r->refahead); if(bany(&r->calahead)) print("ca:%B ", r->calahead); print("\n"); } for(z=0; z<BITS; z++) bit.b[z] = r->set.b[z] & ~(r->refahead.b[z] | r->calahead.b[z] | addrs.b[z]); if(bany(&bit)) { nearln = r->prog->lineno; warn(Z, "set and not used: %B", bit); if(debug['R']) print("set and not used: %B\n", bit); excise(r); } for(z=0; z<BITS; z++) bit.b[z] = LOAD(r) & ~(r->act.b[z] | addrs.b[z]); while(bany(&bit)) { i = bnum(bit); rgp->enter = r; rgp->varno = i; change = 0; if(debug['R'] && debug['v']) print("\n"); paint1(r, i); bit.b[i/32] &= ~(1L<<(i%32)); if(change <= 0) { if(debug['R']) print("%L$%d: %B\n", r->prog->lineno, change, blsh(i)); continue; } rgp->cost = change; nregion++; if(nregion >= NRGN) { warn(Z, "too many regions"); goto brk; } rgp++; } } brk: qsort(region, nregion, sizeof(region[0]), rcmp); /* * pass 6 * determine used registers (paint2) * replace code (paint3) */ rgp = region; for(i=0; i<nregion; i++) { bit = blsh(rgp->varno); vreg = paint2(rgp->enter, rgp->varno); vreg = allreg(vreg, rgp); if(debug['R']) { print("%L$%d %R: %B\n", rgp->enter->prog->lineno, rgp->cost, rgp->regno, bit); } if(rgp->regno != 0) paint3(rgp->enter, rgp->varno, vreg, rgp->regno); rgp++; } /* * pass 7 * peep-hole on basic block */ if(!debug['R'] || debug['P']) peep(); /* * pass 8 * recalculate pc */ val = initpc; for(r = firstr; r != R; r = r1) { r->pc = val; p = r->prog; p1 = P; r1 = r->link; if(r1 != R) p1 = r1->prog; for(; p != p1; p = p->link) { switch(p->as) { default: val++; break; case ANOP: case ADATA: case AGLOBL: case ANAME: case ASIGNAME: break; } } } pc = val; /* * fix up branches */ if(debug['R']) if(bany(&addrs)) print("addrs: %B\n", addrs); r1 = 0; /* set */ for(r = firstr; r != R; r = r->link) { p = r->prog; if(p->to.type == D_BRANCH) p->to.offset = r->s2->pc; r1 = r; } /* * last pass * eliminate nops * free aux structures */ for(p = firstr->prog; p != P; p = p->link){ while(p->link && p->link->as == ANOP) p->link = p->link->link; } if(r1 != R) { r1->link = freer; freer = firstr; } }
int main( int argc, char *argv[] ) { // Init controller db file for backend Q_INIT_RESOURCE( controllerdb ); // Uncomment this to enable the message handler for debugging and stack tracing // qInstallMessageHandler( phoenixDebugMessageHandler ); // Handles stuff with the windowing system QGuiApplication app( argc, argv ); // The engine that runs our QML-based UI QQmlApplicationEngine engine; // Set application metadata QGuiApplication::setApplicationDisplayName( QStringLiteral( "Phoenix" ) ); QGuiApplication::setApplicationName( QStringLiteral( "Phoenix" ) ); QGuiApplication::setApplicationVersion( QStringLiteral( "0.0.1" ) ); QGuiApplication::setOrganizationName( QStringLiteral( "Team Phoenix" ) ); QGuiApplication::setOrganizationDomain( QStringLiteral( "phoenix.vg" ) ); // Figure out the right paths for the environment, and create user storage folders if not already there Library::PhxPaths::initPaths(); // For release builds, write to a log file along with the console #ifdef QT_NO_DEBUG QFile logFile( Library::PhxPaths::userDataLocation() % '/' % QStringLiteral( "Logs" ) % '/' % QDateTime::currentDateTime().toString( QStringLiteral( "ddd MMM d yyyy - h mm ss AP" ) ) % QStringLiteral( ".log" ) ); // If this fails... how would we know? :) logFile.open( QIODevice::WriteOnly | QIODevice::Text ); int logFD = logFile.handle(); logFP = fdopen( dup( logFD ), "w" ); qInstallMessageHandler( phoenixDebugMessageLog ); #endif // Open connections to the SQL databases. Library::LibretroDatabase::open(); Library::MetaDataDatabase::open(); // Necessary to quit properly QObject::connect( &engine, &QQmlApplicationEngine::quit, &app, &QGuiApplication::quit ); // Register our custom types for use within QML VideoItem::registerTypes(); InputManager::registerTypes(); // Register our custom QML-accessable/instantiable objects qmlRegisterType<Library::PlatformsModel>( "vg.phoenix.models", 1, 0, "PlatformsModel" ); qmlRegisterType<Library::CollectionsModel>( "vg.phoenix.models", 1, 0, "CollectionsModel" ); qmlRegisterType<Library::LibraryModel>( "vg.phoenix.models", 1, 0, "LibraryModel" ); qmlRegisterType<Library::CoreModel>( "vg.phoenix.models", 1, 0, "CoreModel" ); qmlRegisterType<Library::ImageCacher>( "vg.phoenix.cache", 1, 0, "ImageCacher" ); qmlRegisterType<GameLauncher>( "vg.phoenix.launcher", 1, 0, "GameLauncher" ); // Register our custom QML-accessable objects and instantiate them here qmlRegisterSingletonType( QUrl( "qrc:/PhxTheme.qml" ), "vg.phoenix.themes", 1, 0, "PhxTheme" ); qmlRegisterSingletonType<Library::PhxPaths>( "vg.phoenix.paths", 1, 0, "PhxPaths", PhxPathsSingletonProviderCallback ); qRegisterMetaType<Library::GameData>( "GameData" ); // Load the root QML object and everything under it engine.load( QUrl( QStringLiteral( "qrc:/main.qml" ) ) ); // Ensure custom controller DB file exists QFile gameControllerDBFile( Library::PhxPaths::userDataLocation() % '/' % QStringLiteral( "gamecontrollerdb.txt" ) ); if( !gameControllerDBFile.exists() ) { gameControllerDBFile.open( QIODevice::ReadWrite ); QTextStream stream( &gameControllerDBFile ); stream << "# Insert your custom definitions here" << endl; gameControllerDBFile.close(); } // Set InputManager's custom controller DB file QQmlProperty prop( engine.rootObjects().first(), "inputManager.controllerDBFile" ); Q_ASSERT( prop.isValid() ); QString path = Library::PhxPaths::userDataLocation() % QStringLiteral( "/gamecontrollerdb.txt" ); QVariant pathVar( path ); prop.write( pathVar ); // Run the app and write return code to the log file if in release mode #ifdef QT_NO_DEBUG int ret = app.exec(); fprintf( logFP, "Returned %d", ret ); fclose( logFP ); return ret; #else // Otherwise, just run it normally return app.exec(); #endif }
QString ItemRDFImpl::commentPostUri() const { PropertyPtr prop(new Property(commentApiNamespace() + QLatin1String("comment"))); return m_item.resource()->property(prop)->asString(); }
QObject *QDeclarativeVME::run(QDeclarativeVMEObjectStack &stack, QDeclarativeContextData *ctxt, QDeclarativeCompiledData *comp, int start, int count, const QBitField &bindingSkipList) { Q_ASSERT(comp); Q_ASSERT(ctxt); const QList<QDeclarativeCompiledData::TypeReference> &types = comp->types; const QList<QString> &primitives = comp->primitives; const QList<QByteArray> &datas = comp->datas; const QList<QDeclarativeCompiledData::CustomTypeData> &customTypeData = comp->customTypeData; const QList<int> &intData = comp->intData; const QList<float> &floatData = comp->floatData; const QList<QDeclarativePropertyCache *> &propertyCaches = comp->propertyCaches; const QList<QDeclarativeParser::Object::ScriptBlock> &scripts = comp->scripts; const QList<QUrl> &urls = comp->urls; QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding> bindValues; QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus> parserStatus; QDeclarativeVMEStack<ListInstance> qliststack; vmeErrors.clear(); QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(ctxt->engine); int status = -1; //for dbus QDeclarativePropertyPrivate::WriteFlags flags = QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::RemoveBindingOnAliasWrite; for (int ii = start; !isError() && ii < (start + count); ++ii) { const QDeclarativeInstruction &instr = comp->bytecode.at(ii); switch(instr.type) { case QDeclarativeInstruction::Init: { if (instr.init.bindingsSize) bindValues = QDeclarativeEnginePrivate::SimpleList<QDeclarativeAbstractBinding>(instr.init.bindingsSize); if (instr.init.parserStatusSize) parserStatus = QDeclarativeEnginePrivate::SimpleList<QDeclarativeParserStatus>(instr.init.parserStatusSize); if (instr.init.contextCache != -1) ctxt->setIdPropertyData(comp->contextCaches.at(instr.init.contextCache)); if (instr.init.compiledBinding != -1) ctxt->optimizedBindings = new QDeclarativeCompiledBindings(datas.at(instr.init.compiledBinding).constData(), ctxt, comp); } break; case QDeclarativeInstruction::CreateObject: { QBitField bindings; if (instr.create.bindingBits != -1) { const QByteArray &bits = datas.at(instr.create.bindingBits); bindings = QBitField((const quint32*)bits.constData(), bits.size() * 8); } if (stack.isEmpty()) bindings = bindings.united(bindingSkipList); QObject *o = types.at(instr.create.type).createInstance(ctxt, bindings, &vmeErrors); if (!o) { VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Unable to create object of type %1").arg(QString::fromLatin1(types.at(instr.create.type).className))); } QDeclarativeData *ddata = QDeclarativeData::get(o); Q_ASSERT(ddata); if (stack.isEmpty()) { if (ddata->context) { Q_ASSERT(ddata->context != ctxt); Q_ASSERT(ddata->outerContext); Q_ASSERT(ddata->outerContext != ctxt); QDeclarativeContextData *c = ddata->context; while (c->linkedContext) c = c->linkedContext; c->linkedContext = ctxt; } else { ctxt->addObject(o); } ddata->ownContext = true; } else if (!ddata->context) { ctxt->addObject(o); } ddata->setImplicitDestructible(); ddata->outerContext = ctxt; ddata->lineNumber = instr.line; ddata->columnNumber = instr.create.column; if (instr.create.data != -1) { QDeclarativeCustomParser *customParser = types.at(instr.create.type).type->customParser(); customParser->setCustomData(o, datas.at(instr.create.data)); } if (!stack.isEmpty()) { QObject *parent = stack.top(); if (o->isWidgetType()) { QWidget *widget = static_cast<QWidget*>(o); if (parent->isWidgetType()) { QWidget *parentWidget = static_cast<QWidget*>(parent); widget->setParent(parentWidget); } else { // TODO: parent might be a layout } } else { QDeclarative_setParent_noEvent(o, parent); } } stack.push(o); } break; case QDeclarativeInstruction::CreateSimpleObject: { QObject *o = (QObject *)operator new(instr.createSimple.typeSize + sizeof(QDeclarativeData)); ::memset(static_cast<void *>(o), 0, instr.createSimple.typeSize + sizeof(QDeclarativeData)); instr.createSimple.create(o); QDeclarativeData *ddata = (QDeclarativeData *)(((const char *)o) + instr.createSimple.typeSize); const QDeclarativeCompiledData::TypeReference &ref = types.at(instr.createSimple.type); if (!ddata->propertyCache && ref.typePropertyCache) { ddata->propertyCache = ref.typePropertyCache; ddata->propertyCache->addref(); } ddata->lineNumber = instr.line; ddata->columnNumber = instr.createSimple.column; QObjectPrivate::get(o)->declarativeData = ddata; ddata->context = ddata->outerContext = ctxt; ddata->nextContextObject = ctxt->contextObjects; if (ddata->nextContextObject) ddata->nextContextObject->prevContextObject = &ddata->nextContextObject; ddata->prevContextObject = &ctxt->contextObjects; ctxt->contextObjects = ddata; QObject *parent = stack.top(); QDeclarative_setParent_noEvent(o, parent); stack.push(o); } break; case QDeclarativeInstruction::SetId: { QObject *target = stack.top(); ctxt->setIdProperty(instr.setId.index, target); } break; case QDeclarativeInstruction::SetDefault: { ctxt->contextObject = stack.top(); } break; case QDeclarativeInstruction::CreateComponent: { QDeclarativeComponent *qcomp = new QDeclarativeComponent(ctxt->engine, comp, ii + 1, instr.createComponent.count, stack.isEmpty() ? 0 : stack.top()); QDeclarativeData *ddata = QDeclarativeData::get(qcomp, true); Q_ASSERT(ddata); ctxt->addObject(qcomp); if (stack.isEmpty()) ddata->ownContext = true; ddata->setImplicitDestructible(); ddata->outerContext = ctxt; ddata->lineNumber = instr.line; ddata->columnNumber = instr.create.column; QDeclarativeComponentPrivate::get(qcomp)->creationContext = ctxt; stack.push(qcomp); ii += instr.createComponent.count; } break; case QDeclarativeInstruction::StoreMetaObject: { QObject *target = stack.top(); QMetaObject mo; const QByteArray &metadata = datas.at(instr.storeMeta.data); QMetaObjectBuilder::fromRelocatableData(&mo, 0, metadata); const QDeclarativeVMEMetaData *data = (const QDeclarativeVMEMetaData *)datas.at(instr.storeMeta.aliasData).constData(); (void)new QDeclarativeVMEMetaObject(target, &mo, data, comp); if (instr.storeMeta.propertyCache != -1) { QDeclarativeData *ddata = QDeclarativeData::get(target, true); if (ddata->propertyCache) ddata->propertyCache->release(); ddata->propertyCache = propertyCaches.at(instr.storeMeta.propertyCache); ddata->propertyCache->addref(); } } break; case QDeclarativeInstruction::StoreVariant: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeString.propertyIndex); // XXX - can be more efficient QVariant v = QDeclarativeStringConverters::variantFromString(primitives.at(instr.storeString.value)); void *a[] = { &v, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeString.propertyIndex, a); } break; case QDeclarativeInstruction::StoreVariantInteger: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeString.propertyIndex); QVariant v(instr.storeInteger.value); void *a[] = { &v, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeString.propertyIndex, a); } break; case QDeclarativeInstruction::StoreVariantDouble: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeString.propertyIndex); QVariant v(instr.storeDouble.value); void *a[] = { &v, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeString.propertyIndex, a); } break; case QDeclarativeInstruction::StoreVariantBool: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeString.propertyIndex); QVariant v(instr.storeBool.value); void *a[] = { &v, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeString.propertyIndex, a); } break; case QDeclarativeInstruction::StoreString: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeString.propertyIndex); void *a[] = { (void *)&primitives.at(instr.storeString.value), 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeString.propertyIndex, a); } break; case QDeclarativeInstruction::StoreUrl: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeUrl.propertyIndex); void *a[] = { (void *)&urls.at(instr.storeUrl.value), 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeUrl.propertyIndex, a); } break; case QDeclarativeInstruction::StoreFloat: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeFloat.propertyIndex); float f = instr.storeFloat.value; void *a[] = { &f, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeFloat.propertyIndex, a); } break; case QDeclarativeInstruction::StoreDouble: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeDouble.propertyIndex); double d = instr.storeDouble.value; void *a[] = { &d, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeDouble.propertyIndex, a); } break; case QDeclarativeInstruction::StoreBool: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeBool.propertyIndex); void *a[] = { (void *)&instr.storeBool.value, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeBool.propertyIndex, a); } break; case QDeclarativeInstruction::StoreInteger: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeInteger.propertyIndex); void *a[] = { (void *)&instr.storeInteger.value, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeInteger.propertyIndex, a); } break; case QDeclarativeInstruction::StoreColor: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeColor.propertyIndex); QColor c = QColor::fromRgba(instr.storeColor.value); void *a[] = { &c, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeColor.propertyIndex, a); } break; case QDeclarativeInstruction::StoreDate: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeDate.propertyIndex); QDate d = QDate::fromJulianDay(instr.storeDate.value); void *a[] = { &d, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeDate.propertyIndex, a); } break; case QDeclarativeInstruction::StoreTime: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeTime.propertyIndex); QTime t; t.setHMS(intData.at(instr.storeTime.valueIndex), intData.at(instr.storeTime.valueIndex+1), intData.at(instr.storeTime.valueIndex+2), intData.at(instr.storeTime.valueIndex+3)); void *a[] = { &t, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeTime.propertyIndex, a); } break; case QDeclarativeInstruction::StoreDateTime: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeDateTime.propertyIndex); QTime t; t.setHMS(intData.at(instr.storeDateTime.valueIndex+1), intData.at(instr.storeDateTime.valueIndex+2), intData.at(instr.storeDateTime.valueIndex+3), intData.at(instr.storeDateTime.valueIndex+4)); QDateTime dt(QDate::fromJulianDay(intData.at(instr.storeDateTime.valueIndex)), t); void *a[] = { &dt, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeDateTime.propertyIndex, a); } break; case QDeclarativeInstruction::StorePoint: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex); QPoint p = QPointF(floatData.at(instr.storeRealPair.valueIndex), floatData.at(instr.storeRealPair.valueIndex+1)).toPoint(); void *a[] = { &p, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeRealPair.propertyIndex, a); } break; case QDeclarativeInstruction::StorePointF: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex); QPointF p(floatData.at(instr.storeRealPair.valueIndex), floatData.at(instr.storeRealPair.valueIndex+1)); void *a[] = { &p, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeRealPair.propertyIndex, a); } break; case QDeclarativeInstruction::StoreSize: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex); QSize p = QSizeF(floatData.at(instr.storeRealPair.valueIndex), floatData.at(instr.storeRealPair.valueIndex+1)).toSize(); void *a[] = { &p, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeRealPair.propertyIndex, a); } break; case QDeclarativeInstruction::StoreSizeF: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeRealPair.propertyIndex); QSizeF s(floatData.at(instr.storeRealPair.valueIndex), floatData.at(instr.storeRealPair.valueIndex+1)); void *a[] = { &s, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeRealPair.propertyIndex, a); } break; case QDeclarativeInstruction::StoreRect: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeRect.propertyIndex); QRect r = QRectF(floatData.at(instr.storeRect.valueIndex), floatData.at(instr.storeRect.valueIndex+1), floatData.at(instr.storeRect.valueIndex+2), floatData.at(instr.storeRect.valueIndex+3)).toRect(); void *a[] = { &r, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeRect.propertyIndex, a); } break; case QDeclarativeInstruction::StoreRectF: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeRect.propertyIndex); QRectF r(floatData.at(instr.storeRect.valueIndex), floatData.at(instr.storeRect.valueIndex+1), floatData.at(instr.storeRect.valueIndex+2), floatData.at(instr.storeRect.valueIndex+3)); void *a[] = { &r, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeRect.propertyIndex, a); } break; case QDeclarativeInstruction::StoreVector3D: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeVector3D.propertyIndex); QVector3D p(floatData.at(instr.storeVector3D.valueIndex), floatData.at(instr.storeVector3D.valueIndex+1), floatData.at(instr.storeVector3D.valueIndex+2)); void *a[] = { &p, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeVector3D.propertyIndex, a); } break; case QDeclarativeInstruction::StoreObject: { QObject *assignObj = stack.pop(); QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeObject.propertyIndex); void *a[] = { (void *)&assignObj, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeObject.propertyIndex, a); } break; case QDeclarativeInstruction::AssignCustomType: { QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.assignCustomType.propertyIndex); QDeclarativeCompiledData::CustomTypeData data = customTypeData.at(instr.assignCustomType.valueIndex); const QString &primitive = primitives.at(data.index); QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(data.type); QVariant v = (*converter)(primitive); QMetaProperty prop = target->metaObject()->property(instr.assignCustomType.propertyIndex); if (v.isNull() || ((int)prop.type() != data.type && prop.userType() != data.type)) VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign value %1 to property %2").arg(primitive).arg(QString::fromUtf8(prop.name()))); void *a[] = { (void *)v.data(), 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.assignCustomType.propertyIndex, a); } break; case QDeclarativeInstruction::AssignSignalObject: { // XXX optimize QObject *assign = stack.pop(); QObject *target = stack.top(); int sigIdx = instr.assignSignalObject.signal; const QByteArray &pr = datas.at(sigIdx); QDeclarativeProperty prop(target, QString::fromUtf8(pr)); if (prop.type() & QDeclarativeProperty::SignalProperty) { QMetaMethod method = QDeclarativeMetaType::defaultMethod(assign); if (method.signature() == 0) VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object type %1 with no default method").arg(QString::fromLatin1(assign->metaObject()->className()))); if (!QMetaObject::checkConnectArgs(prop.method().signature(), method.signature())) VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot connect mismatched signal/slot %1 %vs. %2").arg(QString::fromLatin1(method.signature())).arg(QString::fromLatin1(prop.method().signature()))); QDeclarativePropertyPrivate::connect(target, prop.index(), assign, method.methodIndex()); } else { VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign an object to signal property %1").arg(QString::fromUtf8(pr))); } } break; case QDeclarativeInstruction::StoreSignal: { QObject *target = stack.top(); QObject *context = stack.at(stack.count() - 1 - instr.storeSignal.context); QMetaMethod signal = target->metaObject()->method(instr.storeSignal.signalIndex); QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target); QDeclarativeExpression *expr = new QDeclarativeExpression(ctxt, context, primitives.at(instr.storeSignal.value)); expr->setSourceLocation(comp->name, instr.line); static_cast<QDeclarativeExpressionPrivate *>(QObjectPrivate::get(expr))->name = datas.at(instr.storeSignal.name); bs->setExpression(expr); } break; case QDeclarativeInstruction::StoreImportedScript: { ctxt->addImportedScript(scripts.at(instr.storeScript.value)); } break; case QDeclarativeInstruction::StoreScriptString: { QObject *target = stack.top(); QObject *scope = stack.at(stack.count() - 1 - instr.storeScriptString.scope); QDeclarativeScriptString ss; ss.setContext(ctxt->asQDeclarativeContext()); ss.setScopeObject(scope); ss.setScript(primitives.at(instr.storeScriptString.value)); void *a[] = { &ss, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeScriptString.propertyIndex, a); } break; case QDeclarativeInstruction::BeginObject: { QObject *target = stack.top(); QDeclarativeParserStatus *status = reinterpret_cast<QDeclarativeParserStatus *>(reinterpret_cast<char *>(target) + instr.begin.castValue); parserStatus.append(status); status->d = &parserStatus.values[parserStatus.count - 1]; status->classBegin(); } break; case QDeclarativeInstruction::StoreBinding: case QDeclarativeInstruction::StoreBindingOnAlias: { QObject *target = stack.at(stack.count() - 1 - instr.assignBinding.owner); QObject *context = stack.at(stack.count() - 1 - instr.assignBinding.context); QDeclarativeProperty mp = QDeclarativePropertyPrivate::restore(datas.at(instr.assignBinding.property), target, ctxt); int coreIndex = mp.index(); if ((stack.count() - instr.assignBinding.owner) == 1 && bindingSkipList.testBit(coreIndex)) break; QDeclarativeBinding *bind = new QDeclarativeBinding((void *)datas.at(instr.assignBinding.value).constData(), comp, context, ctxt, comp->name, instr.line, 0); bindValues.append(bind); bind->m_mePtr = &bindValues.values[bindValues.count - 1]; bind->setTarget(mp); if (instr.type == QDeclarativeInstruction::StoreBindingOnAlias) { QDeclarativeAbstractBinding *old = QDeclarativePropertyPrivate::setBindingNoEnable(target, coreIndex, QDeclarativePropertyPrivate::valueTypeCoreIndex(mp), bind); if (old) { old->destroy(); } } else { bind->addToObject(target, QDeclarativePropertyPrivate::bindingIndex(mp)); } } break; case QDeclarativeInstruction::StoreCompiledBinding: { QObject *target = stack.at(stack.count() - 1 - instr.assignBinding.owner); QObject *scope = stack.at(stack.count() - 1 - instr.assignBinding.context); int property = instr.assignBinding.property; if (stack.count() == 1 && bindingSkipList.testBit(property & 0xFFFF)) break; QDeclarativeAbstractBinding *binding = ctxt->optimizedBindings->configBinding(instr.assignBinding.value, target, scope, property); bindValues.append(binding); binding->m_mePtr = &bindValues.values[bindValues.count - 1]; binding->addToObject(target, property); } break; case QDeclarativeInstruction::StoreValueSource: { QObject *obj = stack.pop(); QDeclarativePropertyValueSource *vs = reinterpret_cast<QDeclarativePropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.assignValueSource.castValue); QObject *target = stack.at(stack.count() - 1 - instr.assignValueSource.owner); QDeclarativeProperty prop = QDeclarativePropertyPrivate::restore(datas.at(instr.assignValueSource.property), target, ctxt); obj->setParent(target); vs->setTarget(prop); } break; case QDeclarativeInstruction::StoreValueInterceptor: { QObject *obj = stack.pop(); QDeclarativePropertyValueInterceptor *vi = reinterpret_cast<QDeclarativePropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.assignValueInterceptor.castValue); QObject *target = stack.at(stack.count() - 1 - instr.assignValueInterceptor.owner); QDeclarativeProperty prop = QDeclarativePropertyPrivate::restore(datas.at(instr.assignValueInterceptor.property), target, ctxt); obj->setParent(target); vi->setTarget(prop); QDeclarativeVMEMetaObject *mo = static_cast<QDeclarativeVMEMetaObject *>((QMetaObject*)target->metaObject()); mo->registerInterceptor(prop.index(), QDeclarativePropertyPrivate::valueTypeCoreIndex(prop), vi); } break; case QDeclarativeInstruction::StoreObjectQList: { QObject *assign = stack.pop(); const ListInstance &list = qliststack.top(); list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, assign); } break; case QDeclarativeInstruction::AssignObjectList: { // This is only used for assigning interfaces QObject *assign = stack.pop(); const ListInstance &list = qliststack.top(); int type = list.type; void *ptr = 0; const char *iid = QDeclarativeMetaType::interfaceIId(type); if (iid) ptr = assign->qt_metacast(iid); if (!ptr) VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object to list")); list.qListProperty.append((QDeclarativeListProperty<void>*)&list.qListProperty, ptr); } break; case QDeclarativeInstruction::StoreVariantObject: { QObject *assign = stack.pop(); QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeObject.propertyIndex); QVariant v = QVariant::fromValue(assign); void *a[] = { &v, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, instr.storeObject.propertyIndex, a); } break; case QDeclarativeInstruction::StoreInterface: { QObject *assign = stack.pop(); QObject *target = stack.top(); CLEAN_PROPERTY(target, instr.storeObject.propertyIndex); int coreIdx = instr.storeObject.propertyIndex; QMetaProperty prop = target->metaObject()->property(coreIdx); int t = prop.userType(); const char *iid = QDeclarativeMetaType::interfaceIId(t); bool ok = false; if (iid) { void *ptr = assign->qt_metacast(iid); if (ptr) { void *a[] = { &ptr, 0, &status, &flags }; QMetaObject::metacall(target, QMetaObject::WriteProperty, coreIdx, a); ok = true; } } if (!ok) VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot assign object to interface property")); } break; case QDeclarativeInstruction::FetchAttached: { QObject *target = stack.top(); QObject *qmlObject = qmlAttachedPropertiesObjectById(instr.fetchAttached.id, target); if (!qmlObject) VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Unable to create attached object")); stack.push(qmlObject); } break; case QDeclarativeInstruction::FetchQList: { QObject *target = stack.top(); qliststack.push(ListInstance(instr.fetchQmlList.type)); void *a[1]; a[0] = (void *)&(qliststack.top().qListProperty); QMetaObject::metacall(target, QMetaObject::ReadProperty, instr.fetchQmlList.property, a); } break; case QDeclarativeInstruction::FetchObject: { QObject *target = stack.top(); QObject *obj = 0; // NOTE: This assumes a cast to QObject does not alter the // object pointer void *a[1]; a[0] = &obj; QMetaObject::metacall(target, QMetaObject::ReadProperty, instr.fetch.property, a); if (!obj) VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.fetch.property).name()))); stack.push(obj); } break; case QDeclarativeInstruction::PopQList: { qliststack.pop(); } break; case QDeclarativeInstruction::Defer: { if (instr.defer.deferCount) { QObject *target = stack.top(); QDeclarativeData *data = QDeclarativeData::get(target, true); comp->addref(); data->deferredComponent = comp; data->deferredIdx = ii; ii += instr.defer.deferCount; } } break; case QDeclarativeInstruction::PopFetchedObject: { stack.pop(); } break; case QDeclarativeInstruction::FetchValueType: { QObject *target = stack.top(); if (instr.fetchValue.bindingSkipList != 0) { // Possibly need to clear bindings QDeclarativeData *targetData = QDeclarativeData::get(target); if (targetData) { QDeclarativeAbstractBinding *binding = QDeclarativePropertyPrivate::binding(target, instr.fetchValue.property, -1); if (binding && binding->bindingType() != QDeclarativeAbstractBinding::ValueTypeProxy) { QDeclarativePropertyPrivate::setBinding(target, instr.fetchValue.property, -1, 0); binding->destroy(); } else if (binding) { QDeclarativeValueTypeProxyBinding *proxy = static_cast<QDeclarativeValueTypeProxyBinding *>(binding); proxy->removeBindings(instr.fetchValue.bindingSkipList); } } } QDeclarativeValueType *valueHandler = ep->valueTypes[instr.fetchValue.type]; valueHandler->read(target, instr.fetchValue.property); stack.push(valueHandler); } break; case QDeclarativeInstruction::PopValueType: { QDeclarativeValueType *valueHandler = static_cast<QDeclarativeValueType *>(stack.pop()); QObject *target = stack.top(); valueHandler->write(target, instr.fetchValue.property, QDeclarativePropertyPrivate::BypassInterceptor); } break; default: qFatal("QDeclarativeCompiledData: Internal error - unknown instruction %d", instr.type); break; } } if (isError()) { if (!stack.isEmpty()) { delete stack.at(0); // ### What about failures in deferred creation? } else { ctxt->destroy(); } QDeclarativeEnginePrivate::clear(bindValues); QDeclarativeEnginePrivate::clear(parserStatus); return 0; } if (bindValues.count) ep->bindValues << bindValues; else if (bindValues.values) bindValues.clear(); if (parserStatus.count) ep->parserStatus << parserStatus; else if (parserStatus.values) parserStatus.clear(); Q_ASSERT(stack.count() == 1); return stack.top(); }
void regopt(Prog *firstp) { Reg *r, *r1; Prog *p; int i, z, nr; uint32 vreg; Bits bit; if(first) { fmtinstall('Q', Qconv); exregoffset = D_DI; // no externals first = 0; } fixjmp(firstp); // count instructions nr = 0; for(p=firstp; p!=P; p=p->link) nr++; // if too big dont bother if(nr >= 10000) { // print("********** %S is too big (%d)\n", curfn->nname->sym, nr); return; } r1 = R; firstr = R; lastr = R; /* * control flow is more complicated in generated go code * than in generated c code. define pseudo-variables for * registers, so we have complete register usage information. */ nvar = NREGVAR; memset(var, 0, NREGVAR*sizeof var[0]); for(i=0; i<NREGVAR; i++) var[i].node = newname(lookup(regname[i])); regbits = RtoB(D_SP); for(z=0; z<BITS; z++) { externs.b[z] = 0; params.b[z] = 0; consts.b[z] = 0; addrs.b[z] = 0; ovar.b[z] = 0; } // build list of return variables setoutvar(); /* * pass 1 * build aux data structure * allocate pcs * find use and set of variables */ nr = 0; for(p=firstp; p!=P; p=p->link) { switch(p->as) { case ADATA: case AGLOBL: case ANAME: case ASIGNAME: continue; } r = rega(); nr++; if(firstr == R) { firstr = r; lastr = r; } else { lastr->link = r; r->p1 = lastr; lastr->s1 = r; lastr = r; } r->prog = p; p->reg = r; r1 = r->p1; if(r1 != R) { switch(r1->prog->as) { case ARET: case AJMP: case AIRETL: r->p1 = R; r1->s1 = R; } } bit = mkvar(r, &p->from); if(bany(&bit)) switch(p->as) { /* * funny */ case ALEAL: case AFMOVL: case AFMOVW: case AFMOVV: setaddrs(bit); break; /* * left side read */ default: for(z=0; z<BITS; z++) r->use1.b[z] |= bit.b[z]; break; /* * left side read+write */ case AXCHGB: case AXCHGW: case AXCHGL: for(z=0; z<BITS; z++) { r->use1.b[z] |= bit.b[z]; r->set.b[z] |= bit.b[z]; } break; } bit = mkvar(r, &p->to); if(bany(&bit)) switch(p->as) { default: yyerror("reg: unknown op: %A", p->as); break; /* * right side read */ case ACMPB: case ACMPL: case ACMPW: case ATESTB: case ATESTL: case ATESTW: for(z=0; z<BITS; z++) r->use2.b[z] |= bit.b[z]; break; /* * right side write */ case AFSTSW: case ALEAL: case ANOP: case AMOVL: case AMOVB: case AMOVW: case AMOVBLSX: case AMOVBLZX: case AMOVBWSX: case AMOVBWZX: case AMOVWLSX: case AMOVWLZX: case APOPL: for(z=0; z<BITS; z++) r->set.b[z] |= bit.b[z]; break; /* * right side read+write */ case AINCB: case AINCL: case AINCW: case ADECB: case ADECL: case ADECW: case AADDB: case AADDL: case AADDW: case AANDB: case AANDL: case AANDW: case ASUBB: case ASUBL: case ASUBW: case AORB: case AORL: case AORW: case AXORB: case AXORL: case AXORW: case ASALB: case ASALL: case ASALW: case ASARB: case ASARL: case ASARW: case ARCLB: case ARCLL: case ARCLW: case ARCRB: case ARCRL: case ARCRW: case AROLB: case AROLL: case AROLW: case ARORB: case ARORL: case ARORW: case ASHLB: case ASHLL: case ASHLW: case ASHRB: case ASHRL: case ASHRW: case AIMULL: case AIMULW: case ANEGB: case ANEGL: case ANEGW: case ANOTB: case ANOTL: case ANOTW: case AADCL: case ASBBL: case ASETCC: case ASETCS: case ASETEQ: case ASETGE: case ASETGT: case ASETHI: case ASETLE: case ASETLS: case ASETLT: case ASETMI: case ASETNE: case ASETOC: case ASETOS: case ASETPC: case ASETPL: case ASETPS: case AXCHGB: case AXCHGW: case AXCHGL: for(z=0; z<BITS; z++) { r->set.b[z] |= bit.b[z]; r->use2.b[z] |= bit.b[z]; } break; /* * funny */ case AFMOVDP: case AFMOVFP: case AFMOVLP: case AFMOVVP: case AFMOVWP: case ACALL: setaddrs(bit); break; } switch(p->as) { case AIMULL: case AIMULW: if(p->to.type != D_NONE) break; case AIDIVL: case AIDIVW: case ADIVL: case ADIVW: case AMULL: case AMULW: r->set.b[0] |= RtoB(D_AX) | RtoB(D_DX); r->use1.b[0] |= RtoB(D_AX) | RtoB(D_DX); break; case AIDIVB: case AIMULB: case ADIVB: case AMULB: r->set.b[0] |= RtoB(D_AX); r->use1.b[0] |= RtoB(D_AX); break; case ACWD: r->set.b[0] |= RtoB(D_AX) | RtoB(D_DX); r->use1.b[0] |= RtoB(D_AX); break; case ACDQ: r->set.b[0] |= RtoB(D_DX); r->use1.b[0] |= RtoB(D_AX); break; case AREP: case AREPN: case ALOOP: case ALOOPEQ: case ALOOPNE: r->set.b[0] |= RtoB(D_CX); r->use1.b[0] |= RtoB(D_CX); break; case AMOVSB: case AMOVSL: case AMOVSW: case ACMPSB: case ACMPSL: case ACMPSW: r->set.b[0] |= RtoB(D_SI) | RtoB(D_DI); r->use1.b[0] |= RtoB(D_SI) | RtoB(D_DI); break; case ASTOSB: case ASTOSL: case ASTOSW: case ASCASB: case ASCASL: case ASCASW: r->set.b[0] |= RtoB(D_DI); r->use1.b[0] |= RtoB(D_AX) | RtoB(D_DI); break; case AINSB: case AINSL: case AINSW: r->set.b[0] |= RtoB(D_DX) | RtoB(D_DI); r->use1.b[0] |= RtoB(D_DI); break; case AOUTSB: case AOUTSL: case AOUTSW: r->set.b[0] |= RtoB(D_DI); r->use1.b[0] |= RtoB(D_DX) | RtoB(D_DI); break; } } if(firstr == R) return; for(i=0; i<nvar; i++) { Var *v = var+i; if(v->addr) { bit = blsh(i); for(z=0; z<BITS; z++) addrs.b[z] |= bit.b[z]; } // print("bit=%2d addr=%d et=%-6E w=%-2d s=%S + %lld\n", // i, v->addr, v->etype, v->width, v->sym, v->offset); } if(debug['R'] && debug['v']) dumpit("pass1", firstr); /* * pass 2 * turn branch references to pointers * build back pointers */ for(r=firstr; r!=R; r=r->link) { p = r->prog; if(p->to.type == D_BRANCH) { if(p->to.branch == P) fatal("pnil %P", p); r1 = p->to.branch->reg; if(r1 == R) fatal("rnil %P", p); if(r1 == r) { //fatal("ref to self %P", p); continue; } r->s2 = r1; r->p2link = r1->p2; r1->p2 = r; } } if(debug['R'] && debug['v']) dumpit("pass2", firstr); /* * pass 2.5 * find looping structure */ for(r = firstr; r != R; r = r->link) r->active = 0; change = 0; loopit(firstr, nr); if(debug['R'] && debug['v']) dumpit("pass2.5", firstr); /* * pass 3 * iterate propagating usage * back until flow graph is complete */ loop1: change = 0; for(r = firstr; r != R; r = r->link) r->active = 0; for(r = firstr; r != R; r = r->link) if(r->prog->as == ARET) prop(r, zbits, zbits); loop11: /* pick up unreachable code */ i = 0; for(r = firstr; r != R; r = r1) { r1 = r->link; if(r1 && r1->active && !r->active) { prop(r, zbits, zbits); i = 1; } } if(i) goto loop11; if(change) goto loop1; if(debug['R'] && debug['v']) dumpit("pass3", firstr); /* * pass 4 * iterate propagating register/variable synchrony * forward until graph is complete */ loop2: change = 0; for(r = firstr; r != R; r = r->link) r->active = 0; synch(firstr, zbits); if(change) goto loop2; if(debug['R'] && debug['v']) dumpit("pass4", firstr); /* * pass 4.5 * move register pseudo-variables into regu. */ for(r = firstr; r != R; r = r->link) { r->regu = (r->refbehind.b[0] | r->set.b[0]) & REGBITS; r->set.b[0] &= ~REGBITS; r->use1.b[0] &= ~REGBITS; r->use2.b[0] &= ~REGBITS; r->refbehind.b[0] &= ~REGBITS; r->refahead.b[0] &= ~REGBITS; r->calbehind.b[0] &= ~REGBITS; r->calahead.b[0] &= ~REGBITS; r->regdiff.b[0] &= ~REGBITS; r->act.b[0] &= ~REGBITS; } /* * pass 5 * isolate regions * calculate costs (paint1) */ r = firstr; if(r) { for(z=0; z<BITS; z++) bit.b[z] = (r->refahead.b[z] | r->calahead.b[z]) & ~(externs.b[z] | params.b[z] | addrs.b[z] | consts.b[z]); if(bany(&bit) && !r->refset) { // should never happen - all variables are preset if(debug['w']) print("%L: used and not set: %Q\n", r->prog->lineno, bit); r->refset = 1; } } for(r = firstr; r != R; r = r->link) r->act = zbits; rgp = region; nregion = 0; for(r = firstr; r != R; r = r->link) { for(z=0; z<BITS; z++) bit.b[z] = r->set.b[z] & ~(r->refahead.b[z] | r->calahead.b[z] | addrs.b[z]); if(bany(&bit) && !r->refset) { if(debug['w']) print("%L: set and not used: %Q\n", r->prog->lineno, bit); r->refset = 1; excise(r); } for(z=0; z<BITS; z++) bit.b[z] = LOAD(r) & ~(r->act.b[z] | addrs.b[z]); while(bany(&bit)) { i = bnum(bit); rgp->enter = r; rgp->varno = i; change = 0; paint1(r, i); bit.b[i/32] &= ~(1L<<(i%32)); if(change <= 0) continue; rgp->cost = change; nregion++; if(nregion >= NRGN) { if(debug['R'] && debug['v']) print("too many regions\n"); goto brk; } rgp++; } } brk: qsort(region, nregion, sizeof(region[0]), rcmp); /* * pass 6 * determine used registers (paint2) * replace code (paint3) */ rgp = region; for(i=0; i<nregion; i++) { bit = blsh(rgp->varno); vreg = paint2(rgp->enter, rgp->varno); vreg = allreg(vreg, rgp); if(rgp->regno != 0) paint3(rgp->enter, rgp->varno, vreg, rgp->regno); rgp++; } if(debug['R'] && debug['v']) dumpit("pass6", firstr); /* * pass 7 * peep-hole on basic block */ if(!debug['R'] || debug['P']) { peep(); } /* * eliminate nops * free aux structures */ for(p=firstp; p!=P; p=p->link) { while(p->link != P && p->link->as == ANOP) p->link = p->link->link; if(p->to.type == D_BRANCH) while(p->to.branch != P && p->to.branch->as == ANOP) p->to.branch = p->to.branch->link; } if(r1 != R) { r1->link = freer; freer = firstr; } if(debug['R']) { if(ostats.ncvtreg || ostats.nspill || ostats.nreload || ostats.ndelmov || ostats.nvar || ostats.naddr || 0) print("\nstats\n"); if(ostats.ncvtreg) print(" %4d cvtreg\n", ostats.ncvtreg); if(ostats.nspill) print(" %4d spill\n", ostats.nspill); if(ostats.nreload) print(" %4d reload\n", ostats.nreload); if(ostats.ndelmov) print(" %4d delmov\n", ostats.ndelmov); if(ostats.nvar) print(" %4d var\n", ostats.nvar); if(ostats.naddr) print(" %4d addr\n", ostats.naddr); memset(&ostats, 0, sizeof(ostats)); } }
void ShapeCL::update(int id) { switch (id) { case PROP_STENCIL: { if (prop(id) < 0.0) setProperty(id, 0.0); else if (prop(id) > 3.0) setProperty(id, 3.0); break; } case PROP_BLINK_FREQ: { if (prop(id) < 0.0) { setProperty(id, 0.0); bBlinkOn = 1; dBlinkClock = 0.0; } break; } // numbers between 0.0 and 1.0: case PROP_BLINK_DUTY_CYCLE: case PROP_BLINK_INITIAL_PHASE: { if (prop(id) < 0.0) setProperty(id, 0.0); else if (prop(id) > 1.0) setProperty(id, 1.0); break; } // properties that must be >= 0.0 case PROP_RAMP_REPEAT: case PROP_RAMP_PERIOD: { if (prop(id) < 0.0) setProperty(id, 0.0); break; } // allow least sig 8 bits to be set, bit n [1..8] on // means turn stimulus on for block n case PROP_BLOCK: { if (prop(id) < 0) setProperty(id, 0); else if (prop(id) > 255) setProperty(id, 255); break; } // properties that should be integers in range [1..3]: case PROP_EYE: { if (prop(id) < 1) setProperty(id, 3); else if (prop(id) > 3) setProperty(id, 1); break; } // properties than can be 0 or 1 or 2 case PROP_RAMPED: { if (prop(id) < 0) setProperty(id, 2); else if (prop(id) > 2) setProperty(id, 0); break; } // properties that are 0 or 1 (e.g. on/off properties) case PROP_ALWAYS_ON: case PROP_RAMP_UPORDOWN: case PROP_COLOR_TRACK_BG: { if (prop(id) < 0) setProperty(id, 1); else if (prop(id) > 1) setProperty(id, 0); break; } case PROP_RED: case PROP_GREEN: case PROP_BLUE: { for (int i=PROP_RED; i<=PROP_BLUE; i++) { if (prop(i) < 0) setProperty(i, 0); else if (prop(i) > 255) setProperty(i, 255); fRGBA[i-PROP_RED] = prop(i) / 255.0; } break; } } }
void ShapeCL::updateAt(double seconds) { if (prop(PROP_BLINK_FREQ) > 0.0) { dBlinkClock += seconds; double period = 1.0/prop(PROP_BLINK_FREQ); if (dBlinkClock > period) { dBlinkClock -= period; } bBlinkOn = 1; if (dBlinkClock > period*prop(PROP_BLINK_DUTY_CYCLE)) bBlinkOn = 0; } if (prop(PROP_RAMP_REPEAT) > 0.0) { dRampClock += seconds; if (dRampClock > prop(PROP_RAMP_REPEAT)) { dRampClock -= prop(PROP_RAMP_REPEAT); } if (prop(PROP_RAMP_UPORDOWN) == 0) { if (prop(PROP_RAMP_PERIOD) > 0.0 && dRampClock < prop(PROP_RAMP_PERIOD)) setOpacity(dRampClock / prop(PROP_RAMP_PERIOD)); else setOpacity(1.0); } else { if (prop(PROP_RAMP_PERIOD) > 0.0 && dRampClock < prop(PROP_RAMP_PERIOD)) setOpacity(1.0 - dRampClock / prop(PROP_RAMP_PERIOD)); else setOpacity(0.0); } } }
void VCSlider::editProperties() { VCSliderProperties prop(this, m_doc, m_outputMap, m_inputMap, m_masterTimer); if (prop.exec() == QDialog::Accepted) m_doc->setModified(); }
char *OpenDDLParser::parseHeader( char *in, char *end ) { if( ddl_nullptr == in || in == end ) { return in; } Text *id( ddl_nullptr ); in = OpenDDLParser::parseIdentifier( in, end, &id ); #ifdef DEBUG_HEADER_NAME dumpId( id ); #endif // DEBUG_HEADER_NAME in = lookForNextToken( in, end ); if( ddl_nullptr != id ) { // store the node DDLNode *node( createDDLNode( id, this ) ); if( ddl_nullptr != node ) { pushNode( node ); } else { std::cerr << "nullptr returned by creating DDLNode." << std::endl; } delete id; Name *name(ddl_nullptr); in = OpenDDLParser::parseName(in, end, &name); if( ddl_nullptr != name && ddl_nullptr != node ) { const std::string nodeName( name->m_id->m_buffer ); node->setName( nodeName ); delete name; } Property *first(ddl_nullptr); in = lookForNextToken(in, end); if (*in == Grammar::OpenPropertyToken[0]) { in++; Property *prop(ddl_nullptr), *prev(ddl_nullptr); while (*in != Grammar::ClosePropertyToken[0] && in != end) { in = OpenDDLParser::parseProperty(in, end, &prop); in = lookForNextToken(in, end); if (*in != Grammar::CommaSeparator[0] && *in != Grammar::ClosePropertyToken[0]) { logInvalidTokenError(in, Grammar::ClosePropertyToken, m_logCallback); return ddl_nullptr; } if (ddl_nullptr != prop && *in != Grammar::CommaSeparator[0]) { if (ddl_nullptr == first) { first = prop; } if (ddl_nullptr != prev) { prev->m_next = prop; } prev = prop; } } ++in; } // set the properties if (ddl_nullptr != first && ddl_nullptr != node) { node->setProperties(first); } } return in; }
bool abstract_commutation( const locst &locs, impara_var_mapt &var_map, node_reft current, node_reft ancestor, node_reft mover) { const namespacet &ns=var_map.ns; std::cout << "<<<<<<<<<<<<<<<<<<<<" << std::endl; std::cout << "abstract_commutation current " << current->number << " ancestor " << ancestor->number << " mover " << mover->number << std::endl; for(; !ancestor.is_nil() && !ancestor->has_label();--ancestor); propagationt prop(ns); // turn A into a history propagationt propagation_mover( ns, mover->history, ancestor); propagation_mover.set_hidden(true); std::set<exprt> mover_reads, mover_writes; cone_of_influence(locs, var_map, propagation_mover, mover, ancestor, mover_reads, mover_writes); // split B into VCs propagationt propagation_current( ns, current->history, ancestor); propagation_current.set_hidden(true); std::set<exprt> current_reads, current_writes; cone_of_influence(locs, var_map, propagation_current, current, ancestor, current_reads, current_writes); bool dependence=shared_stept::intersect(current_reads, mover_writes) || shared_stept::intersect(current_writes, mover_reads) || shared_stept::intersect(current_writes, mover_writes); #ifdef DEBUG std::cout << "sensitivity checker VCs" << std::endl; /* for(unsigned i=0; i<vcs.size(); ++i) { std::cout << vcs[i].pretty(ns, locs) << std::endl; } */ if(dependence) { std::cout << "Dependent"<<std::endl; } else { std::cout << "Independent"<<std::endl; } shared_stept::output(mover_reads, mover_writes,std::cout); shared_stept::output(current_reads, current_writes,std::cout); #endif return !dependence; }
void VCSlider::editProperties() { VCSliderProperties prop(_app, this); if (prop.exec() == QDialog::Accepted) _app->doc()->setModified(); }
bool xmlImport::importProps() { TiXmlDocument doc(xmlFile.c_str()); if(!doc.LoadFile()){ Logger::getLogger()->debug("Error: could not load properties XML file"); return false; } TiXmlElement* pElem; TiXmlElement* pChild; TiXmlHandle hDoc(&doc); TiXmlHandle hRoot(0); DesignStore::Ptr ds = Game::getGame()->getDesignStore(); int count=0; // item count pElem = hDoc.FirstChildElement("properties").Element(); if(!pElem) return false; hRoot = TiXmlHandle(pElem); for(pElem=hRoot.FirstChild("prop").Element(); pElem != NULL; pElem = pElem->NextSiblingElement()) { TiXmlElement* pCur = 0; std::string propName, propDisplayName, propDescription, propTpclDisplay, propTpclRequirement, propIDName; int propRank; std::map<uint32_t, std::string> propertylist; pChild = hRoot.Child("prop",count).Element(); //debug: cout << "count: " << count << endl; if(pChild) { //read and set the name of the property pCur = pChild->FirstChildElement("name"); if (pCur) { propName = pCur->GetText(); if (propName.empty()) return false; } else { return false; } //read and set the name of the property pCur = pChild->FirstChildElement("displayName"); if (pCur) { propDisplayName = pCur->GetText(); if (propDisplayName.empty()) return false; } else { return false; } //read and set the ID of the property pCur = pChild->FirstChildElement("PropertyIDName"); if (pCur) { propIDName = pCur->GetText(); if (propIDName.empty()) return false; } else { return false; } //read and set the rank of the property pCur = pChild->FirstChildElement("rank"); if (pCur) { if (pCur->QueryIntAttribute("value", &(propRank)) != TIXML_SUCCESS) { return false; } } //read and set the description of the property pCur = pChild->FirstChildElement("description"); if (pCur) { propDescription = pCur->GetText(); if (propDescription.empty()) return false; } else { return false; } //read and set the tpclDisplayFunction of the property pCur = pChild->FirstChildElement("tpclDisplayFunction"); if (pCur) { propTpclDisplay = pCur->GetText(); if (propTpclDisplay.empty()) return false; } else { return false; } //read and set the tpclRequirementsFunction of the property pCur = pChild->FirstChildElement("tpclRequirementsFunction"); if (pCur) { propTpclRequirement = pCur->GetText(); if (propTpclRequirement.empty()) return false; } else { return false; } //do the property Property::Ptr prop( new Property() ); prop->addCategoryId(ds->getCategoryByName(propIDName)); prop->setRank((uint32_t)propRank); prop->setName(propName); prop->setDisplayName(propDisplayName); prop->setDescription(propDescription); prop->setTpclDisplayFunction(propTpclDisplay); prop->setTpclRequirementsFunction(propTpclRequirement); ds->addProperty(prop); } else { return false; } count++; } return true; }
int main(int argc, char** argv){ //ShowWindow(GetForegroundWindow(), SW_HIDE); Display display(WIDTH, HEIGHT, "OpenGL"); if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0){ std::cout << "ERROR: MixOpenAudio: " << Mix_GetError() << std::endl; } World world; Shader* shader = world.GetShader(); Brush br(24, 6, 24, &world, "./res/tex/pxl_cuboid.jpg"); br.Move(-2, 0, -2); Brush c1(1, 0.5, 3, &world, "./res/tex/pxl_cuboid.jpg"); c1.Move(2, 0, 2); Brush c2(1, 1.0, 3, &world, "./res/tex/pxl_cuboid.jpg"); c2.Move(3, 0, 2); Brush c3(1, 0.2, 1.5, &world, "./res/tex/pxl_cuboid.jpg"); c3.Move(6, 0.9, 2); Brush c4(1, 0.2, 1.5, &world, "./res/tex/pxl_cuboid.jpg"); c4.Move(6, 1.1, 3.5); Brush box(1, 1, 1, &world, "./res/tex/pxl_cuboid.jpg"); box.Move(6, 0.5, 6); Player player(shader); display.SetPlayer(player); Camera cammy; cammy.Init(glm::vec3(0, 0, 0), 70.0f, 1600 / 900, 0.01f, 1000.0f); Ambient amb1; shader->AddAmbient(&amb1); amb1.m_range = 3; amb1.m_intensity = 0.2; Ambient amb2; shader->AddAmbient(&amb2); amb2.SetPosition(1, 1, 1); Ambient amb3; shader->AddAmbient(&amb3); amb3.SetPosition(15, 1, 10); amb3.SetColor(0.2, 0.5, 0.7); Prop prop(world.GetMesh("./res/models/cucco.obj"), world.GetTexture("./res/models/cucco.jpg"), shader); world.AddProp(&prop); Prop stone(world.GetMesh("./res/models/salesman.obj"), world.GetTexture("./res/models/salesman.jpg"), shader); world.AddProp(&stone); stone.Scale(0.01); stone.Teleport(0, -10, 0); Sound laugh; laugh.Init("./res/sounds/sale_laugh.wav", 0.7); laugh.Load(); player.SetListener(Player_OnClick, OnClick); float count = 0.0f; while (!display.IsClosed()){ display.Clear(0.1f, 0.3f, 0.8f, 1.0f); world.Draw(&player.GetCamera()); player.DrawHUD(); display.Update(); laugh.Update(player.GetCamera().GetPos()); if (count >= 2 * PI){ count = 0; } count += 0.05f; c4.Rotate(0, 1, 0); if (glm::distance(prop.position, player.GetCamera().GetPos()) >= 2){ prop.velocity = (player.GetCamera().GetPos() - prop.position) / 64.0f; prop.velocity.y = 0; prop.SetRotate(0, PI / 2 - GetAngleRad(glm::vec2(0, 0), GetXZ(prop.velocity)), 0); } else{ prop.velocity *= 0; } prop.Rotate(0, sin(count) * PI / 360, 0); amb1.m_position = player.GetCamera().GetPos(); if (player.mouse_buttons[0]){//Left Clicking player.mouse_buttons[0] = false; stone.Teleport(world.GetAimPoint(&player)); stone.SetRotate(0, PI / 2 - GetAngleRad(glm::vec2(0, 0), GetXZ(player.GetCamera().GetPos() - stone.position)), 0); laugh.pos = stone.position; laugh.Emit(player.GetCamera().GetPos()); } world.Update(); player.Update(); world.IsCollide(&player); player.CommenceVelocity(); } Mix_CloseAudio(); Mix_Quit(); return 0; }
BOOL CMAPIContact::GetNamedProperty(LPCTSTR szFieldName,CString& strField) { CMAPINamedProperty prop(m_pUser); return prop.GetNamedProperty(szFieldName,strField); }
int main(int argc, const char *argv[]) { InitModuleObjects(); EnableSEHtoExceptionMapping(); NoQuickEditSection xxx; Owned<IFile> file = createIFile("dfuserver.xml"); if (file->exists()) globals.setown(createPTreeFromXMLFile("dfuserver.xml", ipt_caseInsensitive)); else globals.setown(readOldIni()); for (unsigned i=1;i<(unsigned)argc;i++) { const char *arg = argv[i]; StringBuffer prop("@"); StringBuffer val; while (*arg && *arg != '=') prop.append(*arg++); if (*arg) { arg++; while (isspace(*arg)) arg++; val.append(arg); prop.clip(); val.clip(); if (prop.length()>1) globals->setProp(prop.str(), val.str()); } } StringBuffer daliServer; StringBuffer queue; if (!globals->getProp("@DALISERVERS", daliServer)||!globals->getProp("@QUEUE", queue)) { usage(); globals.clear(); releaseAtoms(); return 1; } Owned<IFile> sentinelFile; bool stop = globals->getPropInt("@STOP",0)!=0; if (!stop) { sentinelFile.setown(createSentinelTarget()); removeSentinelFile(sentinelFile); StringBuffer logname; StringBuffer logdir; if (!getConfigurationDirectory(globals->queryPropTree("Directories"),"log","dfuserver",globals->queryProp("@name"),logdir)) globals->getProp("@LOG_DIR", logdir); if (logdir.length() && recursiveCreateDirectory(logdir.str())) logname.append(logdir); else appendCurrentDirectory(logname, true); if (logname.length() && logname.charAt(logname.length()-1) != PATHSEPCHAR) logname.append(PATHSEPCHAR); logname.append("dfuserver"); StringBuffer aliasLogName(logname); aliasLogName.append(".log"); fileMsgHandler = getRollingFileLogMsgHandler(logname.str(), ".log", MSGFIELD_STANDARD, false, true, NULL, aliasLogName.str()); queryLogMsgManager()->addMonitorOwn(fileMsgHandler, getCategoryLogMsgFilter(MSGAUD_all, MSGCLS_all, 1000)); } StringBuffer ftslogdir; if (getConfigurationDirectory(globals->queryPropTree("Directories"),"log","ftslave",globals->queryProp("@name"),ftslogdir)) // NB instance deliberately dfuserver's setFtSlaveLogDir(ftslogdir.str()); setRemoteSpawnSSH( globals->queryProp("SSH/@SSHidentityfile"), globals->queryProp("SSH/@SSHusername"), globals->queryProp("SSH/@SSHpassword"), globals->getPropInt("SSH/@SSHtimeout",0), globals->getPropInt("SSH/@SSHretries",3), "run_"); bool enableSNMP = globals->getPropInt("@enableSNMP")!=0; CSDSServerStatus *serverstatus=NULL; Owned<IReplicateServer> replserver; try { Owned<IGroup> serverGroup = createIGroup(daliServer.str(),DALI_SERVER_PORT); initClientProcess(serverGroup, DCR_DfuServer, 0, NULL, NULL, stop?(1000*30):MP_WAIT_FOREVER); setPasswordsFromSDS(); if(!stop) { if (globals->getPropBool("@enableSysLog",true)) UseSysLogForOperatorMessages(); serverstatus = new CSDSServerStatus("DFUserver"); setDaliServixSocketCaching(true); // speeds up lixux operations startLogMsgParentReceiver(); // for auditing connectLogMsgManagerToDali(); engine.setown(createDFUengine()); addAbortHandler(exitDFUserver); } const char *q = queue.str(); loop { StringBuffer subq; const char *comma = strchr(q,','); if (comma) subq.append(comma-q,q); else subq.append(q); if (stop) { stopDFUserver(subq.str()); } else { StringBuffer mask; mask.appendf("Queue[@name=\"%s\"][1]",subq.str()); IPropertyTree *t=serverstatus->queryProperties()->queryPropTree(mask.str()); if (t) t->setPropInt("@num",t->getPropInt("@num",0)+1); else { t = createPTree(); t->setProp("@name",subq.str()); t->setPropInt("@num",1); serverstatus->queryProperties()->addPropTree("Queue",t); } serverstatus->commitProperties(); engine->setDefaultTransferBufferSize((size32_t)globals->getPropInt("@transferBufferSize")); engine->startListener(subq.str(),serverstatus); } if (!comma) break; q = comma+1; if (!*q) break; } q = globals->queryProp("@MONITORQUEUE"); if (q&&*q) { if (stop) { stopDFUserver(q); } else { IPropertyTree *t=serverstatus->queryProperties()->addPropTree("MonitorQueue",createPTree()); t->setProp("@name",q); engine->startMonitor(q,serverstatus,globals->getPropInt("@MONITORINTERVAL",60)*1000); } } q = globals->queryProp("@REPLICATEQUEUE"); if (q&&*q) { if (stop) { // TBD? } else { replserver.setown(createReplicateServer(q)); replserver->runServer(); } } if (!stop) { serverstatus->commitProperties(); writeSentinelFile(sentinelFile); engine->joinListeners(); if (replserver.get()) replserver->stopServer(); LOG(MCprogress, unknownJob, "Exiting"); } } catch(IException *e){ EXCLOG(e, "DFU Server Exception: "); e->Release(); } catch (const char *s) { WARNLOG("DFU: %s",s); } delete serverstatus; if (stop) Sleep(2000); // give time to stop engine.clear(); globals.clear(); closeEnvironment(); closedownClientProcess(); UseSysLogForOperatorMessages(false); setDaliServixSocketCaching(false); releaseAtoms(); return 0; }
BOOL CMAPIContact::SetNamedProperty(LPCTSTR szFieldName,LPCTSTR szField,BOOL bCreate) { CMAPINamedProperty prop(m_pUser); return prop.SetNamedProperty(szFieldName,szField,bCreate); }
int GModel::readPLY(const std::string &name) { // this is crazy!? replaceCommaByDot(name); FILE *fp = Fopen(name.c_str(), "r"); if(!fp){ Msg::Error("Unable to open file '%s'", name.c_str()); return 0; } std::vector<MVertex*> vertexVector; std::map<int, std::vector<MElement*> > elements[5]; std::map<int, std::vector<double> > properties; char buffer[256], str[256], str2[256], str3[256]; std::string s1; int elementary = getMaxElementaryNumber(-1) + 1; int nbv = 0, nbf = 0; int nbprop = 0; int nbView = 0; std::vector<std::string> propName; while(!feof(fp)) { if(!fgets(buffer, sizeof(buffer), fp)) break; if(buffer[0] != '#'){ // skip comments sscanf(buffer, "%s %s", str, str2); if(!strcmp(str, "element") && !strcmp(str2, "vertex")){ sscanf(buffer, "%s %s %d", str, str2, &nbv); } if(!strcmp(str, "format") && strcmp(str2, "ascii")){ Msg::Error("Only reading of ascii PLY files implemented"); fclose(fp); return 0; } if(!strcmp(str, "property") && strcmp(str2, "list")){ nbprop++; sscanf(buffer, "%s %s %s", str, str2, str3); if (nbprop > 3) propName.push_back(s1+str3); } if(!strcmp(str, "element") && !strcmp(str2, "face")){ sscanf(buffer, "%s %s %d", str, str2, &nbf); } if(!strcmp(str, "end_header")){ nbView = nbprop -3; Msg::Info("%d elements", nbv); Msg::Info("%d triangles", nbf); Msg::Info("%d properties", nbView); vertexVector.resize(nbv); for(int i = 0; i < nbv; i++) { double x,y,z; char line[10000], *pEnd, *pEnd2, *pEnd3; if(!fgets(line, sizeof(line), fp)){ fclose(fp); return 0; } x = strtod(line, &pEnd); y = strtod(pEnd, &pEnd2); z = strtod(pEnd2, &pEnd3); vertexVector[i] = new MVertex(x, y, z); pEnd = pEnd3; std::vector<double> prop(nbView); for (int k = 0; k < nbView; k++){ prop[k]=strtod(pEnd, &pEnd2); pEnd = pEnd2; properties[k].push_back(prop[k]); } } for(int i = 0; i < nbf; i++) { if(!fgets(buffer, sizeof(buffer), fp)) break; int n[3], nbe; sscanf(buffer, "%d %d %d %d", &nbe, &n[0], &n[1], &n[2]); std::vector<MVertex*> vertices; if(!getVertices(3, n, vertexVector, vertices)){ fclose(fp); return 0; } elements[0][elementary].push_back(new MTriangle(vertices)); } } } } for(int i = 0; i < (int)(sizeof(elements) / sizeof(elements[0])); i++) _storeElementsInEntities(elements[i]); _associateEntityWithMeshVertices(); _storeVerticesInEntities(vertexVector); #if defined(HAVE_POST) // create PViews here std::vector<GEntity*> _entities; getEntities(_entities); for (int iV=0; iV< nbView; iV++){ PView *view = new PView(); PViewDataList *data = dynamic_cast<PViewDataList*>(view->getData()); for(unsigned int ii = 0; ii < _entities.size(); ii++){ for(unsigned int i = 0; i < _entities[ii]->getNumMeshElements(); i++){ MElement *e = _entities[ii]->getMeshElement(i); int numNodes = e->getNumVertices(); std::vector<double> x(numNodes), y(numNodes), z(numNodes); std::vector<double> *out = data->incrementList(1, e->getType()); for(int nod = 0; nod < numNodes; nod++) out->push_back((e->getVertex(nod))->x()); for(int nod = 0; nod < numNodes; nod++) out->push_back((e->getVertex(nod))->y()); for(int nod = 0; nod < numNodes; nod++) out->push_back((e->getVertex(nod))->z()); std::vector<double> props; int n[3]; n[0] = e->getVertex(0)->getNum()-1; n[1] = e->getVertex(1)->getNum()-1; n[2] = e->getVertex(2)->getNum()-1; if(!getProperties(3, n, properties[iV], props)){ fclose(fp); return 0; } for(int nod = 0; nod < numNodes; nod++) out->push_back(props[nod]); } } data->setName(propName[iV]); data->Time.push_back(0); data->setFileName("property.pos"); data->finalize(); } #endif fclose(fp); return 1; }
bool InterposeProperty(JSContext* cx, HandleObject target, const nsIID* iid, HandleId id, MutableHandle<JSPropertyDescriptor> descriptor) { // We only want to do interpostion on DOM instances and // wrapped natives. RootedObject unwrapped(cx, UncheckedUnwrap(target)); const js::Class* clasp = js::GetObjectClass(unwrapped); bool isCPOW = jsipc::IsWrappedCPOW(unwrapped); if (!mozilla::dom::IsDOMClass(clasp) && !IS_WN_CLASS(clasp) && !IS_PROTO_CLASS(clasp) && clasp != &OuterWindowProxyClass && !isCPOW) { return true; } XPCWrappedNativeScope* scope = ObjectScope(CurrentGlobalOrNull(cx)); MOZ_ASSERT(scope->HasInterposition()); nsCOMPtr<nsIAddonInterposition> interp = scope->GetInterposition(); InterpositionWhitelist* wl = XPCWrappedNativeScope::GetInterpositionWhitelist(interp); // We do InterposeProperty only if the id is on the whitelist of the interpostion // or if the target is a CPOW. if ((!wl || !wl->has(JSID_BITS(id.get()))) && !isCPOW) return true; JSAddonId* addonId = AddonIdOfObject(target); RootedValue addonIdValue(cx, StringValue(StringOfAddonId(addonId))); RootedValue prop(cx, IdToValue(id)); RootedValue targetValue(cx, ObjectValue(*target)); RootedValue descriptorVal(cx); nsresult rv = interp->InterposeProperty(addonIdValue, targetValue, iid, prop, &descriptorVal); if (NS_FAILED(rv)) { xpc::Throw(cx, rv); return false; } if (!descriptorVal.isObject()) return true; // We need to be careful parsing descriptorVal. |cx| is in the compartment // of the add-on and the descriptor is in the compartment of the // interposition. We could wrap the descriptor in the add-on's compartment // and then parse it. However, parsing the descriptor fetches properties // from it, and we would try to interpose on those property accesses. So // instead we parse in the interposition's compartment and then wrap the // descriptor. { JSAutoCompartment ac(cx, &descriptorVal.toObject()); if (!JS::ObjectToCompletePropertyDescriptor(cx, target, descriptorVal, descriptor)) return false; } // Always make the property non-configurable regardless of what the // interposition wants. descriptor.setAttributes(descriptor.attributes() | JSPROP_PERMANENT); if (!JS_WrapPropertyDescriptor(cx, descriptor)) return false; return true; }
QScriptObjectSnapshot::Delta QScriptObjectSnapshot::capture(const QScriptValue &object) { Delta result; QMap<QString, QScriptValueProperty> currProps; QHash<QString, int> propertyNameToIndex; { int i = 0; QScriptValueIterator it(object); while (it.hasNext()) { it.next(); QScriptValueProperty prop(it.name(), it.value(), it.flags()); currProps.insert(it.name(), prop); propertyNameToIndex.insert(it.name(), i); ++i; } if (object.prototype().isValid()) { QString __proto__ = QString::fromLatin1("__proto__"); QScriptValueProperty protoProp( __proto__, object.prototype(), QScriptValue::Undeletable | QScriptValue::ReadOnly); currProps.insert(__proto__, protoProp); propertyNameToIndex.insert(__proto__, i); ++i; } } QSet<QString> prevSet; for (int i = 0; i < m_properties.size(); ++i) prevSet.insert(m_properties.at(i).name()); QSet<QString> currSet = currProps.keys().toSet(); QSet<QString> removedProperties = prevSet - currSet; QSet<QString> addedProperties = currSet - prevSet; QSet<QString> maybeChangedProperties = currSet & prevSet; { QMap<int, QScriptValueProperty> am; QSet<QString>::const_iterator it; for (it = addedProperties.constBegin(); it != addedProperties.constEnd(); ++it) { int idx = propertyNameToIndex[*it]; am[idx] = currProps[*it]; } result.addedProperties = am.values(); } { QSet<QString>::const_iterator it; for (it = maybeChangedProperties.constBegin(); it != maybeChangedProperties.constEnd(); ++it) { const QScriptValueProperty &p1 = currProps[*it]; const QScriptValueProperty &p2 = findProperty(*it); if (!_q_equal(p1.value(), p2.value()) || (p1.flags() != p2.flags())) { result.changedProperties.append(p1); } } } result.removedProperties = removedProperties.toList(); m_properties = currProps.values(); return result; }
bool StudioModel::LoadModel( const char *pModelName ) { MDLCACHE_CRITICAL_SECTION_( g_pMDLCache ); if (!pModelName) return 0; // In the case of restore, m_pModelName == modelname if (m_pModelName != pModelName) { // Copy over the model name; we'll need it later... if (m_pModelName) { delete[] m_pModelName; } m_pModelName = new char[Q_strlen(pModelName) + 1]; strcpy( m_pModelName, pModelName ); } m_MDLHandle = g_pMDLCache->FindMDL( pModelName ); // allocate a pool for a studiohdr cache if (m_pStudioHdr != NULL) { delete m_pStudioHdr; } m_pStudioHdr = new CStudioHdr( g_pMDLCache->GetStudioHdr( m_MDLHandle ), g_pMDLCache ); // manadatory to access correct verts SetCurrentModel(); m_pPhysics = LoadPhysics( m_MDLHandle ); // Copy over all of the hitboxes; we may add and remove elements m_HitboxSets.RemoveAll(); CStudioHdr *pStudioHdr = GetStudioHdr(); int i; for ( int s = 0; s < pStudioHdr->numhitboxsets(); s++ ) { mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( s ); if ( !set ) continue; m_HitboxSets.AddToTail(); for ( i = 0; i < set->numhitboxes; ++i ) { mstudiobbox_t *pHit = set->pHitbox(i); int nIndex = m_HitboxSets[ s ].AddToTail( ); m_HitboxSets[s][nIndex] = *pHit; } // Set the name hbsetname_s *n = &m_HitboxSetNames[ m_HitboxSetNames.AddToTail() ]; strcpy( n->name, set->pszName() ); } // Copy over all of the surface props; we may change them... for ( i = 0; i < pStudioHdr->numbones(); ++i ) { mstudiobone_t* pBone = pStudioHdr->pBone(i); CUtlSymbol prop( pBone->pszSurfaceProp() ); m_SurfaceProps.AddToTail( prop ); } m_physPreviewBone = -1; bool forceOpaque = (pStudioHdr->flags() & STUDIOHDR_FLAGS_FORCE_OPAQUE) != 0; bool vertexLit = false; m_bIsTransparent = false; m_bHasProxy = false; studiohwdata_t *pHardwareData = g_pMDLCache->GetHardwareData( m_MDLHandle ); if ( !pHardwareData ) { Assert( 0 ); return false; } for( int lodID = pHardwareData->m_RootLOD; lodID < pHardwareData->m_NumLODs; lodID++ ) { studioloddata_t *pLODData = &pHardwareData->m_pLODs[lodID]; for ( i = 0; i < pLODData->numMaterials; ++i ) { if (pLODData->ppMaterials[i]->IsVertexLit()) { vertexLit = true; } if ((!forceOpaque) && pLODData->ppMaterials[i]->IsTranslucent()) { m_bIsTransparent = true; //Msg("Translucent material %s for model %s\n", pLODData->ppMaterials[i]->GetName(), pStudioHdr->name ); } if (pLODData->ppMaterials[i]->HasProxy()) { m_bHasProxy = true; } } } return true; }
void VisualSceneOCCGeometry :: BuildScene (int zoomall) { if (occgeometry -> changed == OCCGEOMETRYVISUALIZATIONFULLCHANGE) { occgeometry -> BuildVisualizationMesh (vispar.occdeflection); center = occgeometry -> Center(); rad = occgeometry -> GetBoundingBox().Diam() / 2; if (vispar.occzoomtohighlightedentity) { bool hilite = false; bool hiliteonepoint = false; Bnd_Box bb; for (int i = 1; i <= occgeometry->fmap.Extent(); i++) if (occgeometry->fvispar[i-1].IsHighlighted()) { hilite = true; BRepBndLib::Add (occgeometry->fmap(i), bb); } for (int i = 1; i <= occgeometry->emap.Extent(); i++) if (occgeometry->evispar[i-1].IsHighlighted()) { hilite = true; BRepBndLib::Add (occgeometry->emap(i), bb); } for (int i = 1; i <= occgeometry->vmap.Extent(); i++) if (occgeometry->vvispar[i-1].IsHighlighted()) { hiliteonepoint = true; BRepBndLib::Add (occgeometry->vmap(i), bb); } if (hilite || hiliteonepoint) { double x1,y1,z1,x2,y2,z2; bb.Get (x1,y1,z1,x2,y2,z2); Point<3> p1 = Point<3> (x1,y1,z1); Point<3> p2 = Point<3> (x2,y2,z2); Box<3> boundingbox(p1,p2); center = boundingbox.Center(); if (hiliteonepoint) rad = occgeometry -> GetBoundingBox().Diam() / 100; else rad = boundingbox.Diam() / 2; } } CalcTransformationMatrices(); } // Clear lists for (int i = 1; i <= linelists.Size(); i++) glDeleteLists (linelists.Elem(i), 1); linelists.SetSize(0); for (int i = 1; i <= trilists.Size(); i++) glDeleteLists (trilists.Elem(i), 1); trilists.SetSize(0); // Total wireframe linelists.Append (glGenLists (1)); glNewList (linelists.Last(), GL_COMPILE); for (int i = 1; i <= occgeometry->emap.Extent(); i++) { TopoDS_Edge edge = TopoDS::Edge(occgeometry->emap(i)); if (BRep_Tool::Degenerated(edge)) continue; if (occgeometry->evispar[i-1].IsHighlighted()) continue; Handle(Poly_PolygonOnTriangulation) aEdgePoly; Handle(Poly_Triangulation) T; TopLoc_Location aEdgeLoc; BRep_Tool::PolygonOnTriangulation(edge, aEdgePoly, T, aEdgeLoc); if(aEdgePoly.IsNull()) { (*testout) << "visualizing edge " << occgeometry->emap.FindIndex (edge) << " without using the occ visualization triangulation" << endl; double s0, s1; Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1); glBegin (GL_LINE_STRIP); for (int i = 0; i<=50; i++) { gp_Pnt p = c->Value (s0 + i*(s1-s0)/50.0); glVertex3f (p.X(),p.Y(),p.Z()); } glEnd (); continue; } int nbnodes = aEdgePoly -> NbNodes(); glBegin (GL_LINE_STRIP); for (int j = 1; j <= nbnodes; j++) { gp_Pnt p = (T -> Nodes())(aEdgePoly->Nodes()(j)).Transformed(aEdgeLoc); glVertex3f (p.X(), p.Y(), p.Z()); } glEnd (); } glEndList (); // Highlighted edge list linelists.Append (glGenLists (1)); glNewList (linelists.Last(), GL_COMPILE); for (int i = 1; i <= occgeometry->emap.Extent(); i++) if (occgeometry->evispar[i-1].IsHighlighted()) { TopoDS_Edge edge = TopoDS::Edge(occgeometry->emap(i)); if (BRep_Tool::Degenerated(edge)) continue; Handle(Poly_PolygonOnTriangulation) aEdgePoly; Handle(Poly_Triangulation) T; TopLoc_Location aEdgeLoc; BRep_Tool::PolygonOnTriangulation(edge, aEdgePoly, T, aEdgeLoc); if(aEdgePoly.IsNull()) { (*testout) << "visualizing edge " << occgeometry->emap.FindIndex (edge) << " without using the occ visualization triangulation" << endl; double s0, s1; Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1); glBegin (GL_LINE_STRIP); for (int i = 0; i<=50; i++) { gp_Pnt p = c->Value (s0 + i*(s1-s0)/50.0); glVertex3f (p.X(),p.Y(),p.Z()); } glEnd (); continue; } int nbnodes = aEdgePoly -> NbNodes(); glBegin (GL_LINE_STRIP); for (int j = 1; j <= nbnodes; j++) { gp_Pnt p = (T -> Nodes())(aEdgePoly->Nodes()(j)).Transformed(aEdgeLoc); glVertex3f (p.X(), p.Y(), p.Z()); } glEnd (); } glEndList (); // display faces trilists.Append (glGenLists (1)); glNewList (trilists.Last(), GL_COMPILE); for (int i = 1; i <= occgeometry->fmap.Extent(); i++) { if (!occgeometry->fvispar[i-1].IsVisible()) continue; glLoadName (i); float mat_col[4]; mat_col[3] = 1; TopoDS_Face face = TopoDS::Face(occgeometry->fmap(i)); if (!occgeometry->fvispar[i-1].IsHighlighted()) { // Philippose - 30/01/2009 // OpenCascade XDE Support Quantity_Color face_colour; // Philippose - 23/02/2009 // Check to see if colours have been extracted first!! // Forum bug-fox (Jean-Yves - 23/02/2009) if(!(occgeometry->face_colours.IsNull()) && (occgeometry->face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour))) { mat_col[0] = face_colour.Red(); mat_col[1] = face_colour.Green(); mat_col[2] = face_colour.Blue(); } else { mat_col[0] = 0.0; mat_col[1] = 1.0; mat_col[2] = 0.0; } } else { mat_col[0] = 0.8; mat_col[1] = 0.2; mat_col[2] = 0.2; } glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col); TopLoc_Location loc; Handle(Geom_Surface) surf = BRep_Tool::Surface (face); BRepAdaptor_Surface sf(face, Standard_False); BRepLProp_SLProps prop(sf, 1, 1e-5); Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (face, loc); if (triangulation.IsNull()) { cout << "cannot visualize face " << i << endl; occgeometry->fvispar[i-1].SetNotDrawable(); continue; } gp_Pnt2d uv; gp_Pnt pnt; gp_Vec n; glBegin (GL_TRIANGLES); int ntriangles = triangulation -> NbTriangles(); for (int j = 1; j <= ntriangles; j++) { Poly_Triangle triangle = (triangulation -> Triangles())(j); gp_Pnt p[3]; for (int k = 1; k <= 3; k++) p[k-1] = (triangulation -> Nodes())(triangle(k)).Transformed(loc); for (int k = 1; k <= 3; k++) { uv = (triangulation -> UVNodes())(triangle(k)); prop.SetParameters (uv.X(), uv.Y()); // surf->D0 (uv.X(), uv.Y(), pnt); if (prop.IsNormalDefined()) n = prop.Normal(); else { (*testout) << "Visualization of face " << i << ": Normal vector not defined" << endl; // n = gp_Vec (0,0,0); gp_Vec a(p[0],p[1]); gp_Vec b(p[0],p[2]); n = b^a; } if (face.Orientation() == TopAbs_REVERSED) n *= -1; glNormal3f (n.X(), n.Y(), n.Z()); glVertex3f (p[k-1].X(), p[k-1].Y(), p[k-1].Z()); } } glEnd (); } glEndList (); }
void c4_HandlerSeq::Restructure(c4_Field &field_, bool remove_) { //d4_assert(_field != 0); // all nested fields must be set up, before we shuffle them around for (int k = 0; k < NumHandlers(); ++k) if (IsNested(k)) { c4_Handler &h = NthHandler(k); for (int n = 0; n < NumRows(); ++n) if (h.HasSubview(n)) { SubEntry(k, n); } } for (int i = 0; i < field_.NumSubFields(); ++i) { c4_Field &nf = field_.SubField(i); c4_Property prop(nf.Type(), nf.Name()); int n = PropIndex(prop.GetId()); if (n == i) { continue; } if (n < 0) { _handlers.InsertAt(i, f4_CreateFormat(prop, *this)); NthHandler(i).Define(NumRows(), 0); } else { // move the handler to the front d4_assert(n > i); _handlers.InsertAt(i, _handlers.GetAt(n)); _handlers.RemoveAt(++n); } ClearCache(); // we mess with the order of handler, keep clearing it d4_assert(PropIndex(prop.GetId()) == i); } c4_Field *ofld = _field; // special case if we're "restructuring a view out of persistence", see below _field = remove_ ? 0 : &field_; // let handler do additional init once all have been prepared //for (int n = 0; n < NumHandlers(); ++n) // NthHandler(n).Define(NumRows(), 0); const char *desc = "[]"; c4_Field temp(desc); // all nested fields are restructured recursively for (int j = 0; j < NumHandlers(); ++j) if (IsNested(j)) { c4_Handler &h = NthHandler(j); for (int n = 0; n < NumRows(); ++n) if (h.HasSubview(n)) { c4_HandlerSeq &seq = SubEntry(j, n); if (j < NumFields()) { seq.Restructure(field_.SubField(j), false); } else if (seq._field != 0) { seq.Restructure(temp, true); } } } if (_parent == this) { delete ofld; } // the root table owns its field structure tree }
void regopt(Prog *firstp) { Reg *r, *r1; Prog *p; Graph *g; ProgInfo info; int i, z; uint32 vreg; Bits bit; if(first) { fmtinstall('Q', Qconv); exregoffset = D_R15; first = 0; } mergetemp(firstp); /* * control flow is more complicated in generated go code * than in generated c code. define pseudo-variables for * registers, so we have complete register usage information. */ nvar = NREGVAR; memset(var, 0, NREGVAR*sizeof var[0]); for(i=0; i<NREGVAR; i++) { if(regnodes[i] == N) regnodes[i] = newname(lookup(regname[i])); var[i].node = regnodes[i]; } regbits = RtoB(D_SP); for(z=0; z<BITS; z++) { externs.b[z] = 0; params.b[z] = 0; consts.b[z] = 0; addrs.b[z] = 0; ovar.b[z] = 0; } // build list of return variables setoutvar(); /* * pass 1 * build aux data structure * allocate pcs * find use and set of variables */ g = flowstart(firstp, sizeof(Reg)); if(g == nil) return; firstr = (Reg*)g->start; for(r = firstr; r != R; r = (Reg*)r->f.link) { p = r->f.prog; if(p->as == AVARDEF) continue; proginfo(&info, p); // Avoid making variables for direct-called functions. if(p->as == ACALL && p->to.type == D_EXTERN) continue; r->use1.b[0] |= info.reguse | info.regindex; r->set.b[0] |= info.regset; bit = mkvar(r, &p->from); if(bany(&bit)) { if(info.flags & LeftAddr) setaddrs(bit); if(info.flags & LeftRead) for(z=0; z<BITS; z++) r->use1.b[z] |= bit.b[z]; if(info.flags & LeftWrite) for(z=0; z<BITS; z++) r->set.b[z] |= bit.b[z]; } bit = mkvar(r, &p->to); if(bany(&bit)) { if(info.flags & RightAddr) setaddrs(bit); if(info.flags & RightRead) for(z=0; z<BITS; z++) r->use2.b[z] |= bit.b[z]; if(info.flags & RightWrite) for(z=0; z<BITS; z++) r->set.b[z] |= bit.b[z]; } } for(i=0; i<nvar; i++) { Var *v = var+i; if(v->addr) { bit = blsh(i); for(z=0; z<BITS; z++) addrs.b[z] |= bit.b[z]; } if(debug['R'] && debug['v']) print("bit=%2d addr=%d et=%-6E w=%-2d s=%N + %lld\n", i, v->addr, v->etype, v->width, v->node, v->offset); } if(debug['R'] && debug['v']) dumpit("pass1", &firstr->f, 1); /* * pass 2 * find looping structure */ flowrpo(g); if(debug['R'] && debug['v']) dumpit("pass2", &firstr->f, 1); /* * pass 3 * iterate propagating usage * back until flow graph is complete */ loop1: change = 0; for(r = firstr; r != R; r = (Reg*)r->f.link) r->f.active = 0; for(r = firstr; r != R; r = (Reg*)r->f.link) if(r->f.prog->as == ARET) prop(r, zbits, zbits); loop11: /* pick up unreachable code */ i = 0; for(r = firstr; r != R; r = r1) { r1 = (Reg*)r->f.link; if(r1 && r1->f.active && !r->f.active) { prop(r, zbits, zbits); i = 1; } } if(i) goto loop11; if(change) goto loop1; if(debug['R'] && debug['v']) dumpit("pass3", &firstr->f, 1); /* * pass 4 * iterate propagating register/variable synchrony * forward until graph is complete */ loop2: change = 0; for(r = firstr; r != R; r = (Reg*)r->f.link) r->f.active = 0; synch(firstr, zbits); if(change) goto loop2; if(debug['R'] && debug['v']) dumpit("pass4", &firstr->f, 1); /* * pass 4.5 * move register pseudo-variables into regu. */ for(r = firstr; r != R; r = (Reg*)r->f.link) { r->regu = (r->refbehind.b[0] | r->set.b[0]) & REGBITS; r->set.b[0] &= ~REGBITS; r->use1.b[0] &= ~REGBITS; r->use2.b[0] &= ~REGBITS; r->refbehind.b[0] &= ~REGBITS; r->refahead.b[0] &= ~REGBITS; r->calbehind.b[0] &= ~REGBITS; r->calahead.b[0] &= ~REGBITS; r->regdiff.b[0] &= ~REGBITS; r->act.b[0] &= ~REGBITS; } /* * pass 5 * isolate regions * calculate costs (paint1) */ r = firstr; if(r) { for(z=0; z<BITS; z++) bit.b[z] = (r->refahead.b[z] | r->calahead.b[z]) & ~(externs.b[z] | params.b[z] | addrs.b[z] | consts.b[z]); if(bany(&bit) && !r->f.refset) { // should never happen - all variables are preset if(debug['w']) print("%L: used and not set: %Q\n", r->f.prog->lineno, bit); r->f.refset = 1; } } for(r = firstr; r != R; r = (Reg*)r->f.link) r->act = zbits; rgp = region; nregion = 0; for(r = firstr; r != R; r = (Reg*)r->f.link) { for(z=0; z<BITS; z++) bit.b[z] = r->set.b[z] & ~(r->refahead.b[z] | r->calahead.b[z] | addrs.b[z]); if(bany(&bit) && !r->f.refset) { if(debug['w']) print("%L: set and not used: %Q\n", r->f.prog->lineno, bit); r->f.refset = 1; excise(&r->f); } for(z=0; z<BITS; z++) bit.b[z] = LOAD(r) & ~(r->act.b[z] | addrs.b[z]); while(bany(&bit)) { i = bnum(bit); rgp->enter = r; rgp->varno = i; change = 0; paint1(r, i); bit.b[i/32] &= ~(1L<<(i%32)); if(change <= 0) continue; rgp->cost = change; nregion++; if(nregion >= NRGN) { if(debug['R'] && debug['v']) print("too many regions\n"); goto brk; } rgp++; } } brk: qsort(region, nregion, sizeof(region[0]), rcmp); if(debug['R'] && debug['v']) dumpit("pass5", &firstr->f, 1); /* * pass 6 * determine used registers (paint2) * replace code (paint3) */ rgp = region; for(i=0; i<nregion; i++) { bit = blsh(rgp->varno); vreg = paint2(rgp->enter, rgp->varno); vreg = allreg(vreg, rgp); if(rgp->regno != 0) { if(debug['R'] && debug['v']) { Var *v; v = var + rgp->varno; print("registerize %N+%lld (bit=%2d et=%2E) in %R\n", v->node, v->offset, rgp->varno, v->etype, rgp->regno); } paint3(rgp->enter, rgp->varno, vreg, rgp->regno); } rgp++; } if(debug['R'] && debug['v']) dumpit("pass6", &firstr->f, 1); /* * free aux structures. peep allocates new ones. */ flowend(g); firstr = R; /* * pass 7 * peep-hole on basic block */ if(!debug['R'] || debug['P']) peep(firstp); /* * eliminate nops */ for(p=firstp; p!=P; p=p->link) { while(p->link != P && p->link->as == ANOP) p->link = p->link->link; if(p->to.type == D_BRANCH) while(p->to.u.branch != P && p->to.u.branch->as == ANOP) p->to.u.branch = p->to.u.branch->link; } if(debug['R']) { if(ostats.ncvtreg || ostats.nspill || ostats.nreload || ostats.ndelmov || ostats.nvar || ostats.naddr || 0) print("\nstats\n"); if(ostats.ncvtreg) print(" %4d cvtreg\n", ostats.ncvtreg); if(ostats.nspill) print(" %4d spill\n", ostats.nspill); if(ostats.nreload) print(" %4d reload\n", ostats.nreload); if(ostats.ndelmov) print(" %4d delmov\n", ostats.ndelmov); if(ostats.nvar) print(" %4d var\n", ostats.nvar); if(ostats.naddr) print(" %4d addr\n", ostats.naddr); memset(&ostats, 0, sizeof(ostats)); } }
bool QLMatchExpr::evaluate(const Properties& props) const { std::string prop(props.get(_prop, "")); return match(_expr.begin(), _expr.end(), prop.begin(), prop.end()); }
int main(int argc, char** argv) { return iface() + prop(); }
bool QLMatchRegExpr::evaluate(const Properties& props) const { std::string prop(props.get(_prop, "")); return _expr.match(prop); }