MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenShadingLanguage / codegen_int

Method codegen_int

src/liboslcomp/codegen.cpp:375–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373
374
375Symbol *
376ASTNode::codegen_int (Symbol *, bool boolify, bool invert)
377{
378 Symbol *dest = codegen ();
379 TypeSpec type = dest->typespec ();
380 if (! type.is_int() || boolify || invert) {
381 // If they're not using an int as the condition, then it's an
382 // implied comparison to zero.
383 Symbol *tempvar = m_compiler->make_temporary (TypeDesc::TypeInt);
384 Symbol *zerovar = NULL;
385 if (type.is_closure())
386 zerovar = m_compiler->make_constant ((int)0);
387 else if (type.is_string())
388 zerovar = m_compiler->make_constant (ustring(""));
389 else if (type.is_int())
390 zerovar = m_compiler->make_constant ((int)0);
391 else
392 zerovar = m_compiler->make_constant (0.0f);
393 emitcode (invert ? "eq" : "neq", tempvar, dest, zerovar);
394 dest = tempvar;
395 }
396 return dest;
397}
398
399
400

Callers 2

codegenMethod · 0.80
codegen_logicMethod · 0.80

Calls 5

is_intMethod · 0.80
make_temporaryMethod · 0.80
is_closureMethod · 0.80
make_constantMethod · 0.80
is_stringMethod · 0.80

Tested by

no test coverage detected