本文整理汇总了C++中Rooted类的典型用法代码示例。如果您正苦于以下问题:C++ Rooted类的具体用法?C++ Rooted怎么用?C++ Rooted使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rooted类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scope
bool TypesystemStructHandler::startCommand(Variant::mapType &args)
{
scope().setFlag(ParserFlag::POST_HEAD, true);
// Fetch the arguments used for creating this type
const std::string &structName = args["name"].asString();
const std::string &parent = args["parent"].asString();
// Fetch the current typesystem and create the struct node
Rooted<Typesystem> typesystem = scope().selectOrThrow<Typesystem>();
Rooted<StructType> structType = typesystem->createStructType(structName);
structType->setLocation(location());
// Try to resolve the parent type and set it as parent structure
if (!parent.empty()) {
scope().resolve<StructType>(
parent, structType, logger(),
[](Handle<Node> parent, Handle<Node> structType, Logger &logger) {
if (parent != nullptr) {
structType.cast<StructType>()->setParentStructure(
parent.cast<StructType>(), logger);
}
});
}
scope().push(structType);
return true;
}
示例2: MarkExactStackRootList
static inline void
MarkExactStackRootList(JSTracer* trc, Source* s, const char* name)
{
Rooted<T>* rooter = s->roots.template gcRooters<T>();
while (rooter) {
T* addr = rooter->address();
TraceFn(trc, addr, name);
rooter = rooter->previous();
}
}
示例3: MarkExactStackRootList
static inline void
MarkExactStackRootList(JSTracer *trc, Source *s, const char *name)
{
Rooted<T> *rooter = s->template gcRooters<T>();
while (rooter) {
T *addr = rooter->address();
if (!IgnoreExactRoot(addr))
MarkFunc(trc, addr, name);
rooter = rooter->previous();
}
}
示例4: GatherRooters
static void
GatherRooters(Vector<Rooter, 0, SystemAllocPolicy> &rooters,
Rooted<void*> **thingGCRooters,
unsigned thingRootKind)
{
Rooted<void*> *rooter = thingGCRooters[thingRootKind];
while (rooter) {
Rooter r = { rooter, ThingRootKind(thingRootKind) };
JS_ALWAYS_TRUE(rooters.append(r));
rooter = rooter->previous();
}
}
示例5: MarkExactStackRooters
static inline void
MarkExactStackRooters(JSTracer *trc, Rooted<void*> rooter, ThingRootKind kind)
{
Rooted<void*> *rooter = cx->thingGCRooters[i];
while (rooter) {
MarkExactStackRoot(trc, rooter, ThingRootKind(i));
rooter = rooter->previous();
}
}
示例6: context
bool TypesystemHandler::startCommand(Variant::mapType &args)
{
// Create the typesystem instance
Rooted<Typesystem> typesystem =
context().getProject()->createTypesystem(args["name"].asString());
typesystem->setLocation(location());
// If the typesystem is defined inside a ontology, add a reference to the
// typesystem to the ontology -- do the same with a document, if no ontology
// is found
Rooted<Ontology> ontology = scope().select<Ontology>();
if (ontology != nullptr) {
ontology->reference(typesystem);
} else {
Rooted<Document> document = scope().select<Document>();
if (document != nullptr) {
document->reference(typesystem);
}
}
// Push the typesystem onto the scope, set the POST_HEAD flag to true
scope().push(typesystem);
scope().setFlag(ParserFlag::POST_HEAD, false);
return true;
}
示例7: MarkExactStackRooter
static inline void
MarkExactStackRooter(JSTracer *trc, Rooted<void*> rooter, ThingRootKind kind)
{
void **addr = (void **)rooter->address();
if (!*addr)
return;
switch (kind) {
case THING_ROOT_OBJECT: MarkObjectRoot(trc, (JSObject **)addr, "exact-object"); break;
case THING_ROOT_STRING: MarkStringRoot(trc, (JSSTring **)addr, "exact-string"); break;
case THING_ROOT_SCRIPT: MarkScriptRoot(trc, (JSScript **)addr, "exact-script"); break;
case THING_ROOT_SHAPE: MarkShapeRoot(trc, (Shape **)addr, "exact-shape"); break;
case THING_ROOT_BASE_SHAPE: MarkBaseShapeRoot(trc, (BaseShape **)addr, "exact-baseshape"); break;
case THING_ROOT_TYPE: MarkTypeRoot(trc, (types::Type *)addr, "exact-type"); break;
case THING_ROOT_TYPE_OBJECT: MarkTypeObjectRoot(trc, (types::TypeObject **)addr, "exact-typeobject"); break;
case THING_ROOT_VALUE: MarkValueRoot(trc, (Value *)addr, "exact-value"); break;
case THING_ROOT_ID: MarkIdRoot(trc, (jsid *)addr, "exact-id"); break;
case THING_ROOT_PROPERTY_ID: MarkIdRoot(trc, &((js::PropertyId *)addr)->asId(), "exact-propertyid"); break;
case THING_ROOT_BINDINGS: ((Bindings *)addr)->trace(trc); break;
default: JS_NOT_REACHED("Invalid THING_ROOT kind"); break;
}
}
示例8:
~EvalScriptGuard() {
if (script_) {
script_->cacheForEval();
EvalCacheEntry cacheEntry = {script_, lookup_.callerScript, lookup_.pc};
lookup_.str = lookupStr_;
if (lookup_.str && IsEvalCacheCandidate(script_))
cx_->runtime()->evalCache.relookupOrAdd(p_, lookup_, cacheEntry);
}
}
示例9: CallDestroyScriptHook
~EvalScriptGuard() {
if (script_) {
CallDestroyScriptHook(cx_->runtime()->defaultFreeOp(), script_);
script_->cacheForEval();
EvalCacheEntry cacheEntry = {script_, lookup_.callerScript, lookup_.pc};
lookup_.str = lookupStr_;
if (lookup_.str && IsEvalCacheCandidate(script_))
cx_->runtime()->evalCache.relookupOrAdd(p_, lookup_, cacheEntry);
}
}
示例10:
~EvalScriptGuard() {
if (script_) {
script_->cacheForEval();
EvalCacheEntry cacheEntry = {lookupStr_, script_, lookup_.callerScript, lookup_.pc};
lookup_.str = lookupStr_;
if (lookup_.str && IsEvalCacheCandidate(script_)) {
bool ok = cx_->runtime()->evalCache.relookupOrAdd(p_, lookup_, cacheEntry);
(void)ok; // Ignore failure to add cache entry.
}
}
}
示例11: lookupInEvalCache
void lookupInEvalCache(JSLinearString *str, JSScript *callerScript, jsbytecode *pc)
{
lookupStr_ = str;
lookup_.str = str;
lookup_.callerScript = callerScript;
lookup_.version = cx_->findVersion();
lookup_.pc = pc;
p_ = cx_->runtime()->evalCache.lookupForAdd(lookup_);
if (p_) {
script_ = p_->script;
cx_->runtime()->evalCache.remove(p_);
script_->uncacheForEval();
}
}
示例12: setNewScript
void setNewScript(JSScript *script) {
// JSScript::initFromEmitter has already called js_CallNewScriptHook.
JS_ASSERT(!script_ && script);
script_ = script;
script_->setActiveEval();
}