Exemple #1
0
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;
}
Exemple #2
0
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;
}
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);
}
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;
    }
}
Exemple #5
0
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);
	}
}
Exemple #6
0
  void BlockBuilder::setup_block_scope() {
    b().CreateStore(ConstantExpr::getNullValue(llvm::PointerType::getUnqual(vars_type)),
        get_field(vars, offset::vars_on_heap));
    Value* self = b().CreateLoad(
        get_field(block_inv, offset::blockinv_self),
        "invocation.self");

    b().CreateStore(self, get_field(vars, offset::vars_self));

    Value* inv_mod = b().CreateLoad(
        get_field(block_inv, offset::blockinv_module),
        "invocation.module");

    Value* creation_mod = b().CreateLoad(
        get_field(block_env, offset::blockenv_module),
        "env.module");

    Value* mod = b().CreateSelect(
        b().CreateICmpNE(inv_mod, ConstantExpr::getNullValue(inv_mod->getType())),
        inv_mod,
        creation_mod);

    module_ = mod;

    b().CreateStore(mod, get_field(vars, offset::vars_module));

    Value* blk = b().CreateLoad(get_field(top_scope, offset::varscope_block),
        "args.block");
    b().CreateStore(blk, get_field(vars, offset::vars_block));


    // We don't use top_scope here because of nested blocks. Parent MUST be
    // the scope the block was created in, not the top scope for depth
    // variables to work.
    Value* be_scope = b().CreateLoad(
        get_field(block_env, offset::blockenv_scope),
        "env.scope");

    b().CreateStore(be_scope, get_field(vars, offset::vars_parent));
    b().CreateStore(constant(Qnil, obj_type), get_field(vars, offset::vars_last_match));

    nil_locals();
  }
Exemple #7
0
	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();
	}
Exemple #8
0
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();
}
Exemple #9
0
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);
        }
//- 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_;
    }
/*------------------------------------------------------------------*/
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]); 
    }
  }
}
Exemple #12
0
 /// 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);
 }
