本文整理汇总了C++中UnitEmitter类的典型用法代码示例。如果您正苦于以下问题:C++ UnitEmitter类的具体用法?C++ UnitEmitter怎么用?C++ UnitEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UnitEmitter类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: txn
bool UnitRepoProxy::GetUnitStmt
::get(UnitEmitter& ue, const MD5& md5) {
try {
RepoTxn txn(m_repo);
if (!prepared()) {
std::stringstream ssSelect;
ssSelect << "SELECT unitSn,preload,bc,data FROM "
<< m_repo.table(m_repoId, "Unit")
<< " WHERE md5 == @md5;";
txn.prepare(*this, ssSelect.str());
}
RepoTxnQuery query(txn, *this);
query.bindMd5("@md5", md5);
query.step();
if (!query.row()) {
return true;
}
int64_t unitSn; /**/ query.getInt64(0, unitSn);
int preloadPriority; /**/ query.getInt(1, preloadPriority);
const void* bc; size_t bclen; /**/ query.getBlob(2, bc, bclen);
BlobDecoder dataBlob = /**/ query.getBlob(3);
ue.m_repoId = m_repoId;
ue.m_sn = unitSn;
ue.m_preloadPriority = preloadPriority;
ue.setBc(static_cast<const unsigned char*>(bc), bclen);
ue.serdeMetaData(dataBlob);
txn.commit();
} catch (RepoExc& re) {
return true;
}
return false;
}
开发者ID:jmarrama,项目名称:hhvm,代码行数:34,代码来源:unit-emitter.cpp
示例2: decodeRAT
RepoAuthType decodeRAT(const UnitEmitter& ue, const unsigned char*& pc) {
return decodeRATImpl(
pc,
[&](uint32_t id) { return ue.lookupLitstr(id); },
[&](uint32_t id) { return ue.lookupArrayType(id); }
);
}
开发者ID:simonwelsh,项目名称:hhvm,代码行数:7,代码来源:repo-auth-type-codec.cpp
示例3: txn
void UnitRepoProxy::GetUnitArraysStmt
::get(UnitEmitter& ue) {
RepoTxn txn(m_repo);
if (!prepared()) {
std::stringstream ssSelect;
ssSelect << "SELECT arrayId,array FROM "
<< m_repo.table(m_repoId, "UnitArray")
<< " WHERE unitSn == @unitSn ORDER BY arrayId ASC;";
txn.prepare(*this, ssSelect.str());
}
RepoTxnQuery query(txn, *this);
query.bindInt64("@unitSn", ue.sn());
do {
query.step();
if (query.row()) {
Id arrayId; /**/ query.getId(0, arrayId);
StringData* array; /**/ query.getStaticString(1, array);
String s(array);
Variant v = f_unserialize(s);
Id id UNUSED = ue.mergeArray(v.asArrRef().get(), array);
ASSERT(id == arrayId);
}
} while (!query.done());
txn.commit();
}
开发者ID:KWMalik,项目名称:hiphop-php,代码行数:25,代码来源:unit.cpp
示例4: txn
void PreClassRepoProxy::GetPreClassesStmt
::get(UnitEmitter& ue) {
RepoTxn txn(m_repo);
if (!prepared()) {
std::stringstream ssSelect;
ssSelect << "SELECT preClassId,name,hoistable,extraData FROM "
<< m_repo.table(m_repoId, "PreClass")
<< " WHERE unitSn == @unitSn ORDER BY preClassId ASC;";
txn.prepare(*this, ssSelect.str());
}
RepoTxnQuery query(txn, *this);
query.bindInt64("@unitSn", ue.sn());
do {
query.step();
if (query.row()) {
Id preClassId; /**/ query.getId(0, preClassId);
StringData* name; /**/ query.getStaticString(1, name);
int hoistable; /**/ query.getInt(2, hoistable);
BlobDecoder extraBlob = /**/ query.getBlob(3);
PreClassEmitter* pce = ue.newPreClassEmitter(
name, (PreClass::Hoistable)hoistable);
pce->serdeMetaData(extraBlob);
if (!SystemLib::s_inited) {
assert(pce->attrs() & AttrPersistent);
assert(pce->attrs() & AttrUnique);
}
assert(pce->id() == preClassId);
}
} while (!query.done());
txn.commit();
}
开发者ID:Alienfeel,项目名称:hhvm,代码行数:31,代码来源:preclass-emit.cpp
示例5: emit_pseudomain
void emit_pseudomain(EmitUnitState& state,
UnitEmitter& ue,
const php::Unit& unit) {
FTRACE(2, " pseudomain\n");
auto& pm = *unit.pseudomain;
ue.initMain(std::get<0>(pm.srcInfo.loc),
std::get<1>(pm.srcInfo.loc));
auto const fe = ue.getMain();
auto const info = emit_bytecode(state, ue, pm);
emit_finish_func(pm, *fe, info);
}
开发者ID:nadanomics,项目名称:hhvm,代码行数:11,代码来源:emit.cpp
示例6: emit_class
void emit_class(EmitUnitState& state,
UnitEmitter& ue,
const php::Class& cls) {
FTRACE(2, " class: {}\n", cls.name->data());
auto const pce = ue.newPreClassEmitter(
cls.name,
cls.hoistability
);
pce->init(
std::get<0>(cls.srcInfo.loc),
std::get<1>(cls.srcInfo.loc),
ue.bcPos(),
cls.attrs,
cls.parentName ? cls.parentName : s_empty.get(),
cls.srcInfo.docComment
);
pce->setUserAttributes(cls.userAttributes);
for (auto& i : cls.interfaceNames) pce->addInterface(i);
for (auto& ut : cls.usedTraitNames) pce->addUsedTrait(ut);
for (auto& req : cls.traitRequirements) pce->addTraitRequirement(req);
for (auto& tp : cls.traitPrecRules) pce->addTraitPrecRule(tp);
for (auto& ta : cls.traitAliasRules) pce->addTraitAliasRule(ta);
for (auto& m : cls.methods) {
FTRACE(2, " method: {}\n", m->name->data());
auto const fe = ue.newMethodEmitter(m->name, pce);
emit_init_func(*fe, *m);
pce->addMethod(fe);
auto const info = emit_bytecode(state, ue, *m);
emit_finish_func(*m, *fe, info);
}
for (auto& prop : cls.properties) {
pce->addProperty(
prop.name,
prop.attrs,
prop.typeConstraint,
prop.docComment,
&prop.val,
KindOfInvalid // hphpcType
);
}
for (auto& cconst : cls.constants) {
pce->addConstant(
cconst.name,
cconst.typeConstraint,
&cconst.val,
cconst.phpCode
);
}
}
开发者ID:Alienfeel,项目名称:hhvm,代码行数:53,代码来源:emit.cpp
示例7: txn
void FuncRepoProxy::GetFuncsStmt
::get(UnitEmitter& ue) {
RepoTxn txn(m_repo);
if (!prepared()) {
std::stringstream ssSelect;
ssSelect << "SELECT funcSn,preClassId,name,top,extraData "
"FROM "
<< m_repo.table(m_repoId, "Func")
<< " WHERE unitSn == @unitSn ORDER BY funcSn ASC;";
txn.prepare(*this, ssSelect.str());
}
RepoTxnQuery query(txn, *this);
query.bindInt64("@unitSn", ue.m_sn);
do {
query.step();
if (query.row()) {
int funcSn; /**/ query.getInt(0, funcSn);
Id preClassId; /**/ query.getId(1, preClassId);
StringData* name; /**/ query.getStaticString(2, name);
bool top; /**/ query.getBool(3, top);
BlobDecoder extraBlob = /**/ query.getBlob(4);
FuncEmitter* fe;
if (preClassId < 0) {
fe = ue.newFuncEmitter(name);
} else {
PreClassEmitter* pce = ue.pce(preClassId);
fe = ue.newMethodEmitter(name, pce);
bool added UNUSED = pce->addMethod(fe);
assert(added);
}
assert(fe->sn() == funcSn);
fe->top = top;
fe->serdeMetaData(extraBlob);
if (!SystemLib::s_inited && !fe->isPseudoMain()) {
assert(fe->attrs & AttrBuiltin);
if (preClassId < 0) {
assert(fe->attrs & AttrPersistent);
assert(fe->attrs & AttrUnique);
assert(fe->attrs & AttrSkipFrame);
}
}
fe->setEHTabIsSorted();
fe->finish(fe->past, true);
ue.recordFunction(fe);
}
} while (!query.done());
txn.commit();
}
开发者ID:shjgiser,项目名称:hhvm,代码行数:49,代码来源:func-emitter.cpp
示例8: emit_func
void emit_func(EmitUnitState& state, UnitEmitter& ue, const php::Func& func) {
FTRACE(2, " func {}\n", func.name->data());
auto const fe = ue.newFuncEmitter(func.name);
emit_init_func(*fe, func);
auto const info = emit_bytecode(state, ue, func);
emit_finish_func(func, *fe, info);
}
开发者ID:nadanomics,项目名称:hhvm,代码行数:7,代码来源:emit.cpp
示例9: encode_member_key
void encode_member_key(MemberKey mk, UnitEmitter& ue) {
ue.emitByte(mk.mcode);
switch (mk.mcode) {
case MEC: case MEL: case MPC: case MPL:
ue.emitIVA(mk.iva);
break;
case MEI:
ue.emitInt64(mk.int64);
break;
case MET: case MPT: case MQT:
ue.emitInt32(ue.mergeLitstr(mk.litstr));
break;
case MW:
// No immediate
break;
}
}
开发者ID:292388900,项目名称:hhvm,代码行数:21,代码来源:hhbc-codec.cpp
示例10: merge_repo_auth_type
void merge_repo_auth_type(UnitEmitter& ue, RepoAuthType rat) {
using T = RepoAuthType::Tag;
switch (rat.tag()) {
case T::OptBool:
case T::OptInt:
case T::OptSStr:
case T::OptStr:
case T::OptDbl:
case T::OptRes:
case T::OptObj:
case T::Null:
case T::Cell:
case T::Ref:
case T::InitUnc:
case T::Unc:
case T::InitCell:
case T::InitGen:
case T::Gen:
case T::Uninit:
case T::InitNull:
case T::Bool:
case T::Int:
case T::Dbl:
case T::Res:
case T::SStr:
case T::Str:
case T::Obj:
return;
case T::OptSArr:
case T::OptArr:
case T::SArr:
case T::Arr:
// We don't need to merge the litstrs in the array, because rats
// in arrays in the array type table must be using global litstr
// ids. (As the array type table itself is not associated with
// any unit.)
return;
case T::OptSubObj:
case T::OptExactObj:
case T::SubObj:
case T::ExactObj:
ue.mergeLitstr(rat.clsName());
return;
}
}
开发者ID:nadanomics,项目名称:hhvm,代码行数:48,代码来源:emit.cpp
示例11: make_repo_type
RepoAuthType make_repo_type(UnitEmitter& ue, const Type& t) {
using T = RepoAuthType::Tag;
if (t.strictSubtypeOf(TObj) || (is_opt(t) && t.strictSubtypeOf(TOptObj))) {
auto const dobj = dobj_of(t);
auto const tag =
is_opt(t)
? (dobj.type == DObj::Exact ? T::OptExactObj : T::OptSubObj)
: (dobj.type == DObj::Exact ? T::ExactObj : T::SubObj);
ue.mergeLitstr(dobj.cls.name());
return RepoAuthType { tag, dobj.cls.name() };
}
#define ASSERTT_OP(x) if (t.subtypeOf(T##x)) return RepoAuthType{T::x};
ASSERTT_OPS
#undef ASSERTT_OP
return RepoAuthType{};
}
开发者ID:2bj,项目名称:hhvm,代码行数:18,代码来源:emit.cpp
示例12: resolveArray
void RepoAuthType::resolveArray(const UnitEmitter& ue) {
auto fn = [&](const uint32_t id) {
return ue.lookupArrayType(id);
};
doResolve(fn);
}
开发者ID:simonwelsh,项目名称:hhvm,代码行数:6,代码来源:repo-auth-type.cpp
示例13: emit_class
void emit_class(EmitUnitState& state,
UnitEmitter& ue,
const php::Class& cls) {
FTRACE(2, " class: {}\n", cls.name->data());
auto const pce = ue.newPreClassEmitter(
cls.name,
cls.hoistability
);
pce->init(
std::get<0>(cls.srcInfo.loc),
std::get<1>(cls.srcInfo.loc),
ue.bcPos(),
cls.attrs,
cls.parentName ? cls.parentName : s_empty.get(),
cls.srcInfo.docComment
);
pce->setUserAttributes(cls.userAttributes);
for (auto& x : cls.interfaceNames) pce->addInterface(x);
for (auto& x : cls.usedTraitNames) pce->addUsedTrait(x);
for (auto& x : cls.requirements) pce->addClassRequirement(x);
for (auto& x : cls.traitPrecRules) pce->addTraitPrecRule(x);
for (auto& x : cls.traitAliasRules) pce->addTraitAliasRule(x);
for (auto& m : cls.methods) {
FTRACE(2, " method: {}\n", m->name->data());
auto const fe = ue.newMethodEmitter(m->name, pce);
emit_init_func(*fe, *m);
pce->addMethod(fe);
auto const info = emit_bytecode(state, ue, *m);
emit_finish_func(*m, *fe, info);
}
auto const privateProps = state.index.lookup_private_props(&cls);
auto const privateStatics = state.index.lookup_private_statics(&cls);
for (auto& prop : cls.properties) {
auto const repoTy = [&] (const PropState& ps) -> RepoAuthType {
// TODO(#3599292): we don't currently infer closure use var types.
if (is_closure(cls)) return RepoAuthType{};
auto it = ps.find(prop.name);
if (it == end(ps)) return RepoAuthType{};
auto const rat = make_repo_type(*state.index.array_table_builder(),
it->second);
merge_repo_auth_type(ue, rat);
return rat;
};
pce->addProperty(
prop.name,
prop.attrs,
prop.typeConstraint,
prop.docComment,
&prop.val,
(prop.attrs & AttrStatic) ? repoTy(privateStatics) : repoTy(privateProps)
);
}
for (auto& cconst : cls.constants) {
pce->addConstant(
cconst.name,
cconst.typeConstraint,
&cconst.val,
cconst.phpCode
);
}
}
开发者ID:brucezy,项目名称:hhvm,代码行数:66,代码来源:emit.cpp
示例14: emit_class
void emit_class(EmitUnitState& state,
UnitEmitter& ue,
const php::Class& cls) {
FTRACE(2, " class: {}\n", cls.name->data());
auto const pce = ue.newPreClassEmitter(
cls.name,
cls.hoistability
);
pce->init(
std::get<0>(cls.srcInfo.loc),
std::get<1>(cls.srcInfo.loc),
ue.bcPos(),
cls.attrs,
cls.parentName ? cls.parentName : s_empty.get(),
cls.srcInfo.docComment
);
pce->setUserAttributes(cls.userAttributes);
for (auto& x : cls.interfaceNames) pce->addInterface(x);
for (auto& x : cls.usedTraitNames) pce->addUsedTrait(x);
for (auto& x : cls.requirements) pce->addClassRequirement(x);
for (auto& x : cls.traitPrecRules) pce->addTraitPrecRule(x);
for (auto& x : cls.traitAliasRules) pce->addTraitAliasRule(x);
pce->setNumDeclMethods(cls.numDeclMethods);
pce->setIfaceVtableSlot(state.index.lookup_iface_vtable_slot(&cls));
for (auto& m : cls.methods) {
FTRACE(2, " method: {}\n", m->name->data());
auto const fe = ue.newMethodEmitter(m->name, pce);
emit_init_func(*fe, *m);
pce->addMethod(fe);
auto const info = emit_bytecode(state, ue, *m);
emit_finish_func(*m, *fe, info);
}
std::vector<Type> useVars;
if (is_closure(cls)) {
auto f = find_method(&cls, s_invoke.get());
useVars = state.index.lookup_closure_use_vars(f);
}
auto uvIt = useVars.begin();
auto const privateProps = state.index.lookup_private_props(&cls);
auto const privateStatics = state.index.lookup_private_statics(&cls);
for (auto& prop : cls.properties) {
auto const makeRat = [&] (const Type& ty) -> RepoAuthType {
if (ty.couldBe(TCls)) {
return RepoAuthType{};
}
auto const rat = make_repo_type(*state.index.array_table_builder(), ty);
merge_repo_auth_type(ue, rat);
return rat;
};
auto const privPropTy = [&] (const PropState& ps) -> Type {
if (is_closure(cls)) {
// For closures use variables will be the first properties of the
// closure object, in declaration order
if (uvIt != useVars.end()) return *uvIt++;
return Type{};
}
auto it = ps.find(prop.name);
if (it == end(ps)) return Type{};
return it->second;
};
Type propTy;
auto const attrs = prop.attrs;
if (attrs & AttrPrivate) {
propTy = privPropTy((attrs & AttrStatic) ? privateStatics : privateProps);
} else if ((attrs & AttrPublic) && (attrs & AttrStatic)) {
propTy = state.index.lookup_public_static(&cls, prop.name);
}
pce->addProperty(
prop.name,
prop.attrs,
prop.typeConstraint,
prop.docComment,
&prop.val,
makeRat(propTy)
);
}
assert(uvIt == useVars.end());
for (auto& cconst : cls.constants) {
if (!cconst.val.hasValue()) {
pce->addAbstractConstant(
cconst.name,
cconst.typeConstraint,
cconst.isTypeconst
);
} else {
pce->addConstant(
cconst.name,
cconst.typeConstraint,
&cconst.val.value(),
cconst.phpCode,
//.........这里部分代码省略.........
开发者ID:ashishbeg,项目名称:hhvm,代码行数:101,代码来源:emit.cpp
示例15: encodeRAT
void encodeRAT(UnitEmitter& ue, RepoAuthType rat) {
using T = RepoAuthType::Tag;
switch (rat.tag()) {
case T::Uninit:
case T::InitNull:
case T::Null:
case T::Int:
case T::OptInt:
case T::Dbl:
case T::OptDbl:
case T::Res:
case T::OptRes:
case T::Bool:
case T::OptBool:
case T::SStr:
case T::OptSStr:
case T::Str:
case T::OptStr:
case T::SVec:
case T::OptSVec:
case T::Vec:
case T::OptVec:
case T::SDict:
case T::OptSDict:
case T::Dict:
case T::OptDict:
case T::SKeyset:
case T::OptSKeyset:
case T::Keyset:
case T::OptKeyset:
case T::Obj:
case T::OptObj:
case T::UncArrKey:
case T::ArrKey:
case T::OptUncArrKey:
case T::OptArrKey:
case T::InitUnc:
case T::Unc:
case T::InitCell:
case T::Cell:
case T::Ref:
case T::InitGen:
case T::Gen:
ue.emitByte(static_cast<uint8_t>(rat.tag()));
break;
case T::SArr:
case T::OptSArr:
case T::Arr:
case T::OptArr:
case T::SVArr:
case T::OptSVArr:
case T::VArr:
case T::OptVArr:
case T::SDArr:
case T::OptSDArr:
case T::DArr:
case T::OptDArr:
{
auto tagByte = static_cast<uint8_t>(rat.tag());
if (rat.hasArrData()) tagByte |= kRATArrayDataBit;
ue.emitByte(tagByte);
if (rat.hasArrData()) {
ue.emitInt32(rat.arrayId());
}
break;
}
case T::ExactObj:
case T::SubObj:
case T::OptExactObj:
case T::OptSubObj:
ue.emitByte(static_cast<uint8_t>(rat.tag()));
ue.emitInt32(ue.mergeLitstr(rat.clsName()));
break;
}
}
开发者ID:simonwelsh,项目名称:hhvm,代码行数:77,代码来源:repo-auth-type-codec.cpp
示例16: emit_class
void emit_class(EmitUnitState& state,
UnitEmitter& ue,
const php::Class& cls) {
FTRACE(2, " class: {}\n", cls.name->data());
auto const pce = ue.newPreClassEmitter(
cls.name,
cls.hoistability
);
pce->init(
std::get<0>(cls.srcInfo.loc),
std::get<1>(cls.srcInfo.loc),
ue.bcPos(),
cls.attrs,
cls.parentName ? cls.parentName : s_empty.get(),
cls.srcInfo.docComment
);
pce->setUserAttributes(cls.userAttributes);
for (auto& x : cls.interfaceNames) pce->addInterface(x);
for (auto& x : cls.usedTraitNames) pce->addUsedTrait(x);
for (auto& x : cls.requirements) pce->addClassRequirement(x);
for (auto& x : cls.traitPrecRules) pce->addTraitPrecRule(x);
for (auto& x : cls.traitAliasRules) pce->addTraitAliasRule(x);
pce->setNumDeclMethods(cls.numDeclMethods);
pce->setIfaceVtableSlot(state.index.lookup_iface_vtable_slot(&cls));
for (auto& m : cls.methods) {
FTRACE(2, " method: {}\n", m->name->data());
auto const fe = ue.newMethodEmitter(m->name, pce);
emit_init_func(*fe, *m);
pce->addMethod(fe);
auto const info = emit_bytecode(state, ue, *m);
emit_finish_func(*m, *fe, info);
}
auto const privateProps = state.index.lookup_private_props(&cls);
auto const privateStatics = state.index.lookup_private_statics(&cls);
for (auto& prop : cls.properties) {
auto const makeRat = [&] (const Type& ty) -> RepoAuthType {
if (ty.couldBe(TCls)) {
return RepoAuthType{};
}
auto const rat = make_repo_type(*state.index.array_table_builder(), ty);
merge_repo_auth_type(ue, rat);
return rat;
};
auto const privPropTy = [&] (const PropState& ps) -> Type {
/*
* Skip closures, because the types of their used vars can be
* communicated via assert opcodes right now. At the time of this
* writing there was nothing to gain by including RAT's for the
* properties, since closure properties are only used internally by the
* runtime, not directly via opcodes like CGetM.
*/
if (is_closure(cls)) return Type{};
auto it = ps.find(prop.name);
if (it == end(ps)) return Type{};
return it->second;
};
Type propTy;
auto const attrs = prop.attrs;
if (attrs & AttrPrivate) {
propTy = privPropTy((attrs & AttrStatic) ? privateStatics : privateProps);
} else if ((attrs & AttrPublic) && (attrs & AttrStatic)) {
propTy = state.index.lookup_public_static(&cls, prop.name);
}
pce->addProperty(
prop.name,
prop.attrs,
prop.typeConstraint,
prop.docComment,
&prop.val,
makeRat(propTy)
);
}
for (auto& cconst : cls.constants) {
if (!cconst.val.hasValue()) {
pce->addAbstractConstant(
cconst.name,
cconst.typeConstraint,
cconst.isTypeconst
);
} else {
pce->addConstant(
cconst.name,
cconst.typeConstraint,
&cconst.val.value(),
cconst.phpCode,
cconst.isTypeconst
);
}
}
pce->setEnumBaseTy(cls.enumBaseTy);
//.........这里部分代码省略.........
开发者ID:nadanomics,项目名称:hhvm,代码行数:101,代码来源:emit.cpp
示例17: emit_typealias
void emit_typealias(UnitEmitter& ue, const php::TypeAlias& alias) {
auto const id = ue.addTypeAlias(alias);
ue.pushMergeableTypeAlias(HPHP::Unit::MergeKind::TypeAlias, id);
}
开发者ID:nadanomics,项目名称:hhvm,代码行数:4,代码来源:emit.cpp
注:本文中的UnitEmitter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论