本文整理汇总了C++中CodeGenerator::callInfoTop方法的典型用法代码示例。如果您正苦于以下问题:C++ CodeGenerator::callInfoTop方法的具体用法?C++ CodeGenerator::callInfoTop怎么用?C++ CodeGenerator::callInfoTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator::callInfoTop方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outputCPPImpl
void ArrayElementExpression::outputCPPImpl(CodeGenerator &cg,
AnalysisResultPtr ar) {
if (m_global) {
if (!m_globalName.empty()) {
VariableTablePtr variables = getScope()->getVariables();
string name = variables->getGlobalVariableName(cg, ar, m_globalName);
cg_printf("g->%s", name.c_str());
} else {
cg_printf("((LVariableTable *)g)->get(");
m_offset->outputCPP(cg, ar);
cg_printf(")");
}
} else {
TypePtr type = m_variable->getActualType();
if (hasContext(UnsetContext)) {
cg_printf("unsetLval(");
m_variable->outputCPP(cg, ar);
cg_printf(", ");
} else {
if (m_variable->is(Expression::KindOfScalarExpression) ||
(type && (type->isInteger() ||
type->is(Type::KindOfDouble) ||
type->is(Type::KindOfObject) ||
type->is(Type::KindOfBoolean)))) {
cg_printf(type && type->is(Type::KindOfString) ? "((String)" :
"((Variant)");
m_variable->outputCPP(cg, ar);
cg_printf(")");
} else {
TypePtr act;
if (!m_variable->hasCPPTemp() && m_variable->getImplementedType() &&
type->is(Type::KindOfArray) &&
!Type::SameType(m_variable->getImplementedType(), type)) {
act = type;
type = m_variable->getImplementedType();
m_variable->setActualType(m_variable->getImplementedType());
}
m_variable->outputCPP(cg, ar);
if (act) {
m_variable->setActualType(act);
}
}
}
if (m_offset) {
bool lvalAt = false;
bool rvalAt = false;
bool byRef = false;
bool arrRef = false;
const char *sep = ", AccessFlags::";
if (hasContext(UnsetContext)) {
// do nothing
} else if (hasContext(InvokeArgument) && cg.callInfoTop() != -1) {
cg_printf(".argvalAt(cit%d->isRef(%d), ", cg.callInfoTop(), m_argNum);
} else if (m_context & (LValue|RefValue|DeepReference)) {
cg_printf(".lvalAt(");
lvalAt = true;
} else {
byRef = (m_context & AccessContext) &&
(!type || !type->is(Type::KindOfString));
arrRef = byRef && type && type->is(Type::KindOfArray);
cg_printf(".rval%s%s(",
arrRef || !byRef ? "At" : "", byRef ? "Ref" : "");
rvalAt = true;
}
m_offset->outputCPP(cg, ar);
if (!type || !type->is(Type::KindOfString)) {
if (rvalAt) {
if (byRef && !arrRef) {
const string &tmp = cg.getReferenceTemp();
cg_printf(", %s", tmp.empty() ? "Variant()" : tmp.c_str());
}
if (!hasContext(ExistContext)) {
cg_printf(", AccessFlags::Error"); // raise undefined index error
sep = "_";
}
} else if (lvalAt) {
if (hasContext(AccessContext)) {
// Dont copy the array if the element is an object, or
// is referenced.
// This is safe in AccessContext (the parent is an ArrayElement,
// or an ObjectProperty) because applying [] to an object will
// either invoke OffsetGet, or fatal, and modifications to a
// referenced element would be reflected in all copies
// of the array anyway.
cg_printf(", AccessFlags::CheckExist");
sep = "_";
}
}
ScalarExpressionPtr sc =
dynamic_pointer_cast<ScalarExpression>(m_offset);
if (!hasContext(UnsetContext) && sc && sc->isLiteralString()) {
String s(sc->getLiteralString());
int64 n;
if (!s.get()->isStrictlyInteger(n)) {
if (lvalAt || rvalAt) {
cg_printf("%sKey", sep);
} else {
cg_printf(", true"); // skip toKey() at run time
}
}
//.........这里部分代码省略.........
示例2: preOutputStash
void SimpleVariable::preOutputStash(CodeGenerator &cg, AnalysisResultPtr ar,
int state)
{
if (hasCPPTemp()) return;
VariableTablePtr vt(getScope()->getVariables());
if (hasContext(InvokeArgument) && !hasContext(AccessContext) &&
(isLocalExprAltered() || (m_sym && m_sym->isReseated())) &&
!m_globals /* $GLOBALS always has reference semantics */ &&
hasAssignableCPPVariable()) {
const string &cppName = getAssignableCPPVariable(ar);
ASSERT(!cppName.empty());
if (m_sym && m_sym->isReseated()) {
const string &arg_temp = genCPPTemp(cg, ar);
cg.wrapExpressionBegin();
cg_printf("const Variant %s = cit%d->isRef(%d) ? "
"Variant(strongBind(%s)) : %s;\n",
arg_temp.c_str(),
cg.callInfoTop(),
m_argNum,
cppName.c_str(),
cppName.c_str());
setCPPTemp(arg_temp);
} else {
Expression::preOutputStash(cg, ar, state);
const string &ref_temp = cppTemp();
ASSERT(!ref_temp.empty());
const string ©_temp = genCPPTemp(cg, ar);
const string &arg_temp = genCPPTemp(cg, ar);
cg_printf("const Variant %s = %s;\n",
copy_temp.c_str(),
cppName.c_str());
cg_printf("const Variant &%s = cit%d->isRef(%d) ? %s : %s;\n",
arg_temp.c_str(),
cg.callInfoTop(),
m_argNum,
ref_temp.c_str(),
copy_temp.c_str());
setCPPTemp(arg_temp);
}
return;
}
if (hasAnyContext(RefValue|RefParameter)) {
if (!hasAnyContext(InvokeArgument|AccessContext|
AssignmentRHS|ReturnContext) &&
!m_globals && (!m_sym || m_sym->isReseated()) &&
hasAssignableCPPVariable()) {
cg.wrapExpressionBegin();
const string &cppName = getAssignableCPPVariable(ar);
ASSERT(!cppName.empty());
const string &tmp = genCPPTemp(cg, ar);
cg_printf("VRefParamValue %s((ref(%s)));\n",
tmp.c_str(), cppName.c_str());
setCPPTemp(tmp);
setContext(NoRefWrapper);
}
return;
} else if (hasContext(LValue)) {
return;
}
if (!m_alwaysStash && !(state & StashVars)) return;
Expression::preOutputStash(cg, ar, state);
}
示例3: outputCPPObjProperty
void ObjectPropertyExpression::outputCPPObjProperty(CodeGenerator &cg,
AnalysisResultPtr ar,
int doExist) {
string func = Option::ObjectPrefix;
const char *error = ", true";
std::string context = "";
bool doUnset = m_context & LValue && m_context & UnsetContext;
bool needTemp = false;
if (cg.getOutput() != CodeGenerator::SystemCPP) {
context = originalClassName(cg, true);
}
if (doUnset) {
func = "o_unset";
error = "";
} else if (doExist) {
func = doExist > 0 ? "o_isset" : "o_empty";
error = "";
} else {
if (m_context & ExistContext) {
error = ", false";
}
if (m_context & InvokeArgument) {
ASSERT(cg.callInfoTop() != -1);
func += "argval";
} else if (m_context & (LValue | RefValue | DeepReference | UnsetContext)) {
if (m_context & UnsetContext) {
assert(!(m_context & LValue)); // handled by doUnset
func += "unsetLval";
} else {
func += "lval";
}
error = "";
needTemp = true;
} else {
func += "get";
if (isNonPrivate(ar)) {
func += "Public";
context = "";
}
}
}
if (m_valid && doExist) cg_printf(doExist > 0 ? "isset(" : "empty(");
bool flag = outputCPPObject(cg, ar, doUnset || (!m_valid && doExist));
if (flag) {
cg_printf("id(");
outputCPPProperty(cg, ar);
cg_printf(")");
if (doExist) cg_printf(", %s", doExist > 0 ? "false" : "true");
cg_printf(")");
} else if (!doUnset && m_valid) {
assert(m_object->getType()->isSpecificObject());
ScalarExpressionPtr name =
dynamic_pointer_cast<ScalarExpression>(m_property);
cg_printf("%s%s", Option::PropertyPrefix, name->getString().c_str());
if (doExist) cg_printf(")");
} else {
cg_printf("%s(", func.c_str());
if (hasContext(InvokeArgument)) {
cg_printf("cit%d->isRef(%d), ", cg.callInfoTop(), m_argNum);
}
outputCPPProperty(cg, ar);
if (needTemp) {
const string &tmp = cg.getReferenceTemp();
context = ", " + (tmp.empty() ? "Variant()" : tmp) + context;
}
cg_printf("%s%s)", error, context.c_str());
}
}
示例4: outputCPPImpl
void ArrayElementExpression::outputCPPImpl(CodeGenerator &cg,
AnalysisResultPtr ar) {
if (m_global) {
if (!m_globalName.empty()) {
VariableTablePtr variables = getScope()->getVariables();
string name = variables->getGlobalVariableName(ar, m_globalName);
cg_printf("g->%s", name.c_str());
} else {
cg_printf("((LVariableTable *)g)->get(");
m_offset->outputCPP(cg, ar);
cg_printf(")");
}
} else {
TypePtr type = m_variable->getType();
if (hasContext(UnsetContext)) {
cg_printf("unsetLval(");
m_variable->outputCPP(cg, ar);
cg_printf(", ");
} else {
if (m_variable->is(Expression::KindOfScalarExpression) ||
(type && (type->isInteger() ||
type->is(Type::KindOfDouble) ||
type->is(Type::KindOfObject) ||
type->is(Type::KindOfBoolean)))) {
cg_printf(type && type->is(Type::KindOfString) ? "((String)" :
"((Variant)");
m_variable->outputCPP(cg, ar);
cg_printf(")");
} else {
m_variable->outputCPP(cg, ar);
}
}
if (m_offset) {
bool lvalAt = false;
bool rvalAt = false;
bool byRef = false;
bool arrRef = false;
const char *sep = ", AccessFlags::";
bool isArrayType = type && type->is(Type::KindOfArray);
bool isStringType = type && type->is(Type::KindOfString);
bool isRealChainRoot = isChainRoot() && hasCPPCseTemp();
TypePtr t;
bool hasCseStore = isRealChainRoot && GetCseTempInfo(
ar,
static_pointer_cast<Expression>(shared_from_this()),
t);
if (hasContext(UnsetContext)) {
// do nothing
} else if (hasContext(InvokeArgument) && cg.callInfoTop() != -1) {
ASSERT(!isRealChainRoot); // TODO: handle this case
cg_printf(".argvalAt(cit%d->isRef(%d), ", cg.callInfoTop(), m_argNum);
} else if (m_context & (LValue|RefValue|DeepReference)) {
// if we see an array access element in LValue context, the
// type inference pass will never infer its type to be a string
ASSERT(!isStringType);
if (isRealChainRoot && !isArrayType) {
// chain roots for non array types (variants) should call
// lvalRef()
cg_printf(".lvalRef(");
} else {
cg_printf(".lvalAt(");
}
lvalAt = true;
} else {
byRef =
((m_context & AccessContext) || isRealChainRoot) && !isStringType;
arrRef = byRef && isArrayType;
cg_printf(".rval%s%s(",
arrRef || !byRef ? "At" : "", byRef ? "Ref" : "");
rvalAt = true;
}
m_offset->outputCPP(cg, ar);
if (!isStringType) {
if (rvalAt) {
if (byRef && !arrRef) {
string tmp;
if (hasCseStore) {
tmp = string(Option::CseTempStoragePrefix) + m_cppCseTemp;
} else {
tmp = cg.getReferenceTemp();
}
cg_printf(", %s", tmp.empty() ? "Variant()" : tmp.c_str());
}
if (!hasContext(ExistContext)) {
cg_printf(", AccessFlags::Error"); // raise undefined index error
sep = "_";
}
} else if (lvalAt) {
if (hasCseStore && !isArrayType) {
cg_printf(", %s%s",
Option::CseTempStoragePrefix, m_cppCseTemp.c_str());
}
if (hasContext(AccessContext)) {
// Dont copy the array if the element is an object, or
// is referenced.
// This is safe in AccessContext (the parent is an ArrayElement,
// or an ObjectProperty) because applying [] to an object will
// either invoke OffsetGet, or fatal, and modifications to a
//.........这里部分代码省略.........
示例5: outputCPPObjProperty
void ObjectPropertyExpression::outputCPPObjProperty(CodeGenerator &cg,
AnalysisResultPtr ar,
int doExist) {
if (m_valid) {
TypePtr type = m_object->getActualType();
if (type->isSpecificObject()) {
ClassScopePtr cls(type->getClass(ar, getScope()));
if (cls) getFileScope()->addUsedClassFullHeader(cls);
}
}
string func = Option::ObjectPrefix;
const char *error = ", true";
std::string context = "";
bool doUnset = m_context & LValue && m_context & UnsetContext;
bool needTemp = false;
if (cg.getOutput() != CodeGenerator::SystemCPP) {
context = originalClassName(cg, true);
}
if (doUnset) {
func = "o_unset";
error = "";
} else if (doExist) {
func = doExist > 0 ? "o_isset" : "o_empty";
error = "";
} else {
if (m_context & ExistContext) {
error = ", false";
}
if (m_context & InvokeArgument) {
if (cg.callInfoTop() != -1) {
func += "argval";
} else {
func += "get";
}
} else if (m_context & (LValue | RefValue | DeepReference | UnsetContext)) {
if (m_context & UnsetContext) {
always_assert(!(m_context & LValue)); // handled by doUnset
func += "unsetLval";
} else {
func += "lval";
}
error = "";
needTemp = true;
} else {
func += "get";
if (isNonPrivate(ar)) {
func += "Public";
context = "";
}
}
}
if (m_valid && !m_object->isThis() &&
(!m_object->is(KindOfSimpleVariable) ||
!static_pointer_cast<SimpleVariable>(m_object)->isGuarded())) {
cg_printf("(obj_tmp = ");
outputCPPValidObject(cg, ar, false);
bool write_context = hasAnyContext(LValue | RefValue | DeepReference |
UnsetContext | OprLValue |
DeepOprLValue | DeepAssignmentLHS |
AssignmentLHS) && !doUnset;
cg_printf(", LIKELY(obj_tmp != 0) %s ", write_context ? "||" : "?");
always_assert(m_property->is(KindOfScalarExpression));
ScalarExpressionPtr name =
static_pointer_cast<ScalarExpression>(m_property);
if (doExist || doUnset) {
cg_printf(doUnset ? "unset" : doExist > 0 ? "isset" : "empty");
}
ClassScopePtr cls =
ar->findExactClass(shared_from_this(),
m_object->getActualType()->getName());
if (write_context) {
cg_printf("(throw_null_object_prop(),false),");
}
cg_printf("(((%s%s*)obj_tmp)->%s%s)",
Option::ClassPrefix, cls->getId().c_str(),
Option::PropertyPrefix, name->getString().c_str());
if (!write_context) {
cg_printf(" : (raise_null_object_prop(),%s)",
doUnset ? "null_variant" :
doExist ? doExist > 0 ? "false" : "true" :
nullName(ar, getCPPType()).c_str());
}
cg_printf(")");
return;
}
if (m_valid && (doExist || doUnset)) {
cg_printf(doUnset ? "unset(" : doExist > 0 ? "isset(" : "empty(");
}
bool flag = outputCPPObject(cg, ar, !m_valid && (doUnset || doExist));
if (flag) {
cg_printf("id(");
outputCPPProperty(cg, ar);
cg_printf(")");
if (doExist) cg_printf(", %s", doExist > 0 ? "false" : "true");
//.........这里部分代码省略.........