Exemple #13
0
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);
    }
}
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();
}
Exemple #15
0
/*===--------------------------------------------------------------------------

---------------------------------------------------------------------------===*/
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;
}
Exemple #16
0
    /**
     * @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;
    }
Exemple #17
0
 /// 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_;
     }
     int num_blocks = numBlocks();
     std::vector<M> jac(num_blocks);
     assert(numBlocks() == rhs.numBlocks());
     typedef Eigen::DiagonalMatrix<Scalar, Eigen::Dynamic> D;
     D D1 = val_.matrix().asDiagonal();
     D D2 = rhs.val_.matrix().asDiagonal();
     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] = D2*jac_[block] + D1*rhs.jac_[block];
     }
     return function(val_ * rhs.val_, jac);
 }
Exemple #18
0
Size Button::get_minimum_size_internal() {


	Painter *p=get_painter();

	Size min;

	if (get_icon() >=0 && p->is_bitmap_valid( get_icon() )) {
		Size icon_size=p->get_bitmap_size( get_icon() );

		min.width+=icon_size.width;
		if (min.height < icon_size.height )
			min.height=icon_size.height;

		if (label_text!="")
			min.width+=constant( C_BUTTON_SEPARATION ); //if there is an icon, add the label-icon separation
	}


	min.width+=p->get_font_string_width( font( FONT_BUTTON ) , label_text );

	if (p->get_font_height( font( FONT_BUTTON ) ) >  min.height )
		min.height=p->get_font_height( font( FONT_BUTTON ) );


	if (constant( C_BUTTON_HAS_CHECKBOX )) {

		if ( constant( C_BUTTON_CHECKBOX_SIZE )>0 ) {
			min.width+=constant( C_BUTTON_CHECKBOX_SIZE );
			if (min.height<constant( C_BUTTON_CHECKBOX_SIZE ))
				min.height=constant( C_BUTTON_CHECKBOX_SIZE );
		} else {

			Size uncheck_size=p->get_bitmap_size( bitmap( BITMAP_BUTTON_UNCHECKED ) );
			min.width+=uncheck_size.width;
			if (min.height<uncheck_size.height)
				min.height=uncheck_size.height;
		}

		min.width+=constant( C_BUTTON_SEPARATION );
	}

	if (shortcut!=0) {
	
		String s_str = Keyboard::get_code_name( shortcut );
		min.width+=constant( C_BUTTON_SEPARATION );
		min.width+=p->get_font_string_width( font(FONT_BUTTON), s_str );
		
	}

	min.width+=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_LEFT );
	min.width+=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_RIGHT );

	min.height+=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_TOP );
	min.height+=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_BOTTOM );


	min.width+=constant( C_BUTTON_EXTRA_MARGIN )*2+constant( C_BUTTON_DISPLACEMENT ); //both margins and displacement
	min.height+=constant( C_BUTTON_EXTRA_MARGIN )*2+constant( C_BUTTON_DISPLACEMENT ); //both margins and displacement

	

	return min;

}
Exemple #19
0
void Button::draw(const Point& p_pos,const Size& p_size,const Rect& p_exposed) {

	Painter *p=get_painter();

	/* Draw Outline */

	//if disabled...
	bool draw_displaced=false;

	DrawMode draw_mode=get_draw_mode();

	if (draw_mode==DRAW_HOVER) { //optative, otherwise draw normal

		if (stylebox( SB_BUTTON_HOVER ).mode!=StyleBox::MODE_NONE && (!is_toggle_mode() || (is_toggle_mode() && !is_pressed()))) {

			p->draw_stylebox( stylebox( SB_BUTTON_HOVER ) , Point() , p_size, p_exposed );

		} else
			draw_mode=is_pressed()?DRAW_PRESSED:DRAW_NORMAL;
	} ;

	if (draw_mode==DRAW_NORMAL) {

		p->draw_stylebox( stylebox( SB_BUTTON_NORMAL ) , Point() , p_size, p_exposed );

	}

	if (draw_mode==DRAW_PRESSED) {

		p->draw_stylebox( stylebox( SB_BUTTON_PRESSED ) , Point() , p_size, p_exposed );
		draw_displaced=true;

	}


	Rect area_rect=Rect( p_pos, p_size );

	area_rect.pos.x=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_LEFT );
	area_rect.pos.y=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_TOP );
	area_rect.size-=area_rect.pos;

	area_rect.size.x-=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_RIGHT );
	area_rect.size.y-=p->get_stylebox_margin( stylebox( SB_BUTTON_NORMAL ), MARGIN_BOTTOM );

	area_rect.size.x-=constant( C_BUTTON_EXTRA_MARGIN )*2;
	area_rect.pos.x+=constant( C_BUTTON_EXTRA_MARGIN );
	area_rect.size.y-=constant( C_BUTTON_EXTRA_MARGIN )*2;
	area_rect.pos.y+=constant( C_BUTTON_EXTRA_MARGIN );

	area_rect.size.x-=constant( C_BUTTON_DISPLACEMENT );
	area_rect.size.y-=constant( C_BUTTON_DISPLACEMENT );
	if (draw_displaced)
		area_rect.pos+=Point( constant( C_BUTTON_DISPLACEMENT ), constant( C_BUTTON_DISPLACEMENT ) );


	if (constant(C_BUTTON_HAS_CHECKBOX)) {

		Size cbsize;

		if ( constant( C_BUTTON_CHECKBOX_SIZE )>0 ) {

			cbsize.width+=constant( C_BUTTON_CHECKBOX_SIZE );
			cbsize.height+=constant( C_BUTTON_CHECKBOX_SIZE );
		} else {

			cbsize=p->get_bitmap_size( bitmap( BITMAP_BUTTON_UNCHECKED ) );
		}

		Point check_pos=area_rect.pos;
		check_pos.y+=(area_rect.size.height-cbsize.height)/2;

		if ( constant( C_BUTTON_CHECKBOX_SIZE )>0 ) {

			p->draw_stylebox( stylebox( is_pressed() ? SB_BUTTON_CHECKED : SB_BUTTON_UNCHECKED ) , check_pos , cbsize);
		} else {

			p->draw_bitmap( bitmap( is_pressed() ? BITMAP_BUTTON_CHECKED : BITMAP_BUTTON_UNCHECKED ), check_pos );
		}

		area_rect.pos.x+=cbsize.x+constant( C_BUTTON_SEPARATION );
		area_rect.size.x-=cbsize.x+constant( C_BUTTON_SEPARATION );
	}

	if (get_icon() >=0 && p->is_bitmap_valid( get_icon() )) {

		Size icon_size=p->get_bitmap_size( get_icon() );

		Point icon_pos=area_rect.pos;
		icon_pos.y+=(area_rect.size.height-icon_size.height)/2;

		p->draw_bitmap( get_icon(), icon_pos );

		area_rect.pos.x+=icon_size.width;
		area_rect.size.x-=icon_size.width;
		if (label_text!="") {
			
			area_rect.pos.x+=constant( C_BUTTON_SEPARATION ); //separation for the label
			area_rect.size.x-=constant( C_BUTTON_SEPARATION ); //separation for the label
		}

	}

	if (shortcut!=0) {
	

		String s_str = Keyboard::get_code_name( shortcut );
		int w = p->get_font_string_width( font(FONT_BUTTON), s_str );
		
		Point shrc_ofs= area_rect.pos;
		
		shrc_ofs.y+=(area_rect.size.height-p->get_font_height( font( FONT_BUTTON ) ))/2+p->get_font_ascent( font( FONT_BUTTON ) );
		shrc_ofs.x = (area_rect.pos.x+area_rect.size.x)-w;
		
		p->draw_text( font( FONT_BUTTON ) ,  shrc_ofs, s_str, color(COLOR_BUTTON_SHORTCUT_FONT) );
		
		area_rect.size.x-=w;
		
	}

	Point label_ofs=area_rect.pos;
	if (constant(C_BUTTON_LABEL_ALIGN_CENTER)) {

		label_ofs.x+=(area_rect.size.width-p->get_font_string_width( font( FONT_BUTTON ) , label_text ))/2;
	}
	label_ofs.y+=(area_rect.size.height-p->get_font_height( font( FONT_BUTTON ) ))/2+p->get_font_ascent( font( FONT_BUTTON ) );


	
	p->draw_text( font( FONT_BUTTON ) ,  label_ofs, label_text, color(draw_mode==DRAW_HOVER?COLOR_BUTTON_FONT_HOVER:COLOR_BUTTON_FONT) );
	if (accel_char >= 0) {
		int width = 0;
		for (int i=0; i<accel_char; i++) {

			width += p->get_font_char_width(font( FONT_BUTTON ), label_text[i]);
		};
		p->draw_text( font( FONT_BUTTON ) ,  label_ofs + Point(width, 0), "_", color(COLOR_BUTTON_FONT) );
	};


	if (has_focus())
		p->draw_stylebox( stylebox( SB_BUTTON_FOCUS ) , Point() , p_size, p_exposed);

}
Exemple #20
0
/*===--------------------------------------------------------------------------

--------------------------------------------------------------------------===*/
static symbol *post2ic(ast *t1) {
	symbol *s1, *s2, *val, *base;
	dlist *args, *d2;
	ast *t2;
	int node = t1->node, cat, post;
	type *ty = t1->ty;
	value v;
	icode *ic;

	assert(ty && "type of post AST empty");
	cat = ty->cat;		// t1->ty->cat
	switch (node) {
	case AST_POST_INC:
	case AST_POST_DEC:
		/*-----------------------------------------
			char c = 1;	//char
			c++;		//int
		ty is scalar(int/float/double) type
		------------------------------------------*/
		s1 = post2ic(t1->left);
		val = gen_vit_reg(ty);
		emit_ic(IC_MOV + gen_post(cat, cat), val, cast(s1, ty));
		/// source's post value
		post = gen_post(s1->ty->cat, s1->ty->cat);
		if (node == AST_POST_INC)
			emit_inc(IC_INC, s1);
		else
			emit_inc(IC_DEC, s1);
		return val;
	case AST_ARRAY:
		s1 = post2ic(t1->left);			//base
		s2 = expr2ic(t1->right);		//index
		assert(is_int_cat(s2->ty->cat));
		assert(s1->ty->cat == CAT_POINTER);
		// the type infer of post-expression is work correct ?
		assert(s1->ty->cat == ty->cat);
		/* size of array's element*/
		assert(ty->size);
		v.i = ty->size;
		s2 = cast(s2, int_type);
		val = constant(v, int_type);
		verify_ops(&s2, val);		// make sure s2 is a not a immediate value
		emit_ic(IC_MUL + i32, s2, val);	//offset
		/* address = base + offset, can be optimzation using complex address mode*/
		base = gen_vit_reg(s1->ty);
		emit_ic(IC_ADDR + i32, base, s1);
		emit_ic(IC_ADD + i32, s2, base);	//base + offset
		val = gen_vit_reg(ty);
		val->is_addr = 1;
		emit_ic(IC_MOV + i32, val, s2);
		return val;			// lvalue, is a address
	case AST_CALL:
		s1 = post2ic(t1->left);
		args = (dlist *)t1->right->left;
		d2 = args = args->prev;	//pass argument from right to left
		if (d2)
			do {
				t2 = (ast *)d2->it;
				s2 = asgn2ic(t2);
				//emit_pass_arg(t2->u.arg_off, s2);
				// TODO, pushl arguments ?????
				post = gen_post(t2->ty->cat, t2->ty->cat);
				ic = emit_ic(IC_MOV_ARG + post, s2, NULL);
				ic->u.arg_off = t2->u.arg_off;
				d2 = d2->prev;
			} while (d2 != args);
		if (ty->cat != CAT_VOID)
			val = gen_vit_reg(ty);
		else {		// no return value
			assert(ty == void_type);
			val = NULL;
		}
		emit_ic(IC_CALL, val, s1);
		return val;
	case AST_MEMBER:
		s1 = post2ic(t1->left);
		s2 = primary2ic(t1->right);
		val = emit_member(s1, s2);
		return val;
	case AST_ARROW:
		s1 = post2ic(t1->left);
		s2 = primary2ic(t1->right);
		val = gen_vit_reg(s1->ty);
		emit_ic(IC_MOV + i32, val, s1);		// get the address value if in lvalue
		val = emit_member(val, s2);
		return val;	//lvalue, is a address
	default:
		return primary2ic(t1);
	}
	assert(0);
}
void estimate(const size_t order, const Points &X, const HistogramY &Y,
              const size_t i_min, const size_t i_max, const size_t p_min,
              const size_t p_max, bool haveGap, double &out_bg0,
              double &out_bg1, double &out_bg2, double &out_chisq_red) {
  // Validate input
  if (order > 2)
    throw std::runtime_error("can only estimate up to order=2");
  if (i_min >= i_max) {
    std::stringstream err;
    err << "i_min (" << i_min << ")cannot be larger or equal to i_max ("
        << i_max << ")";
    throw std::runtime_error(err.str());
  }
  if (i_max > X.size()) {
    std::stringstream err;
    err << "i_max  (" << i_max << ") cannot be larger or equal to size of X "
        << X.size() << ")";
    throw std::runtime_error(err.str());
  }
  if (haveGap && p_min >= p_max)
    throw std::runtime_error("p_min cannot larger or equal to p_max");
  // ignore when p-range is outside of i-range

  // set all output parameters to zero
  out_bg0 = 0.;
  out_bg1 = 0.;
  out_bg2 = 0.;
  out_chisq_red = INVALID_CHISQ;

  // accumulate sum
  double sum = 0.0;
  double sumX = 0.0;
  double sumY = 0.0;
  double sumX2 = 0.0;
  double sumXY = 0.0;
  double sumX2Y = 0.0;
  double sumX3 = 0.0;
  double sumX4 = 0.0;
  for (size_t i = i_min; i < i_max; ++i) {
    if (haveGap && i >= p_min && i < p_max)
      continue;
    sum += 1.0;
    sumX += X[i];
    sumX2 += X[i] * X[i];
    sumY += Y[i];
    sumXY += X[i] * Y[i];
    sumX2Y += X[i] * X[i] * Y[i];
    sumX3 += X[i] * X[i] * X[i];
    sumX4 += X[i] * X[i] * X[i] * X[i];
  }

  if (sum == 0.) {
    return;
  }

  // Estimate flat
  double bg0_flat = 0.;
  calcFlatParameters(sum, sumY, bg0_flat);

  // Estimate linear
  double bg0_linear = 0.;
  double bg1_linear = 0.;
  calcLinearParameters(sum, sumX, sumY, sumXY, sumX2, bg0_linear, bg1_linear);

  // Estimate quadratic
  double bg0_quadratic = 0.;
  double bg1_quadratic = 0.;
  double bg2_quadratic = 0.;
  calcQuadraticParameters(sum, sumX, sumY, sumXY, sumX2, sumX2Y, sumX3, sumX4,
                          bg0_quadratic, bg1_quadratic, bg2_quadratic);

  // Setup to calculate the residuals
  double chisq_flat = 0.;
  double chisq_linear = 0.;
  double chisq_quadratic = 0.;
  auto residual_flat = constant(bg0_flat);
  auto residual_linear = linear(bg0_linear, bg1_linear);
  auto residual_quadratic =
      quadratic(bg0_quadratic, bg1_quadratic, bg2_quadratic);
  double num_points = 0.;

  // calculate the chisq - not normalized by the number of points
  for (size_t i = i_min; i < i_max; ++i) {
    if (haveGap && i >= p_min && i < p_max)
      continue;

    num_points += 1.;
    chisq_flat += residual_flat(X[i], Y[i]);
    chisq_linear += residual_linear(X[i], Y[i]);
    chisq_quadratic += residual_quadratic(X[i], Y[i]);
  }

  // convert to <reduced chisq> = chisq / (<number points> - <number
  // parameters>)
  chisq_flat = chisq_flat / (num_points - 1.);
  chisq_linear = chisq_linear / (num_points - 2.);
  chisq_quadratic = chisq_quadratic / (num_points - 3.);

  if (order < 2) {
    chisq_quadratic = BAD_CHISQ;
    if (order < 1) {
      chisq_linear = BAD_CHISQ;
    }
  }

  // choose the right background function to return
  // this is written that lower order polynomial wins in the case of a tie
  if ((chisq_flat <= chisq_linear) && (chisq_flat <= chisq_quadratic)) {
    out_bg0 = bg0_flat;
    out_chisq_red = chisq_flat;
  } else if ((chisq_linear <= chisq_flat) &&
             (chisq_linear <= chisq_quadratic)) {
    out_bg0 = bg0_linear;
    out_bg1 = bg1_linear;
    out_chisq_red = chisq_linear;
  } else {
    out_bg0 = bg0_quadratic;
    out_bg1 = bg1_quadratic;
    out_bg2 = bg2_quadratic;
    out_chisq_red = chisq_quadratic;
  }
}
GUI::Size FilterBankFR::get_minimum_size_internal() {

	return GUI::Size( constant( C_NODEUI_FILTERBANK_FR_MIN_WIDTH) , 0 );
}
Foam::word Foam::Time::findInstance
(
    const fileName& dir,
    const word& name,
    const IOobject::readOption rOpt,
    const word& stopInstance
) const
{
    // Note: if name is empty, just check the directory itself

    // check the current time directory
    if
    (
        name.empty()
      ? isDir(path()/timeName()/dir)
      :
        (
            isFile(path()/timeName()/dir/name)
         && IOobject(name, timeName(), dir, *this).headerOk()
        )
    )
    {
        if (debug)
        {
            Info<< "Time::findInstance"
                "(const fileName&, const word&, const IOobject::readOption)"
                << " : found \"" << name
                << "\" in " << timeName()/dir
                << endl;
        }

        return timeName();
    }

    // Search back through the time directories to find the time
    // closest to and lower than current time

    instantList ts = times();
    label instanceI;

    for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
    {
        if (ts[instanceI].value() <= timeOutputValue())
        {
            break;
        }
    }

    // continue searching from here
    for (; instanceI >= 0; --instanceI)
    {
        if
        (
            name.empty()
          ? isDir(path()/ts[instanceI].name()/dir)
          :
            (
                isFile(path()/ts[instanceI].name()/dir/name)
             && IOobject(name, ts[instanceI].name(), dir, *this).headerOk()
            )
        )
        {
            if (debug)
            {
                Info<< "Time::findInstance"
                    "(const fileName&, const word&, const IOobject::readOption)"
                    << " : found \"" << name
                    << "\" in " << ts[instanceI].name()/dir
                    << endl;
            }

            return ts[instanceI].name();
        }

        // Check if hit minimum instance
        if (ts[instanceI].name() == stopInstance)
        {
            if (debug)
            {
                Info<< "Time::findInstance"
                    "(const fileName&, const word&"
                    ", const IOobject::readOption, const word&)"
                    << " : hit stopInstance " << stopInstance
                    << endl;
            }

            if (rOpt == IOobject::MUST_READ)
            {
                FatalErrorIn
                (
                    "Time::findInstance"
                    "(const fileName&, const word&"
                    ", const IOobject::readOption, const word&)"
                )   << "Cannot find file \"" << name << "\" in directory "
                    << dir << " in times " << timeName()
                    << " down to " << stopInstance
                    << exit(FatalError);
            }

            return ts[instanceI].name();
        }
    }

    // not in any of the time directories, try constant

    // Note. This needs to be a hard-coded constant, rather than the
    // constant function of the time, because the latter points to
    // the case constant directory in parallel cases

    if
    (
        name.empty()
      ? isDir(path()/constant()/dir)
      :
        (
            isFile(path()/constant()/dir/name)
         && IOobject(name, constant(), dir, *this).headerOk()
        )
    )
    {
        if (debug)
        {
            Info<< "Time::findInstance"
                "(const fileName&, const word&, const IOobject::readOption)"
                << " : found \"" << name
                << "\" in " << constant()/dir
                << endl;
        }

        return constant();
    }

    if (rOpt == IOobject::MUST_READ)
    {
        FatalErrorIn
        (
            "Time::findInstance"
            "(const fileName&, const word&, const IOobject::readOption)"
        )   << "Cannot find file \"" << name << "\" in directory "
            << dir << " in times " << timeName()
            << " down to " << constant()
            << exit(FatalError);
    }

    return constant();
}
Exemple #24
0
/*
 * Process a label.
 *
 * typ		type of the label (T_NAME, T_DEFAULT or T_CASE).
 * sym		symbol table entry of label if typ == T_NAME
 * tn		expression if typ == T_CASE
 */
