本文整理汇总了C++中constant函数的典型用法代码示例。如果您正苦于以下问题:C++ constant函数的具体用法?C++ constant怎么用?C++ constant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了constant函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: output_task_defines
void output_task_defines(void)
{
text("/* MIPS task_struct offsets. */");
offset("#define TASK_STATE ", struct task_struct, state);
offset("#define TASK_FLAGS ", struct task_struct, flags);
constant(" #define _PT_TRACESYS ", PT_TRACESYS);
offset("#define TASK_SIGPENDING ", struct task_struct, sigpending);
offset("#define TASK_NEED_RESCHED ", struct task_struct, need_resched);
offset("#define TASK_PTRACE ", struct task_struct, ptrace);
offset("#define TASK_COUNTER ", struct task_struct, counter);
offset("#define TASK_NICE ", struct task_struct, nice);
offset("#define TASK_MM ", struct task_struct, mm);
offset("#define TASK_PROCESSOR ", struct task_struct, processor);
offset("#define TASK_PID ", struct task_struct, pid);
size( "#define TASK_STRUCT_SIZE ", struct task_struct);
linefeed;
}
示例2: setup_shading
boost::shared_ptr<shade::Program> setup_shading(boost::shared_ptr<shade::GLSLWrapper> state, boost::shared_ptr<shade::Texture> texture)
{
boost::shared_ptr<shade::shaders::Surface> shader(new shade::shaders::Surface);
boost::shared_ptr<shade::Program> program(new shade::Program(shader, state));
boost::shared_ptr<shade::shaders::Constant> constant(new shade::shaders::Constant);
constant->color.set_value(shade::vec4<>(1., 0.4, 0.4, 1.));
shader->material = constant;
boost::shared_ptr<shade::shaders::Texture2D> tex(new shade::shaders::Texture2D);
tex->texture_unit.set(texture);
boost::shared_ptr<shade::shaders::UVCoord> uvcoord(new shade::shaders::UVCoord);
tex->uv = uvcoord;
constant->color = tex;
return program;
}
示例3: main
int main(int argc, char *argv[]) {
/*
printf("sizeof(enum Fred) = %lu\n", sizeof(enum Fred));
int keyUp = 1073741906;
printf("keyUp = %d\n", keyUp);
*/
printf("module Constants\n\n");
constant("QUIT", SDL_QUIT);
constant("KEYDOWN", SDL_KEYDOWN);
constant("KEYUP", SDL_KEYUP);
constant("KEY_ESCAPE", SDLK_ESCAPE);
constant("KEY_UP", SDLK_UP);
constant("KEY_RIGHT", SDLK_RIGHT);
constant("KEY_DOWN", SDLK_DOWN);
constant("KEY_LEFT", SDLK_LEFT);
}
示例4: switch
void GetByOffsetMethod::dumpInContext(PrintStream& out, DumpContext* context) const
{
out.print(m_kind, ":");
switch (m_kind) {
case Invalid:
out.print("<none>");
return;
case Constant:
out.print(pointerDumpInContext(constant(), context));
return;
case Load:
out.print(offset());
return;
case LoadFromPrototype:
out.print(offset(), "@", pointerDumpInContext(prototype(), context));
return;
}
}
示例5: switch
void CCompiler::Prepare(CParser *pParser)
{
s32 high_const = -1,high_temp = -1;
u32 i,j,nICount = pParser->GetInstructionCount();
struct nvfx_insn *insns = pParser->GetInstructions();
for(i=0;i<nICount;i++) {
struct nvfx_insn *insn = &insns[i];
for(j=0;j<3;j++) {
struct nvfx_src *src = &insn->src[j];
switch(src->reg.type) {
case NVFXSR_TEMP:
if((s32)src->reg.index>high_temp) high_temp = src->reg.index;
break;
case NVFXSR_CONST:
if((s32)src->reg.index>high_const) high_const = src->reg.index;
break;
}
}
switch(insn->dst.type) {
case NVFXSR_TEMP:
if((s32)insn->dst.index>high_temp) high_temp = insn->dst.index;
break;
case NVFXSR_CONST:
if((s32)insn->dst.index>high_const) high_const = insn->dst.index;
break;
}
}
if(++high_temp) {
m_nNumRegs = high_temp;
m_rTemp = (struct nvfx_reg*)calloc(high_temp,sizeof(struct nvfx_reg));
for(i=0;i<(u32)high_temp;i++) m_rTemp[i] = temp();
m_rTempsDiscard = 0;
}
if(++high_const) {
m_rConst = (struct nvfx_reg*)calloc(high_const,sizeof(struct nvfx_reg));
for(i=0;i<(u32)high_const;i++) m_rConst[i] = constant(i,0.0f,0.0f,0.0f,0.0f);
}
}
示例6: assert
Node* UnaryArithmeticAssignmentNode::expandToAsebaTree(std::wostream* dump, unsigned int index)
{
assert(children.size() == 1);
Node* memoryVector = children[0];
// create a vector of 1's
std::auto_ptr<TupleVectorNode> constant(new TupleVectorNode(sourcePos));
for (unsigned int i = 0; i < memoryVector->getVectorSize(); i++)
constant->addImmediateValue(1);
// expand to "vector (op)= 1"
std::auto_ptr<ArithmeticAssignmentNode> assignment(new ArithmeticAssignmentNode(sourcePos, arithmeticOp, memoryVector->deepCopy(), constant.release()));
std::auto_ptr<Node> finalBlock(assignment->expandToAsebaTree(dump, index));
assignment.release();
delete this;
return finalBlock.release();
}
示例7: body
void body(){
symbol_t t, id;
if(sym->type==CONST){
nextSym();
constant();
}
while(isType(sym)){
t = copySym(sym);
nextSym();
if(sym->type!=ID){
msg(ERR, "missing a identifier after a type name", line);
ERROR_STATUS = 1;
}
id = copySym(sym);
nextSym();
variable(t, id);
mfree(t);
}
statementlist();
}
示例8: find_variables
static int find_variables()
{
int i,k;
char nimi[LLENGTH];
for (i=0; i<rdim; ++i)
{
poimi(nimi,rlab,lr,i);
if (constant(nimi)) k=-1;
else
{
k=prosparam(nimi); if (k<0) return(-1);
k=varfind(&d,nimi); if (k<0) return(-2);
}
var[i]=k;
}
for (k=0; k<rdim; ++k) lag[k]=0;
for (i=0; i<cdim; ++i)
{
poimi(nimi,clab,lc,i);
if (muste_strcmpi(nimi,"#LAG")==0)
{
for (k=0; k<rdim; ++k) lag[k]=(int)A[i*rdim+k];
k=-1;
}
else
{
k=prosparam(nimi); if (k<0) return(-1);
if (k==0) { outvar[i]=-1; continue; }
k=varfind2(&d,nimi,0);
if (k<0)
{
k=create_newvar1(&d,nimi,'4',4,act);
if (k<0) return(-3);
}
}
outvar[i]=k;
}
return(1);
}
示例9: constant
//- Construct from objectRegistry arguments
Foam::engineTime::engineTime
(
const word& name,
const fileName& rootPath,
const fileName& caseName,
const fileName& systemName,
const fileName& constantName,
const fileName& dictName
)
:
Time
(
name,
rootPath,
caseName,
systemName,
constantName
),
dict_
(
IOobject
(
dictName,
constant(),
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
),
rpm_(dict_.lookup("rpm")),
conRodLength_(dimensionedScalar("conRodLength", dimLength, 0)),
bore_(dimensionedScalar("bore", dimLength, 0)),
stroke_(dimensionedScalar("stroke", dimLength, 0)),
clearance_(dimensionedScalar("clearance", dimLength, 0))
{
// the geometric parameters are not strictly required for Time
if (dict_.found("conRodLength"))
{
dict_.lookup("conRodLength") >> conRodLength_;
}
示例10: weights
/*------------------------------------------------------------------*/
void AzOptOnTree::updateTreeWeights(AzRgfTreeEnsemble *ens) const
{
int dtree_num = ens->size();
int tx;
for (tx = 0; tx < dtree_num; ++tx) {
ens->tree_u(tx)->resetWeights();
}
const double *weight = weights()->point();
double const_val = constant();
ens->set_constant(const_val);
int num = tree_feat->featNum();
int fx;
for (fx = 0; fx < num; ++fx) {
if (weight[fx] != 0) {
const AzTrTreeFeatInfo *fp = tree_feat->featInfo(fx);
ens->tree_u(fp->tx)->setWeight(fp->nx, weight[fx]);
}
}
}
示例11: constant
/// Elementwise operator -
AutoDiffBlock operator-(const AutoDiffBlock& rhs) const
{
if (jac_.empty() && rhs.jac_.empty()) {
return constant(val_ - rhs.val_);
}
if (jac_.empty()) {
return val_ - rhs;
}
if (rhs.jac_.empty()) {
return *this - rhs.val_;
}
std::vector<M> jac = jac_;
assert(numBlocks() == rhs.numBlocks());
int num_blocks = numBlocks();
for (int block = 0; block < num_blocks; ++block) {
assert(jac[block].rows() == rhs.jac_[block].rows());
assert(jac[block].cols() == rhs.jac_[block].cols());
jac[block] -= rhs.jac_[block];
}
return function(val_ - rhs.val_, jac);
}
示例12: helper_function
void helper_function()
{
signal_t r = fa_signal_lift2(string("times"), times, NULL, constant(0.1), fa_signal_sin(line(440)));
{
fa_audio_session_t s = fa_audio_begin_session();
fa_audio_device_t i = fa_audio_default_input(s);
fa_audio_device_t o = fa_audio_default_output(s);
fa_audio_stream_t st = fa_audio_open_stream(i, o, just, list(r, r));
if (fa_check(st)) {
fa_error_log(st, NULL);
} else {
while (1) {
fa_thread_sleep(10000);
}
}
fa_audio_end_session(s);
}
}
示例13: switch
void ExitValue::dumpInContext(PrintStream& out, DumpContext* context) const
{
switch (kind()) {
case InvalidExitValue:
out.print("Invalid");
return;
case ExitValueDead:
out.print("Dead");
return;
case ExitValueArgument:
out.print("Argument(", exitArgument(), ")");
return;
case ExitValueConstant:
out.print("Constant(", inContext(constant(), context), ")");
return;
case ExitValueInJSStack:
out.print("InJSStack:r", virtualRegister());
return;
case ExitValueInJSStackAsInt32:
out.print("InJSStackAsInt32:r", virtualRegister());
return;
case ExitValueInJSStackAsInt52:
out.print("InJSStackAsInt52:r", virtualRegister());
return;
case ExitValueInJSStackAsDouble:
out.print("InJSStackAsDouble:r", virtualRegister());
return;
case ExitValueArgumentsObjectThatWasNotCreated:
out.print("ArgumentsObjectThatWasNotCreated");
return;
case ExitValueRecovery:
out.print("Recovery(", recoveryOpcode(), ", arg", leftRecoveryArgument(), ", arg", rightRecoveryArgument(), ", ", recoveryFormat(), ")");
return;
case ExitValueMaterializeNewObject:
out.print("Materialize(", pointerDump(objectMaterialization()), ")");
return;
}
RELEASE_ASSERT_NOT_REACHED();
}
示例14: emit_inc
/*===--------------------------------------------------------------------------
---------------------------------------------------------------------------===*/
static void emit_inc(int ic, symbol *s) {
int cat, post;
symbol *val;
value v;
assert(s->ty);
cat = s->ty->cat;
post = gen_post(cat, cat);
//s1 = cast(l, ty);
if (cat == CAT_POINTER) {
v.i = s->ty->bty->size;
val = constant(v, int_type);
if (ic == IC_DEC)
ic = IC_SUB;
else if (ic == IC_INC)
ic = IC_ADD;
else
assert(0);
emit_ic(ic + i32, s, val);
} else
emit_ic(ic + post, s, NULL);
return;
}
示例15: add_entry
/**
* @brief Adds a new entry to the truth table
*
* With adding the first entry the dimension of inputs
* and outputs is set. When adding further entries
* it has to make sure that the dimensions fit, else
* an assertion is thrown and false is returned.
*
* @param input Input assignment
* @param output Output assignment
* @return Returns whether the assignment could be added or not
*
* @since 1.0
*/
bool add_entry( const cube_type& input, const cube_type& output )
{
if ( _cubes.size() &&
( input.size() != _cubes.begin()->first.size() ||
output.size() != _cubes.begin()->second.size() ) )
{
assert( false );
return false;
}
if ( !_cubes.size() && !_permutation.size() )
{
/* first entry -> create permutation */
std::copy( boost::counting_iterator<unsigned>( 0 ),
boost::counting_iterator<unsigned>( output.size() ),
std::back_inserter( _permutation ) );
_constants.resize( input.size(), constant() );
_garbage.resize( output.size(), false );
}
_cubes.insert( std::make_pair( input, output ) );
return true;
}