void MotionMaster::MoveIdle(MovementSlot slot) { //if (empty() || !isStatic(top())) // push(&si_idleMovement); if (!isStatic(Impl[slot])) Mutate(&si_idleMovement, slot); }
MethodSetElement MethodSetElement::withNoExceptPredicate(Predicate newNoExceptPredicate) const { return MethodSetElement(templateVariables().copy(), constPredicate().copy(), std::move(newNoExceptPredicate), requirePredicate().copy(), isStatic(), returnType(), parameterTypes().copy()); }
APCHandle::Pair APCHandle::Create(const Variant& source, bool serialized, APCHandleLevel level, bool unserializeObj) { auto createStaticStr = [&](StringData* s) { assert(s->isStatic()); if (serialized) { // It is priming, and there might not be the right class definitions // for unserialization. return APCString::MakeSerializedObject(apc_reserialize(String{s})); } auto value = new APCTypedValue(APCTypedValue::StaticStr{}, s); return APCHandle::Pair{value->getHandle(), sizeof(APCTypedValue)}; }; auto type = source.getType(); // this gets rid of the ref, if it was one switch (type) { case KindOfUninit: { auto value = APCTypedValue::tvUninit(); return {value->getHandle(), sizeof(APCTypedValue)}; } case KindOfNull: { auto value = APCTypedValue::tvNull(); return {value->getHandle(), sizeof(APCTypedValue)}; } case KindOfBoolean: { auto value = source.getBoolean() ? APCTypedValue::tvTrue() : APCTypedValue::tvFalse(); return {value->getHandle(), sizeof(APCTypedValue)}; } case KindOfInt64: { auto value = new APCTypedValue(source.getInt64()); return {value->getHandle(), sizeof(APCTypedValue)}; } case KindOfDouble: { auto value = new APCTypedValue(source.getDouble()); return {value->getHandle(), sizeof(APCTypedValue)}; } case KindOfString: { StringData* s = source.getStringData(); if (s->isStatic()) { return createStaticStr(s); } if (serialized) { // It is priming, and there might not be the right class definitions // for unserialization. return APCString::MakeSerializedObject(apc_reserialize(String{s})); } auto const st = lookupStaticString(s); if (st) { auto value = new APCTypedValue(APCTypedValue::StaticStr{}, st); return {value->getHandle(), sizeof(APCTypedValue)}; } if (level == APCHandleLevel::Outer && apcExtension::UseUncounted) { auto st = StringData::MakeUncounted(s->slice()); auto value = new APCTypedValue(APCTypedValue::UncountedStr{}, st); return {value->getHandle(), st->size() + sizeof(APCTypedValue)}; } return APCString::MakeSharedString(s); } case KindOfStaticString: return createStaticStr(source.getStringData()); case KindOfPersistentArray: case KindOfArray: { auto ad = source.getArrayData(); if (ad->isStatic()) { auto value = new APCTypedValue(APCTypedValue::StaticArr{}, ad); return {value->getHandle(), sizeof(APCTypedValue)}; } return APCArray::MakeSharedArray(source.getArrayData(), level, unserializeObj); } case KindOfObject: if (source.getObjectData()->isCollection()) { return APCCollection::Make(source.getObjectData(), level, unserializeObj); } return unserializeObj ? APCObject::Construct(source.getObjectData()) : APCString::MakeSerializedObject(apc_serialize(source)); case KindOfResource: // TODO Task #2661075: Here and elsewhere in the runtime, we convert // Resources to the empty array during various serialization operations, // which does not match Zend behavior. We should fix this. return APCArray::MakeSharedEmptyArray(); case KindOfRef: case KindOfClass: return {nullptr, 0}; } not_reached(); }
void LLDrawable::shiftPos(const LLVector4a &shift_vector) { if (isDead()) { LL_WARNS() << "Shifting dead drawable" << LL_ENDL; return; } if (mParent) { mXform.setPosition(mVObjp->getPosition()); } else { mXform.setPosition(mVObjp->getPositionAgent()); } mXform.updateMatrix(); if (isStatic()) { LLVOVolume* volume = getVOVolume(); bool rebuild = (!volume && getRenderType() != LLPipeline::RENDER_TYPE_TREE && getRenderType() != LLPipeline::RENDER_TYPE_TERRAIN && getRenderType() != LLPipeline::RENDER_TYPE_SKY && getRenderType() != LLPipeline::RENDER_TYPE_GROUND); if (rebuild) { gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE); } for (S32 i = 0; i < getNumFaces(); i++) { LLFace *facep = getFace(i); if (facep) { facep->mCenterAgent += LLVector3(shift_vector.getF32ptr()); facep->mExtents[0].add(shift_vector); facep->mExtents[1].add(shift_vector); if (rebuild && facep->hasGeometry()) { facep->clearVertexBuffer(); } } } shift(shift_vector); } else if (mSpatialBridge) { mSpatialBridge->shiftPos(shift_vector); } else if (isAvatar()) { shift(shift_vector); } mVObjp->onShift(shift_vector); }
MethodSetElement MethodSetElement::copy() const { return MethodSetElement(templateVariables().copy(), constPredicate().copy(), noexceptPredicate().copy(), requirePredicate().copy(), isStatic(), returnType(), parameterTypes().copy()); }
void StringData::setChar(int offset, char ch) { assert(offset >= 0 && offset < size() && !isStatic()); if (isImmutable()) escalate(size()); ((char*)rawdata())[offset] = ch; m_hash = 0; }
void Scene::build () { Lock<MutexSys> lock(mutex); if (isStatic() && isBuild()) { process_error(RTC_INVALID_OPERATION,"static geometries cannot get committed twice"); return; } if (!ready()) { process_error(RTC_INVALID_OPERATION,"not all buffers are unmapped"); return; } /* verify geometry in debug mode */ #if defined(DEBUG) for (size_t i=0; i<geometries.size(); i++) { if (geometries[i]) { if (!geometries[i]->verify()) { process_error(RTC_INVALID_OPERATION,"invalid geometry specified"); return; } } } #endif /* select fast code path if no intersection filter is present */ accels.select(numIntersectionFilters4,numIntersectionFilters8,numIntersectionFilters16); /* spawn build task */ TaskScheduler::EventSync event; new (&task) TaskScheduler::Task(&event,NULL,NULL,1,_task_build,this,"scene_build"); TaskScheduler::addTask(-1,TaskScheduler::GLOBAL_FRONT,&task); event.sync(); /* make static geometry immutable */ if (isStatic()) { accels.immutable(); for (size_t i=0; i<geometries.size(); i++) geometries[i]->immutable(); } /* delete geometry that is scheduled for delete */ for (size_t i=0; i<geometries.size(); i++) { Geometry* geom = geometries[i]; if (geom == NULL || geom->state != Geometry::ERASING) continue; remove(geom); } /* update bounds */ bounds = accels.bounds; intersectors = accels.intersectors; is_build = true; /* enable only algorithms choosen by application */ if ((aflags & RTC_INTERSECT1) == 0) { intersectors.intersector1.intersect = NULL; intersectors.intersector1.occluded = NULL; } if ((aflags & RTC_INTERSECT4) == 0) { intersectors.intersector4.intersect = NULL; intersectors.intersector4.occluded = NULL; } if ((aflags & RTC_INTERSECT8) == 0) { intersectors.intersector8.intersect = NULL; intersectors.intersector8.occluded = NULL; } if ((aflags & RTC_INTERSECT16) == 0) { intersectors.intersector16.intersect = NULL; intersectors.intersector16.occluded = NULL; } if (g_verbose >= 2) { std::cout << "created scene intersector" << std::endl; accels.print(2); std::cout << "selected scene intersector" << std::endl; intersectors.print(2); } }
void MotionMaster::MoveIdle(MovementSlot slot) { if(!isStatic(Impl[slot])) Mutate(&si_idleMovement, slot); }
static Variant HHVM_METHOD(Closure, bindto, const Variant& newthis, const Variant& scope) { if (RuntimeOption::RepoAuthoritative && RuntimeOption::EvalAllowScopeBinding) { raise_warning("Closure binding is not supported in RepoAuthoritative mode"); return init_null_variant; } auto const cls = this_->getVMClass(); auto const invoke = cls->getCachedInvoke(); ObjectData* od = nullptr; if (newthis.isObject()) { if (invoke->isStatic()) { raise_warning("Cannot bind an instance to a static closure"); } else { od = newthis.getObjectData(); } } else if (!newthis.isNull()) { raise_warning("Closure::bindto() expects parameter 1 to be object"); return init_null_variant; } auto const curscope = invoke->cls(); auto newscope = curscope; if (scope.isObject()) { newscope = scope.getObjectData()->getVMClass(); } else if (scope.isString()) { auto const className = scope.getStringData(); if (!className->equal(s_static.get())) { newscope = Unit::loadClass(className); if (!newscope) { raise_warning("Class '%s' not found", className->data()); return init_null_variant; } } } else if (scope.isNull()) { newscope = nullptr; } else { raise_warning("Closure::bindto() expects parameter 2 " "to be string or object"); return init_null_variant; } if (od && !newscope) { // Bound closures should be scoped. If no scope is specified, scope it to // the Closure class. newscope = static_cast<Class*>(c_Closure::classof()); } bool thisNotOfCtx = od && !od->getVMClass()->classof(newscope); if (!RuntimeOption::EvalAllowScopeBinding) { if (newscope != curscope) { raise_warning("Re-binding closure scopes is disabled"); return init_null_variant; } if (thisNotOfCtx) { raise_warning("Binding to objects not subclassed from closure " "context is disabled"); return init_null_variant; } } auto cloneObj = this_->clone(); auto clone = c_Closure::fromObject(cloneObj); Attr curattrs = invoke->attrs(); Attr newattrs = static_cast<Attr>(curattrs & ~AttrHasForeignThis); if (od) { od->incRefCount(); clone->setThis(od); if (thisNotOfCtx) { // If the bound $this is not a subclass of the context class, then we // have to pessimize translation. newattrs |= AttrHasForeignThis; } } else if (newscope) { // If we attach a scope to a function with no bound $this we need to make // the function static. newattrs |= AttrStatic; clone->setClass(newscope); } else { clone->setThis(nullptr); } // If we are changing either the scope or the attributes of the closure, we // need to re-scope its Closure subclass. if (newscope != curscope || newattrs != curattrs) { assertx(newattrs != AttrNone); auto newcls = cls->rescope(newscope, newattrs); cloneObj->setVMClass(newcls); } return Object{cloneObj}; }
ArrayData* SharedMap::EscalateForSort(ArrayData* ad) { auto a = asSharedMap(ad); auto ret = a->m_arr->loadElems(*a); assert(!ret->isStatic()); return ret; }
void OMR::Symbol::setCallSiteTableEntry() { TR_ASSERT(isStatic(), "assertion failure"); _flags2.set(CallSiteTableEntry); }
ArrayData *SharedMap::Escalate(const ArrayData* ad) { auto smap = asSharedMap(ad); auto ret = smap->m_arr->loadElems(*smap); assert(!ret->isStatic()); return ret; }
/* * Generate the XML for a function. */ static void xmlFunction(sipSpec *pt, moduleDef *mod, classDef *scope, memberDef *md, overDef *oloads, int indent, FILE *fp) { overDef *od; for (od = oloads; od != NULL; od = od->next) { int isstat; classDef *xtnds; if (od->common != md) continue; if (isPrivate(od)) continue; if (isSignal(od)) { int a; xmlIndent(indent++, fp); fprintf(fp, "<Signal name=\""); prScopedPythonName(fp, scope, md->pyname->text); fprintf(fp, "\""); xmlRealScopedName(scope, od->cppname, fp); if (hasCppSignature(od->cppsig)) { fprintf(fp, " cppsig=\""); xmlCppSignature(fp, od->cppsig, FALSE); fprintf(fp, "\""); } /* Handle the trivial case. */ if (od->pysig.nrArgs == 0) { fprintf(fp, "/>\n"); continue; } fprintf(fp, ">\n"); for (a = 0; a < od->pysig.nrArgs; ++a) { argDef *ad = &od->pysig.args[a]; xmlArgument(pt, mod, ad, FALSE, od->kwargs, FALSE, indent, fp); } xmlIndent(--indent, fp); fprintf(fp, "</Signal>\n"); continue; } xtnds = NULL; isstat = (scope == NULL || scope->iff->type == namespace_iface || isStatic(od)); if (scope == NULL && md->slot != no_slot && od->pysig.args[0].atype == class_type) { xtnds = od->pysig.args[0].u.cd; isstat = FALSE; } xmlOverload(pt, mod, scope, md, od, xtnds, isstat, indent, fp); } }
void MotionMaster::DirectDelete(_Ty curr) { if (isStatic(curr)) return; curr->Finalize(*i_owner); delete curr; }
Symbol *FuncDeclaration::toSymbol() { if (!csym) { Symbol *s; TYPE *t; const char *id; #if 0 id = ident->toChars(); #else id = mangleExact(); #endif //printf("FuncDeclaration::toSymbol(%s %s)\n", kind(), toChars()); //printf("\tid = '%s'\n", id); //printf("\ttype = %s\n", type->toChars()); s = symbol_calloc(id); slist_add(s); { s->prettyIdent = toPrettyChars(); s->Sclass = SCglobal; symbol_func(s); func_t *f = s->Sfunc; if (isVirtual() && vtblIndex != -1) f->Fflags |= Fvirtual; else if (isMember2() && isStatic()) f->Fflags |= Fstatic; f->Fstartline.Slinnum = loc.linnum; f->Fstartline.Sfilename = (char *)loc.filename; if (endloc.linnum) { f->Fendline.Slinnum = endloc.linnum; f->Fendline.Sfilename = (char *)endloc.filename; } else { f->Fendline.Slinnum = loc.linnum; f->Fendline.Sfilename = (char *)loc.filename; } t = type->toCtype(); } mangle_t msave = t->Tmangle; if (isMain()) { t->Tty = TYnfunc; t->Tmangle = mTYman_c; } else { switch (linkage) { case LINKwindows: t->Tmangle = mTYman_std; break; case LINKpascal: t->Tty = TYnpfunc; t->Tmangle = mTYman_pas; break; case LINKc: t->Tmangle = mTYman_c; break; case LINKd: t->Tmangle = mTYman_d; break; case LINKcpp: { t->Tmangle = mTYman_cpp; if (isThis() && !global.params.is64bit && global.params.isWindows) { if (((TypeFunction *)type)->varargs == 1) t->Tty = TYnfunc; else t->Tty = TYmfunc; } s->Sflags |= SFLpublic; Dsymbol *parent = toParent(); ClassDeclaration *cd = parent->isClassDeclaration(); if (cd) { ::type *tc = cd->type->toCtype(); s->Sscope = tc->Tnext->Ttag; } StructDeclaration *sd = parent->isStructDeclaration(); if (sd) { ::type *ts = sd->type->toCtype(); s->Sscope = ts->Ttag; } if (isCtorDeclaration()) s->Sfunc->Fflags |= Fctor; if (isDtorDeclaration()) s->Sfunc->Fflags |= Fdtor; break; } default: printf("linkage = %d\n", linkage); assert(0); } } if (msave) assert(msave == t->Tmangle); //printf("Tty = %x, mangle = x%x\n", t->Tty, t->Tmangle); t->Tcount++; s->Stype = t; //s->Sfielddef = this; csym = s; } return csym; }
int VarDeclaration::isImportedSymbol() { if (protection == PROTexport && !init && (isStatic() || isConst() || parent->isModule())) return TRUE; return FALSE; }
int FuncDeclaration::cvMember(unsigned char *p) { char *id; idx_t typidx; unsigned attribute; int nwritten = 0; debtyp_t *d; //printf("FuncDeclaration::cvMember() '%s'\n", toChars()); if (!type) // if not compiled in, return 0; // skip it id = toChars(); if (!p) { nwritten = 6 + cv_stringbytes(id); } else { int count; int mlen; unsigned char *q; count = 0; mlen = 2; { if (introducing) mlen += 4; mlen += cgcv.sz_idx * 2; count++; } // Allocate and fill it in d = debtyp_alloc(mlen); q = d->data; TOWORD(q,LF_METHODLIST); q += 2; // for (s = sf; s; s = s->Sfunc->Foversym) { attribute = PROTtoATTR(prot()); /* 0*4 vanilla method * 1*4 virtual method * 2*4 static method * 3*4 friend method * 4*4 introducing virtual method * 5*4 pure virtual method * 6*4 pure introducing virtual method * 7*4 reserved */ if (isStatic()) attribute |= 2*4; else if (isVirtual()) { if (introducing) { if (isAbstract()) attribute |= 6*4; else attribute |= 4*4; } else { if (isAbstract()) attribute |= 5*4; else attribute |= 1*4; } } else attribute |= 0*4; TOIDX(q,attribute); q += cgcv.sz_idx; TOIDX(q, cv4_memfunctypidx(this)); q += cgcv.sz_idx; if (introducing) { TOLONG(q, vtblIndex * PTRSIZE); q += 4; } } assert(q - d->data == mlen); typidx = cv_debtyp(d); if (typidx) { TOWORD(p,LF_METHOD); TOWORD(p + 2,count); nwritten = 4; TOIDX(p + nwritten, typidx); nwritten += cgcv.sz_idx; nwritten += cv_namestring(p + nwritten, id); } } return nwritten; }
void VarDeclaration::semantic(Scope *sc) { #if 0 printf("VarDeclaration::semantic('%s', parent = '%s')\n", toChars(), sc->parent->toChars()); printf(" type = %s\n", type ? type->toChars() : "null"); printf(" stc = x%x\n", sc->stc); printf(" storage_class = x%x\n", storage_class); printf("linkage = %d\n", sc->linkage); //if (strcmp(toChars(), "mul") == 0) halt(); #endif storage_class |= sc->stc; if (storage_class & STCextern && init) error("extern symbols cannot have initializers"); /* If auto type inference, do the inference */ int inferred = 0; if (!type) { inuse++; type = init->inferType(sc); inuse--; inferred = 1; /* This is a kludge to support the existing syntax for RAII * declarations. */ storage_class &= ~STCauto; originalType = type; } else { if (!originalType) originalType = type; type = type->semantic(loc, sc); } //printf(" semantic type = %s\n", type ? type->toChars() : "null"); type->checkDeprecated(loc, sc); linkage = sc->linkage; this->parent = sc->parent; //printf("this = %p, parent = %p, '%s'\n", this, parent, parent->toChars()); protection = sc->protection; //printf("sc->stc = %x\n", sc->stc); //printf("storage_class = x%x\n", storage_class); #if DMDV2 if (storage_class & STCgshared && global.params.safe && !sc->module->safe) { error("__gshared not allowed in safe mode; use shared"); } #endif Dsymbol *parent = toParent(); FuncDeclaration *fd = parent->isFuncDeclaration(); Type *tb = type->toBasetype(); if (tb->ty == Tvoid && !(storage_class & STClazy)) { error("voids have no value"); type = Type::terror; tb = type; } if (tb->ty == Tfunction) { error("cannot be declared to be a function"); type = Type::terror; tb = type; } if (tb->ty == Tstruct) { TypeStruct *ts = (TypeStruct *)tb; if (!ts->sym->members) { error("no definition of struct %s", ts->toChars()); } } if (tb->ty == Ttuple) { /* Instead, declare variables for each of the tuple elements * and add those. */ TypeTuple *tt = (TypeTuple *)tb; size_t nelems = Parameter::dim(tt->arguments); Objects *exps = new Objects(); exps->setDim(nelems); Expression *ie = init ? init->toExpression() : NULL; for (size_t i = 0; i < nelems; i++) { Parameter *arg = Parameter::getNth(tt->arguments, i); OutBuffer buf; buf.printf("_%s_field_%zu", ident->toChars(), i); buf.writeByte(0); const char *name = (const char *)buf.extractData(); Identifier *id = Lexer::idPool(name); Expression *einit = ie; if (ie && ie->op == TOKtuple) { einit = (Expression *)((TupleExp *)ie)->exps->data[i]; } Initializer *ti = init; if (einit) { ti = new ExpInitializer(einit->loc, einit); } VarDeclaration *v = new VarDeclaration(loc, arg->type, id, ti); //printf("declaring field %s of type %s\n", v->toChars(), v->type->toChars()); v->semantic(sc); if (sc->scopesym) { //printf("adding %s to %s\n", v->toChars(), sc->scopesym->toChars()); if (sc->scopesym->members) sc->scopesym->members->push(v); } Expression *e = new DsymbolExp(loc, v); exps->data[i] = e; } TupleDeclaration *v2 = new TupleDeclaration(loc, ident, exps); v2->isexp = 1; aliassym = v2; return; } if (storage_class & STCconst && !init && !fd) // Initialize by constructor only storage_class = (storage_class & ~STCconst) | STCctorinit; if (isConst()) { } else if (isStatic()) { } else if (isSynchronized()) { error("variable %s cannot be synchronized", toChars()); } else if (isOverride()) { error("override cannot be applied to variable"); } else if (isAbstract()) { error("abstract cannot be applied to variable"); } else if (storage_class & STCtemplateparameter) { } else if (storage_class & STCctfe) { } else { AggregateDeclaration *aad = sc->anonAgg; if (!aad) aad = parent->isAggregateDeclaration(); if (aad) { #if DMDV2 assert(!(storage_class & (STCextern | STCstatic | STCtls | STCgshared))); if (storage_class & (STCconst | STCimmutable) && init) { if (!type->toBasetype()->isTypeBasic()) storage_class |= STCstatic; } else #endif aad->addField(sc, this); } InterfaceDeclaration *id = parent->isInterfaceDeclaration(); if (id) { error("field not allowed in interface"); } /* Templates cannot add fields to aggregates */ TemplateInstance *ti = parent->isTemplateInstance(); if (ti) { // Take care of nested templates while (1) { TemplateInstance *ti2 = ti->tempdecl->parent->isTemplateInstance(); if (!ti2) break; ti = ti2; } // If it's a member template AggregateDeclaration *ad = ti->tempdecl->isMember(); if (ad && storage_class != STCundefined) { error("cannot use template to add field to aggregate '%s'", ad->toChars()); } } } #if DMDV2 if ((storage_class & (STCref | STCparameter | STCforeach)) == STCref && ident != Id::This) { error("only parameters or foreach declarations can be ref"); } #endif if (type->isauto() && !noauto) { if (storage_class & (STCfield | STCout | STCref | STCstatic) || !fd) { error("globals, statics, fields, ref and out parameters cannot be auto"); } if (!(storage_class & (STCauto | STCscope))) { if (!(storage_class & STCparameter) && ident != Id::withSym) error("reference to scope class must be scope"); } } enum TOK op = TOKconstruct; if (!init && !sc->inunion && !isStatic() && !isConst() && fd && !(storage_class & (STCfield | STCin | STCforeach)) && type->size() != 0) { // Provide a default initializer //printf("Providing default initializer for '%s'\n", toChars()); if (type->ty == Tstruct && ((TypeStruct *)type)->sym->zeroInit == 1) { /* If a struct is all zeros, as a special case * set it's initializer to the integer 0. * In AssignExp::toElem(), we check for this and issue * a memset() to initialize the struct. * Must do same check in interpreter. */ Expression *e = new IntegerExp(loc, 0, Type::tint32); Expression *e1; e1 = new VarExp(loc, this); e = new AssignExp(loc, e1, e); e->op = TOKconstruct; e->type = e1->type; // don't type check this, it would fail init = new ExpInitializer(loc, e); return; } else if (type->ty == Ttypedef) { TypeTypedef *td = (TypeTypedef *)type; if (td->sym->init) { init = td->sym->init; ExpInitializer *ie = init->isExpInitializer(); if (ie) // Make copy so we can modify it init = new ExpInitializer(ie->loc, ie->exp); } else init = getExpInitializer(); } else { init = getExpInitializer(); } // Default initializer is always a blit op = TOKblit; } if (init) { sc = sc->push(); sc->stc &= ~(STC_TYPECTOR | STCpure | STCnothrow | STCref); ArrayInitializer *ai = init->isArrayInitializer(); if (ai && tb->ty == Taarray) { init = ai->toAssocArrayInitializer(); } StructInitializer *si = init->isStructInitializer(); ExpInitializer *ei = init->isExpInitializer(); // See if initializer is a NewExp that can be allocated on the stack if (ei && isScope() && ei->exp->op == TOKnew) { NewExp *ne = (NewExp *)ei->exp; if (!(ne->newargs && ne->newargs->dim)) { ne->onstack = 1; onstack = 1; if (type->isBaseOf(ne->newtype->semantic(loc, sc), NULL)) onstack = 2; } } // If inside function, there is no semantic3() call if (sc->func) { // If local variable, use AssignExp to handle all the various // possibilities. if (fd && !isStatic() && !isConst() && !init->isVoidInitializer()) { //printf("fd = '%s', var = '%s'\n", fd->toChars(), toChars()); if (!ei) { Expression *e = init->toExpression(); if (!e) { init = init->semantic(sc, type); e = init->toExpression(); if (!e) { error("is not a static and cannot have static initializer"); return; } } ei = new ExpInitializer(init->loc, e); init = ei; } Expression *e1 = new VarExp(loc, this); Type *t = type->toBasetype(); if (t->ty == Tsarray && !(storage_class & (STCref | STCout))) { ei->exp = ei->exp->semantic(sc); if (!ei->exp->implicitConvTo(type)) { int dim = ((TypeSArray *)t)->dim->toInteger(); // If multidimensional static array, treat as one large array while (1) { t = t->nextOf()->toBasetype(); if (t->ty != Tsarray) break; dim *= ((TypeSArray *)t)->dim->toInteger(); e1->type = new TypeSArray(t->nextOf(), new IntegerExp(0, dim, Type::tindex)); } } e1 = new SliceExp(loc, e1, NULL, NULL); } else if (t->ty == Tstruct) { ei->exp = ei->exp->semantic(sc); ei->exp = resolveProperties(sc, ei->exp); StructDeclaration *sd = ((TypeStruct *)t)->sym; #if DMDV2 /* Look to see if initializer is a call to the constructor */ if (sd->ctor && // there are constructors ei->exp->type->ty == Tstruct && // rvalue is the same struct ((TypeStruct *)ei->exp->type)->sym == sd && ei->exp->op == TOKstar) { /* Look for form of constructor call which is: * *__ctmp.ctor(arguments...) */ PtrExp *pe = (PtrExp *)ei->exp; if (pe->e1->op == TOKcall) { CallExp *ce = (CallExp *)pe->e1; if (ce->e1->op == TOKdotvar) { DotVarExp *dve = (DotVarExp *)ce->e1; if (dve->var->isCtorDeclaration()) { /* It's a constructor call, currently constructing * a temporary __ctmp. */ /* Before calling the constructor, initialize * variable with a bit copy of the default * initializer */ Expression *e = new AssignExp(loc, new VarExp(loc, this), t->defaultInit(loc)); e->op = TOKblit; e->type = t; ei->exp = new CommaExp(loc, e, ei->exp); /* Replace __ctmp being constructed with e1 */ dve->e1 = e1; return; } } } } #endif if (!ei->exp->implicitConvTo(type)) { /* Look for opCall * See bugzilla 2702 for more discussion */ Type *ti = ei->exp->type->toBasetype(); // Don't cast away invariant or mutability in initializer if (search_function(sd, Id::call) && /* Initializing with the same type is done differently */ !(ti->ty == Tstruct && t->toDsymbol(sc) == ti->toDsymbol(sc))) { // Rewrite as e1.call(arguments) Expression * eCall = new DotIdExp(loc, e1, Id::call); ei->exp = new CallExp(loc, eCall, ei->exp); } } } ei->exp = new AssignExp(loc, e1, ei->exp); ei->exp->op = TOKconstruct; canassign++; ei->exp = ei->exp->semantic(sc); canassign--; ei->exp->optimize(WANTvalue); } else { init = init->semantic(sc, type); if (fd && isConst() && !isStatic()) { // Make it static storage_class |= STCstatic; } } } else if (isConst() || isFinal() || parent->isAggregateDeclaration()) { /* Because we may need the results of a const declaration in a * subsequent type, such as an array dimension, before semantic2() * gets ordinarily run, try to run semantic2() now. * Ignore failure. */ if (!global.errors && !inferred) { unsigned errors = global.errors; global.gag++; //printf("+gag\n"); Expression *e; Initializer *i2 = init; inuse++; if (ei) { e = ei->exp->syntaxCopy(); e = e->semantic(sc); e = e->implicitCastTo(sc, type); } else if (si || ai) { i2 = init->syntaxCopy(); i2 = i2->semantic(sc, type); } inuse--; global.gag--; //printf("-gag\n"); if (errors != global.errors) // if errors happened { if (global.gag == 0) global.errors = errors; // act as if nothing happened #if DMDV2 /* Save scope for later use, to try again */ scope = new Scope(*sc); scope->setNoFree(); #endif } else if (ei) { e = e->optimize(WANTvalue | WANTinterpret); if (e->op == TOKint64 || e->op == TOKstring || e->op == TOKfloat64) { ei->exp = e; // no errors, keep result } #if DMDV2 else { /* Save scope for later use, to try again */ scope = new Scope(*sc); scope->setNoFree(); } #endif } else init = i2; // no errors, keep result } } sc = sc->pop(); } }
void StringData::inc() { assert(!isStatic()); assert(!empty()); if (isImmutable()) { escalate(m_len + 1); } else { reserve(m_len + 1); } m_hash = 0; enum class CharKind { UNKNOWN, LOWER_CASE, UPPER_CASE, NUMERIC }; auto const len = m_len; auto const s = m_data; int carry = 0; int pos = len - 1; auto last = CharKind::UNKNOWN; // Shut up the compiler warning int ch; while (pos >= 0) { ch = s[pos]; if (ch >= 'a' && ch <= 'z') { if (ch == 'z') { s[pos] = 'a'; carry=1; } else { s[pos]++; carry=0; } last = CharKind::LOWER_CASE; } else if (ch >= 'A' && ch <= 'Z') { if (ch == 'Z') { s[pos] = 'A'; carry=1; } else { s[pos]++; carry=0; } last = CharKind::UPPER_CASE; } else if (ch >= '0' && ch <= '9') { if (ch == '9') { s[pos] = '0'; carry=1; } else { s[pos]++; carry=0; } last = CharKind::NUMERIC; } else { carry=0; break; } if (carry == 0) { break; } pos--; } if (carry) { if (UNLIKELY(len + 1 > MaxSize)) { throw InvalidArgumentException("len > 2^31-2", len); } assert(len + 2 <= capacity()); memmove(s + 1, s, len); s[len + 1] = '\0'; m_len = len + 1; switch (last) { case CharKind::NUMERIC: s[0] = '1'; break; case CharKind::UPPER_CASE: s[0] = 'A'; break; case CharKind::LOWER_CASE: s[0] = 'a'; break; default: break; } } }
void Declaration::checkModify(Loc loc, Scope *sc, Type *t) { if (sc->incontract && isParameter()) error(loc, "cannot modify parameter '%s' in contract", toChars()); if (sc->incontract && isResult()) error(loc, "cannot modify result '%s' in contract", toChars()); if (isCtorinit() && !t->isMutable()) { // It's only modifiable if inside the right constructor Dsymbol *s = sc->func; while (1) { FuncDeclaration *fd = NULL; if (s) fd = s->isFuncDeclaration(); if (fd && ((fd->isCtorDeclaration() && storage_class & STCfield) || (fd->isStaticCtorDeclaration() && !(storage_class & STCfield))) && fd->toParent() == toParent() ) { VarDeclaration *v = isVarDeclaration(); assert(v); v->ctorinit = 1; //printf("setting ctorinit\n"); } else { if (s) { s = s->toParent2(); continue; } else { const char *p = isStatic() ? "static " : ""; error(loc, "can only initialize %sconst %s inside %sconstructor", p, toChars(), p); } } break; } } else { VarDeclaration *v = isVarDeclaration(); if (v && v->canassign == 0) { const char *p = NULL; if (isConst()) p = "const"; else if (isImmutable()) p = "immutable"; else if (storage_class & STCmanifest) p = "enum"; else if (!t->isAssignable()) p = "struct with immutable members"; if (p) { error(loc, "cannot modify %s", p); } } } }
Scene::Scene (RTCSceneFlags sflags, RTCAlgorithmFlags aflags) : flags(sflags), aflags(aflags), numMappedBuffers(0), is_build(false), needTriangles(false), needVertices(false), numTriangleMeshes(0), numTriangleMeshes2(0), numTriangles(0), numTriangles2(0), numBezierCurves(0), numBezierCurves2(0), numUserGeometries1(0), numIntersectionFilters4(0), numIntersectionFilters8(0), numIntersectionFilters16(0) { if (g_scene_flags != -1) flags = (RTCSceneFlags) g_scene_flags; geometries.reserve(128); #if defined(__MIC__) accels.add( BVH4mb::BVH4mbTriangle1ObjectSplitBinnedSAH(this) ); accels.add( BVH4i::BVH4iVirtualGeometryBinnedSAH(this) ); accels.add( BVH4Hair::BVH4HairBinnedSAH(this) ); if (g_verbose >= 1) { std::cout << "scene flags: static " << isStatic() << " compact = " << isCompact() << " high quality = " << isHighQuality() << " robust = " << isRobust() << std::endl; } if (g_tri_accel == "default" || g_tri_accel == "bvh4i") { if (g_tri_builder == "default") { if (isStatic()) { if (g_verbose >= 1) std::cout << "STATIC BUILDER MODE" << std::endl; if ( isCompact() ) accels.add(BVH4i::BVH4iTriangle1MemoryConservativeBinnedSAH(this)); else if ( isHighQuality() ) accels.add(BVH4i::BVH4iTriangle1ObjectSplitBinnedSAH(this)); else accels.add(BVH4i::BVH4iTriangle1ObjectSplitBinnedSAH(this)); } else { if (g_verbose >= 1) std::cout << "DYNAMIC BUILDER MODE" << std::endl; accels.add(BVH4i::BVH4iTriangle1ObjectSplitMorton(this)); } } else { if (g_tri_builder == "sah" || g_tri_builder == "bvh4i" || g_tri_builder == "bvh4i.sah") { accels.add(BVH4i::BVH4iTriangle1ObjectSplitBinnedSAH(this)); } else if (g_tri_builder == "fast" || g_tri_builder == "morton") { accels.add(BVH4i::BVH4iTriangle1ObjectSplitMorton(this)); } else if (g_tri_builder == "fast_enhanced" || g_tri_builder == "morton.enhanced") { accels.add(BVH4i::BVH4iTriangle1ObjectSplitEnhancedMorton(this)); } else if (g_tri_builder == "high_quality" || g_tri_builder == "presplits") { accels.add(BVH4i::BVH4iTriangle1PreSplitsBinnedSAH(this)); } else if (g_tri_builder == "compact" || g_tri_builder == "memory_conservative") { accels.add(BVH4i::BVH4iTriangle1MemoryConservativeBinnedSAH(this)); } else if (g_tri_builder == "morton64") { accels.add(BVH4i::BVH4iTriangle1ObjectSplitMorton64Bit(this)); } else throw std::runtime_error("unknown builder "+g_tri_builder+" for BVH4i<Triangle1>"); } } else throw std::runtime_error("unknown accel "+g_tri_accel); #else createTriangleAccel(); accels.add(BVH4MB::BVH4MBTriangle1v(this)); accels.add(BVH4::BVH4UserGeometry(this)); createHairAccel(); #endif }
void StringData::destructStatic() { assert(checkSane() && isStatic()); assert(isFlat()); low_free(this); }
void MotionMaster::MoveIdle() { //! Should be preceded by MovementExpired or Clear if there's an overlying movementgenerator active if (empty() || !isStatic(top())) Mutate(&si_idleMovement, MOTION_SLOT_IDLE); }
String c_Continuation::t_getorigfuncname() { auto const origName = m_origFunc->isClosureBody() ? s__closure_.get() : m_origFunc->name(); assert(origName->isStatic()); return String(const_cast<StringData*>(origName)); }
MethodSetElement MethodSetElement::withRequirement(Predicate requirement) const { return MethodSetElement(templateVariables().copy(), constPredicate().copy(), noexceptPredicate().copy(), Predicate::And(requirePredicate().copy(), std::move(requirement)), isStatic(), returnType(), parameterTypes().copy()); }
ArrayData *APCLocalArray::Escalate(const ArrayData* ad) { auto smap = asSharedArray(ad); auto ret = smap->loadElems(); assert(!ret->isStatic()); return ret; }
FunctionType MethodSetElement::createFunctionType(const bool isTemplated) const { const bool isVarArg = false; const bool isMethod = !isStatic(); FunctionAttributes attributes(isVarArg, isMethod, isTemplated, noexceptPredicate().copy()); return FunctionType(std::move(attributes), returnType(), parameterTypes().copy()); }
ArrayData* APCLocalArray::EscalateForSort(ArrayData* ad) { auto a = asSharedArray(ad); auto ret = a->loadElems(); assert(!ret->isStatic()); return ret; }
void MotionMaster::MoveIdle() { if (empty() || !isStatic(top())) push(&si_idleMovement); }
void Variant::setEvalScalar() { assertx(cellIsPlausible(*this)); auto const do_array = [this]{ auto parr = m_data.parr; if (!parr->isStatic()) { auto ad = ArrayData::GetScalarArray(parr); assert(ad->isStatic()); m_data.parr = ad; decRefArr(parr); } }; switch (m_type) { case KindOfUninit: case KindOfNull: case KindOfBoolean: case KindOfInt64: case KindOfDouble: return; case KindOfString: m_type = KindOfPersistentString; case KindOfPersistentString: { auto pstr = m_data.pstr; if (!pstr->isStatic()) { StringData *sd = makeStaticString(pstr); decRefStr(pstr); m_data.pstr = sd; assert(m_data.pstr->isStatic()); } return; } case KindOfVec: m_type = KindOfPersistentVec; case KindOfPersistentVec: do_array(); return; case KindOfDict: m_type = KindOfPersistentDict; case KindOfPersistentDict: do_array(); return; case KindOfKeyset: m_type = KindOfPersistentKeyset; case KindOfPersistentKeyset: do_array(); return; case KindOfArray: m_type = KindOfPersistentArray; case KindOfPersistentArray: do_array(); return; case KindOfObject: case KindOfResource: case KindOfRef: case KindOfClass: break; } not_reached(); }