void
label(int typ, sym_t *sym, tnode_t *tn)
{
	cstk_t	*ci;
	clst_t	*cl;
	val_t	*v;
	val_t	nv;
	tspec_t	t;

	switch (typ) {

	case T_NAME:
		if (sym->s_set) {
			/* label %s redefined */
			error(194, sym->s_name);
		} else {
			setsflg(sym);
		}
		break;

	case T_CASE:

		/* find the stack entry for the innermost switch statement */
		for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_nxt)
			continue;

		if (ci == NULL) {
			/* case not in switch */
			error(195);
			tn = NULL;
		} else if (tn != NULL && tn->tn_op != CON) {
			/* non-constant case expression */
			error(197);
			tn = NULL;
		} else if (tn != NULL && !isityp(tn->tn_type->t_tspec)) {
			/* non-integral case expression */
			error(198);
			tn = NULL;
		}

		if (tn != NULL) {

			if (ci->c_swtype == NULL)
				lerror("label() 1");

			if (reached && !ftflg) {
				if (hflag)
					/* fallthrough on case statement */
					warning(220);
			}

			t = tn->tn_type->t_tspec;
			if (t == LONG || t == ULONG ||
			    t == QUAD || t == UQUAD) {
				if (tflag)
					/* case label must be of type ... */
					warning(203);
			}

			/*
			 * get the value of the expression and convert it
			 * to the type of the switch expression
			 */
			v = constant(tn);
			(void) memset(&nv, 0, sizeof nv);
			cvtcon(CASE, 0, ci->c_swtype, &nv, v);
			free(v);

			/* look if we had this value already */
			for (cl = ci->c_clst; cl != NULL; cl = cl->cl_nxt) {
				if (cl->cl_val.v_quad == nv.v_quad)
					break;
			}
			if (cl != NULL && isutyp(nv.v_tspec)) {
				/* duplicate case in switch, %lu */
				error(200, (u_long)nv.v_quad);
			} else if (cl != NULL) {
				/* duplicate case in switch, %ld */
				error(199, (long)nv.v_quad);
			} else {
				/*
				 * append the value to the list of
				 * case values
				 */
				cl = xcalloc(1, sizeof (clst_t));
				STRUCT_ASSIGN(cl->cl_val, nv);
				cl->cl_nxt = ci->c_clst;
				ci->c_clst = cl;
			}
		}
		tfreeblk();
		break;

	case T_DEFAULT:

		/* find the stack entry for the innermost switch statement */
		for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_nxt)
			continue;

		if (ci == NULL) {
			/* default outside switch */
			error(201);
		} else if (ci->c_default) {
			/* duplicate default in switch */
			error(202);
		} else {
			if (reached && !ftflg) {
				if (hflag)
					/* fallthrough on default statement */
					warning(284);
			}
			ci->c_default = 1;
		}
		break;
	};
	reached = 1;
}
Exemple #25
0
    bool Field::PEDump(PELib &peLib)
    {
        size_t sz;
        Byte *sig = SignatureGenerator::FieldSig(this, sz);
        size_t sigindex = peLib.PEOut().HashBlob(sig, sz);
        size_t nameindex = peIndex_ = peLib.PEOut().HashString(Name());
        int peflags = 0;
        if (flags_.Flags() & Qualifiers::Public)
            peflags |= FieldTableEntry::Public;
        else if (flags_.Flags() & Qualifiers::Private)
            peflags |= FieldTableEntry::Private;

        if (flags_.Flags() & Qualifiers::Static)
            peflags |= FieldTableEntry::Static;
        if (flags_.Flags() & Qualifiers::Literal)
            peflags |= FieldTableEntry::Literal;
        switch (mode_)
        {
        case Enum:
            peflags |= FieldTableEntry::HasDefault; // in the blob;
            break;
        case Bytes:
            if (byteValue_ && byteLength_)
            {
                peflags |= FieldTableEntry::HasFieldRVA; // in separate memory
            }
            break;
        }
        TableEntryBase *table = new FieldTableEntry(peflags, nameindex, sigindex);
        peIndex_ = peLib.PEOut().AddTableEntry(table);
        delete[] sig;

        Byte buf[8];
        *(longlong *)(buf) = enumValue_;
        int type;
        switch (mode_)
        {
        case Enum:
        {
            switch (size_)
            {
            case Field::i8:
                sz = 1;
                type = ELEMENT_TYPE_I1;
                break;
            case Field::i16:
                sz = 2;
                type = ELEMENT_TYPE_I2;
                break;
            case Field::i32:
            default:
                sz = 4;
                type = ELEMENT_TYPE_I4;
                break;
            case Field::i64:
                sz = 8;
                type = ELEMENT_TYPE_I8;
                break;
            }
            // this is NOT compressed like the sigs are...
            size_t valueIndex = peLib.PEOut().HashBlob(&buf[0], sz);
            Constant constant(Constant::FieldDef, peIndex_);
            table = new ConstantTableEntry(type, constant, valueIndex);
            peLib.PEOut().AddTableEntry(table);

        }
        case Bytes:
            if (byteValue_ && byteLength_)
            {
                size_t valueIndex = peLib.PEOut().RVABytes(byteValue_, byteLength_);
                table = new FieldRVATableEntry(valueIndex, peIndex_);
                peLib.PEOut().AddTableEntry(table);
            }
            break;
        }
        return true;
    }
