本文整理汇总了C++中TypeSpec::is_int方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeSpec::is_int方法的具体用法?C++ TypeSpec::is_int怎么用?C++ TypeSpec::is_int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeSpec
的用法示例。
在下文中一共展示了TypeSpec::is_int方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
track_variable_lifetimes ();
check_for_illegal_writes ();
// if (m_optimizelevel >= 1)
// coalesce_temporaries ();
}
if (! error_encountered()) {
if (m_output_filename.size() == 0)
m_output_filename = default_output_filename ();
write_oso_file (m_output_filename);
}
oslcompiler = NULL;
}
return ! error_encountered();
}
struct GlobalTable {
const char *name;
TypeSpec type;
};
void
OSLCompilerImpl::initialize_globals ()
{
static GlobalTable globals[] = {
{ "P", TypeDesc::TypePoint },
{ "I", TypeDesc::TypeVector },
{ "N", TypeDesc::TypeNormal },
{ "Ng", TypeDesc::TypeNormal },
{ "u", TypeDesc::TypeFloat },
{ "v", TypeDesc::TypeFloat },
{ "dPdu", TypeDesc::TypeVector },
{ "dPdv", TypeDesc::TypeVector },
#if 0
// Light variables -- we don't seem to be on a route to support this
// kind of light shader, so comment these out for now.
{ "L", TypeDesc::TypeVector },
{ "Cl", TypeDesc::TypeColor },
{ "Ns", TypeDesc::TypeNormal },
{ "Pl", TypeDesc::TypePoint },
{ "Nl", TypeDesc::TypeNormal },
#endif
{ "Ps", TypeDesc::TypePoint },
{ "Ci", TypeSpec (TypeDesc::TypeColor, true) },
{ "time", TypeDesc::TypeFloat },
{ "dtime", TypeDesc::TypeFloat },
{ "dPdtime", TypeDesc::TypeVector },
{ NULL }
};
for (int i = 0; globals[i].name; ++i) {
Symbol *s = new Symbol (ustring(globals[i].name), globals[i].type,
SymTypeGlobal);
symtab().insert (s);
}
}
std::string
OSLCompilerImpl::default_output_filename ()
{
if (m_shader && shader_decl())
return shader_decl()->shadername().string() + ".oso";
return std::string();
}
void
OSLCompilerImpl::write_oso_metadata (const ASTNode *metanode) const
{
ASSERT (metanode->nodetype() == ASTNode::variable_declaration_node);
const ASTvariable_declaration *metavar = static_cast<const ASTvariable_declaration *>(metanode);
Symbol *metasym = metavar->sym();
ASSERT (metasym);
TypeSpec ts = metasym->typespec();
oso ("%%meta{%s,%s,", ts.string().c_str(), metasym->name().c_str());
const ASTNode *init = metavar->init().get();
ASSERT (init);
if (ts.is_string() && init->nodetype() == ASTNode::literal_node)
oso ("\"%s\"", ((const ASTliteral *)init)->strval());
else if (ts.is_int() && init->nodetype() == ASTNode::literal_node)
oso ("%d", ((const ASTliteral *)init)->intval());
else if (ts.is_float() && init->nodetype() == ASTNode::literal_node)
oso ("%.8g", ((const ASTliteral *)init)->floatval());
// FIXME -- what about type constructors?
else {
std::cout << "Error, don't know how to print metadata "
<< ts.string() << " with node type "
<< init->nodetypename() << "\n";
ASSERT (0); // FIXME
}
oso ("} ");
}
示例2: if
void
BackendLLVM::llvm_assign_initial_value (const Symbol& sym)
{
// Don't write over connections! Connection values are written into
// our layer when the earlier layer is run, as part of its code. So
// we just don't need to initialize it here at all.
if (sym.valuesource() == Symbol::ConnectedVal &&
!sym.typespec().is_closure_based())
return;
if (sym.typespec().is_closure_based() && sym.symtype() == SymTypeGlobal)
return;
int arraylen = std::max (1, sym.typespec().arraylength());
// Closures need to get their storage before anything can be
// assigned to them. Unless they are params, in which case we took
// care of it in the group entry point.
if (sym.typespec().is_closure_based() &&
sym.symtype() != SymTypeParam && sym.symtype() != SymTypeOutputParam) {
llvm_assign_zero (sym);
return;
}
if ((sym.symtype() == SymTypeLocal || sym.symtype() == SymTypeTemp)
&& shadingsys().debug_uninit()) {
// Handle the "debug uninitialized values" case
bool isarray = sym.typespec().is_array();
int alen = isarray ? sym.typespec().arraylength() : 1;
llvm::Value *u = NULL;
if (sym.typespec().is_closure_based()) {
// skip closures
}
else if (sym.typespec().is_floatbased())
u = ll.constant (std::numeric_limits<float>::quiet_NaN());
else if (sym.typespec().is_int_based())
u = ll.constant (std::numeric_limits<int>::min());
else if (sym.typespec().is_string_based())
u = ll.constant (Strings::uninitialized_string);
if (u) {
for (int a = 0; a < alen; ++a) {
llvm::Value *aval = isarray ? ll.constant(a) : NULL;
for (int c = 0; c < (int)sym.typespec().aggregate(); ++c)
llvm_store_value (u, sym, 0, aval, c);
}
}
return;
}
if ((sym.symtype() == SymTypeLocal || sym.symtype() == SymTypeTemp) &&
sym.typespec().is_string_based()) {
// Strings are pointers. Can't take any chance on leaving
// local/tmp syms uninitialized.
llvm_assign_zero (sym);
return; // we're done, the parts below are just for params
}
ASSERT_MSG (sym.symtype() == SymTypeParam || sym.symtype() == SymTypeOutputParam,
"symtype was %d, data type was %s", (int)sym.symtype(), sym.typespec().c_str());
if (sym.has_init_ops() && sym.valuesource() == Symbol::DefaultVal) {
// Handle init ops.
build_llvm_code (sym.initbegin(), sym.initend());
} else if (! sym.lockgeom() && ! sym.typespec().is_closure()) {
// geometrically-varying param; memcpy its default value
TypeDesc t = sym.typespec().simpletype();
ll.op_memcpy (llvm_void_ptr (sym), ll.constant_ptr (sym.data()),
t.size(), t.basesize() /*align*/);
if (sym.has_derivs())
llvm_zero_derivs (sym);
} else {
// Use default value
int num_components = sym.typespec().simpletype().aggregate;
TypeSpec elemtype = sym.typespec().elementtype();
for (int a = 0, c = 0; a < arraylen; ++a) {
llvm::Value *arrind = sym.typespec().is_array() ? ll.constant(a) : NULL;
if (sym.typespec().is_closure_based())
continue;
for (int i = 0; i < num_components; ++i, ++c) {
// Fill in the constant val
llvm::Value* init_val = 0;
if (elemtype.is_floatbased())
init_val = ll.constant (((float*)sym.data())[c]);
else if (elemtype.is_string())
init_val = ll.constant (((ustring*)sym.data())[c]);
else if (elemtype.is_int())
init_val = ll.constant (((int*)sym.data())[c]);
ASSERT (init_val);
llvm_store_value (init_val, sym, 0, arrind, i);
}
}
if (sym.has_derivs())
llvm_zero_derivs (sym);
}
// Handle interpolated params.
// FIXME -- really, we shouldn't assign defaults or run init ops if
// the values are interpolated. The perf hit is probably small, since
// there are so few interpolated params, but we should come back and
// fix this later.
if ((sym.symtype() == SymTypeParam || sym.symtype() == SymTypeOutputParam)
&& ! sym.lockgeom()) {
//.........这里部分代码省略.........