Exemple #26
0
Pair *ConstantPool::m_read_pair(IInStream &s)
{
    unsigned head = read_chain_uint(s), tail = read_chain_uint(s);
    return PairUtil::pair(constant((int)head), constant((int)tail));
}
Exemple #27
0
void eval(BOOLEAN do_gc)
{
  static unsigned int count = 0;

  OBJECT_PTR exp = car(reg_next_expression);

  OBJECT_PTR opcode = car(exp);

  pin_globals();

  if(do_gc)
  {
    count++;

    if(count == GC_FREQUENCY)
    {
      gc(false, true);
      count = 0;
    }
  }

  if(opcode == APPLY && profiling_in_progress)
  {
    last_operator = reg_accumulator;

    if(prev_operator != NIL)
    {
      OBJECT_PTR operator_to_be_used;

      hashtable_entry_t *e;

      unsigned int count;
      unsigned int mem_alloc;
      double elapsed_wall_time;
      double elapsed_cpu_time;

      double temp1 = get_wall_time();
      clock_t temp2 = clock();
      unsigned int temp3 = memory_allocated();

      profiling_datum_t *pd = (profiling_datum_t *)malloc(sizeof(profiling_datum_t));

      if(IS_SYMBOL_OBJECT(prev_operator))
         operator_to_be_used = prev_operator;
      else
      {
        OBJECT_PTR res = get_symbol_from_value(prev_operator, reg_current_env);
        if(car(res) != NIL)
          operator_to_be_used = cdr(res);
        else
          operator_to_be_used = cons(LAMBDA,
                                     cons(get_params_object(prev_operator),
                                          cons(car(get_source_object(prev_operator)), NIL)));
      }

      e = hashtable_get(profiling_tab, (void *)operator_to_be_used);

      if(e)
      {
        profiling_datum_t *pd = (profiling_datum_t *)e->value;

        count = pd->count + 1;

        elapsed_wall_time = pd->elapsed_wall_time + temp1 - wall_time_var;
        elapsed_cpu_time = pd->elapsed_cpu_time + (temp2 - cpu_time_var) * 1.0 / CLOCKS_PER_SEC;
      
        mem_alloc = pd->mem_allocated + temp3 - mem_alloc_var;

        hashtable_remove(profiling_tab, (void *)operator_to_be_used);
        free(pd);
      }
      else
      {
        count = 1;
        elapsed_wall_time = temp1 - wall_time_var;
        elapsed_cpu_time = (temp2 - cpu_time_var) * 1.0 / CLOCKS_PER_SEC;
        mem_alloc = temp3 - mem_alloc_var;
      }

      pd->count = count;
      pd->elapsed_wall_time = elapsed_wall_time;
      pd->elapsed_cpu_time = elapsed_cpu_time;
      pd->mem_allocated = mem_alloc;

      hashtable_put(profiling_tab, (void *)operator_to_be_used, (void *)pd);
    }

    wall_time_var = get_wall_time();
    cpu_time_var = clock();
    mem_alloc_var = memory_allocated();

    prev_operator = reg_accumulator;
  }

  if(opcode == HALT)
  {
    halt_op();
  }
  else if(opcode == REFER)
  {
    if(refer(CADR(exp)))
       return;
    reg_next_expression = CADDR(exp);
  }
  else if(opcode == CONSTANT)
  {
    if(constant(CADR(exp)))
      return;
    reg_next_expression = CADDR(exp);
  }
  else if(opcode == CLOSE)
  {
    if(closure(exp))
      return;
    reg_next_expression = fifth(exp);
  }
  else if(opcode == MACRO)
  {
    if(macro(exp))
      return;
    reg_next_expression = CADDDDR(exp);
  }
  else if(opcode == TEST)
  {
    if(reg_accumulator != NIL)
      reg_next_expression = CADR(exp);
    else
      reg_next_expression = CADDR(exp);
  }
  //Not using this WHILE; reverting 
  //to macro definition, as this
  //version doesn't handle (BREAK)
  else if(opcode == WHILE)
  {
    OBJECT_PTR cond = CADR(exp);
    OBJECT_PTR body  = CADDR(exp);

    OBJECT_PTR ret = NIL;

    while(1)
    {
      OBJECT_PTR temp = reg_current_stack;

      reg_next_expression = cond;

      while(car(reg_next_expression) != NIL)
      {
        eval(false);
        if(in_error)
          return;
      }

      if(reg_accumulator == NIL)
        break;

      reg_next_expression = body;

      while(car(reg_next_expression) != NIL)
      {
        eval(false);
        if(in_error)
          return;
      }

      //to handle premature exits
      //via RETURN-FROM
      if(reg_current_stack != temp)
        return;

      ret = reg_accumulator;
    }

    reg_accumulator = ret;
    reg_next_expression = CADDDR(exp);
  }
  else if(opcode == ASSIGN)
  {
    if(assign(CADR(exp)))
      return;
    reg_next_expression = CADDR(exp);
  }
  else if(opcode == DEFINE)
  {
    if(define(CADR(exp)))
      return;
    reg_next_expression = CADDR(exp);
  }
  else if(opcode == CONTI)
  {
    if(conti())
      return;
    reg_next_expression = CADR(exp);
  }
  else if(opcode == NUATE) //this never gets called
  {
    reg_current_stack = CADR(exp);
    reg_accumulator = CADDR(exp);
    reg_current_value_rib = NIL;
    reg_next_expression =  cons(CONS_RETURN_NIL, cdr(reg_next_expression));
  }
  else if(opcode == FRAME)
  {
    if(frame(exp))
      return;
    reg_next_expression = CADDR(exp);
  }
  else if(opcode == ARGUMENT)
  {
    if(argument())
      return;
    reg_next_expression = CADR(exp);
  }
  else if(opcode == APPLY)
  {
    apply_compiled();
  }
  else if(opcode == RETURN)
  {
    return_op();
  }
}
Exemple #28
0
		std::string Value::toString() const {
			switch (kind()) {
				case SELF:
					return "self";
				case THIS:
					return "this";
				case CONSTANT:
					return makeString("Constant(%s)", constant().toString().c_str());
				case ALIAS:
					return makeString("Alias(alias: %s, templateArguments: %s)",
					                  alias().toString().c_str(),
					                  makeArrayString(aliasTemplateArguments()).c_str());
				case PREDICATE:
					return makeString("Predicate(%s)", predicate().toString().c_str());
				case LOCALVAR:
					return makeString("LocalVar(%s)", localVar().toString().c_str());
				case REINTERPRET:
					return makeString("Reinterpret(value: %s)", reinterpretOperand().toString().c_str());
				case DEREF_REFERENCE:
					return makeString("DerefReference(%s)", derefOperand().toString().c_str());
				case TERNARY:
					return makeString("Ternary(cond: %s, ifTrue: %s, ifFalse: %s)",
						ternaryCondition().toString().c_str(),
						ternaryIfTrue().toString().c_str(),
						ternaryIfFalse().toString().c_str());
				case CAST:
					return makeString("Cast(value: %s, targetType: %s)",
						castOperand().toString().c_str(),
						castTargetType()->toString().c_str());
				case POLYCAST:
					return makeString("PolyCast(value: %s, targetType: %s)",
						polyCastOperand().toString().c_str(),
						polyCastTargetType()->toString().c_str());
				case INTERNALCONSTRUCT:
					return makeString("InternalConstruct(args: %s)",
						makeArrayString(internalConstructParameters()).c_str());
				case MEMBERACCESS:
					return makeString("MemberAccess(object: %s, var: %s)",
						memberAccessObject().toString().c_str(),
						memberAccessVar().toString().c_str());
				case BIND_REFERENCE:
					return makeString("BindReference(value: %s)", bindReferenceOperand().toString().c_str());
				case TYPEREF:
					return makeString("TypeRef(targetType: %s)", typeRefType()->toString().c_str());
				case TEMPLATEVARREF:
					return makeString("TemplateVarRef(templateVar: %s)", templateVar()->toString().c_str());
				case CALL:
					return makeString("Call(funcValue: %s, args: %s)",
						callValue().toString().c_str(),
						makeArrayString(callParameters()).c_str());
				case FUNCTIONREF:
					return makeString("FunctionRef(name: %s, type: %s, parentType: %s, templateArgs: %s)",
						functionRefFunction().fullName().toString().c_str(),
						type()->toString().c_str(),
						functionRefParentType() != nullptr ?
							functionRefParentType()->toString().c_str() :
							"[NONE]",
						makeArrayString(functionRefTemplateArguments()).c_str());
				case TEMPLATEFUNCTIONREF:
					return makeString("TemplateFunctionRef(name: %s, parentType: %s)",
						templateFunctionRefName().c_str(),
						templateFunctionRefParentType()->toString().c_str());
				case METHODOBJECT:
					return makeString("MethodObject(method: %s, object: %s)",
						methodObject().toString().c_str(),
						methodOwner().toString().c_str());
				case INTERFACEMETHODOBJECT:
					return makeString("InterfaceMethodObject(method: %s, object: %s)",
						interfaceMethodObject().toString().c_str(),
						interfaceMethodOwner().toString().c_str());
				case STATICINTERFACEMETHODOBJECT:
					return makeString("StaticInterfaceMethodObject(method: %s, typeRef: %s)",
						staticInterfaceMethodObject().toString().c_str(),
						staticInterfaceMethodOwner().toString().c_str());
				case CAPABILITYTEST:
					return makeString("CapabilityTest(checkType: %s, capabilityType: %s)",
					                  capabilityTestCheckType()->toString().c_str(),
					                  capabilityTestCapabilityType()->toString().c_str());
				case Value::ARRAYLITERAL:
					return makeString("ArrayLiteral(type: %s, values: %s)",
					                  type()->toString().c_str(),
					                  makeArrayString(arrayLiteralValues()).c_str());
				case NEW:
					return makeString("New(placementArg: %s, operand: %s)",
					                  newPlacementArg().toString().c_str(),
					                  newOperand().toString().c_str());
				case CASTDUMMYOBJECT:
					return makeString("[CAST DUMMY OBJECT (FOR SEMANTIC ANALYSIS)](type: %s)",
						type()->toString().c_str());
			}
			
			locic_unreachable("Unknown value kind.");
		}
Exemple #29
0
int Constant::compare(const Basic &o) const
{
    SYMENGINE_ASSERT(is_a<Constant>(o))
    const Constant &s = static_cast<const Constant &>(o);
    if (name_ == s.name_)
        return 0;
    return name_ < s.name_ ? -1 : 1;
}

RCP<const Integer> zero = integer(0);
RCP<const Integer> one = integer(1);
RCP<const Integer> minus_one = integer(-1);
RCP<const Number> I = Complex::from_two_nums(*zero, *one);

RCP<const Constant> pi = constant("pi");
RCP<const Constant> E = constant("E");
RCP<const Constant> EulerGamma = constant("EulerGamma");

// Global variables declared in functions.cpp
// Look over https://github.com/sympy/symengine/issues/272
// for further details
RCP<const Basic> i2 = integer(2);

namespace
{
RCP<const Basic> sqrt_(const RCP<const Basic> &arg)
{
    return pow(arg, div(one, i2));
}
}
Exemple #30
0
signal_t fir(ptr_t a, signal_t rec)
{
    return fa_add((signal_t) delay(10, a), fa_multiply(rec, constant(0.9999)));
}