예제 #1
0
파일: luainput.cpp 프로젝트: redxdev/Wake
 void push_cursor_mode_constants(lua_State* L)
 {
     lua_newtable(L);
     add_constant(L, "Normal", (lua_Integer) CursorMode::Normal);
     add_constant(L, "Hidden", (lua_Integer) CursorMode::Hidden);
     add_constant(L, "Disabled", (lua_Integer) CursorMode::Disabled);
 }
예제 #2
0
static bool set_build_target( void )
/**********************************/
{
    if( Options.build_target == NULL ) {
#if defined(__OSI__)
        if( __OS == OS_DOS ) {
            SetTargName( "DOS", 3 );
        } else if( __OS == OS_OS2 ) {
            SetTargName( "OS2", 3 );
        } else if( __OS == OS_NT ) {
            SetTargName( "NT", 2 );
        } else if( __OS == OS_WIN ) {
            SetTargName( "WINDOWS", 7 );
        } else {
            SetTargName( "XXX", 3 );
        }
#elif defined(__QNX__)
        SetTargName( "QNX", 3 );
#elif defined(__LINUX__)
        SetTargName( "LINUX", 5 );
#elif defined(__HAIKU__)
        SetTargName( "HAIKU", 5 );
#elif defined(__BSD__)
        SetTargName( "BSD", 3 );
#elif defined(__OSX__) || defined(__APPLE__)
        SetTargName( "OSX", 3 );
#elif defined(__SOLARIS__) || defined( __sun )
        SetTargName( "SOLARIS", 7 );
#elif defined(__DOS__)
        SetTargName( "DOS", 3 );
#elif defined(__OS2__)
        SetTargName( "OS2", 3 );
#elif defined(__NT__)
        SetTargName( "NT", 2 );
#elif defined(__ZDOS__)
        SetTargName( "ZDOS", 4 );
#else
        #error unknown host OS
#endif
    }

    add_constant( Options.build_target, true ); // always define something

    if( stricmp( Options.build_target, "DOS" ) == 0 ) {
        add_constant( "MSDOS", true );
    } else if( stricmp( Options.build_target, "NETWARE" ) == 0 ) {
        if( (Code->info.cpu&P_CPU_MASK) >= P_386 ) {
            add_constant( "NETWARE_386", true );
        }
    } else if( stricmp( Options.build_target, "WINDOWS" ) == 0 ) {
        if( (Code->info.cpu&P_CPU_MASK) >= P_386 ) {
            add_constant( "WINDOWS_386", true );
        }
    } else if( stricmp( Options.build_target, "QNX" ) == 0
      || stricmp( Options.build_target, "LINUX" ) == 0
      || stricmp( Options.build_target, "BSD" ) == 0 ) {
        add_constant( "UNIX", true );
    }
    return( RC_OK );
}
예제 #3
0
파일: luainput.cpp 프로젝트: redxdev/Wake
 void push_action_constants(lua_State* L)
 {
     lua_newtable(L);
     add_constant(L, "Press", (lua_Integer) InputAction::Press);
     add_constant(L, "Release", (lua_Integer) InputAction::Release);
     add_constant(L, "Repeat", (lua_Integer) InputAction::Repeat);
 }
예제 #4
0
파일: menu.c 프로젝트: Efreak/elinks
int
python_init_menu_interface(PyObject *dict, PyObject *name)
{
	if (add_constant(dict, "MENU_LINK", PYTHON_MENU_LINK) != 0) return -1;
	if (add_constant(dict, "MENU_TAB", PYTHON_MENU_TAB) != 0) return -1;

	return add_python_methods(dict, name, menu_methods);
}
예제 #5
0
static void set_cpu_mode( void )
/******************************/
{
    // set parameters passing convention macro
    if( SWData.cpu >= 3 ) {
        if( Options.watcom_parms_passed_by_regs ) {
            add_constant( "REGISTER", true );
        } else {
            add_constant( "STACK", true );
        }
    }
}
예제 #6
0
static void set_fpu_mode( void )
/******************************/
{
    switch( floating_point ) {
    case DO_FP_EMULATION:
        add_constant( "FPI", true );
        break;
    case NO_FP_EMULATION:
        add_constant( "FPI87", true );
        break;
    case NO_FP_ALLOWED:
        add_constant( "FPC", true );
        break;
    }
}
예제 #7
0
void set_fpu_parameters( void )
/*****************************/
{
    switch( Options.floating_point ) {
    case DO_FP_EMULATION:
        add_constant( "__FPI__" );
        break;
    case NO_FP_EMULATION:
        add_constant( "__FPI87__" );
        break;
    case NO_FP_ALLOWED:
        add_constant( "__FPC__" );
        cpu_directive( T_DOT_NO87 );
        return;
    }
    switch( SWData.fpu ) {
    case 0:
    case 1:
        cpu_directive( T_DOT_8087 );
        break;
    case 2:
        cpu_directive( T_DOT_287 );
        break;
    case 3:
    case 5:
    case 6:
        cpu_directive( T_DOT_387 );
        break;
    case 7:
    default: // unspecified FPU
        switch( SWData.cpu ) {
        case 0:
        case 1:
            cpu_directive( T_DOT_8087 );
            break;
        case 2:
            cpu_directive( T_DOT_287 );
            break;
        case 3:
        case 4:
        case 5:
        case 6:
            cpu_directive( T_DOT_387 );
            break;
        }
        break;
    }
}
예제 #8
0
int main(int argc, char* argv[])
{
    int var_to_be_added_to = atoi(argv[1]);
    int var_added = add_constant(var_to_be_added_to);
    printf("%d\n", var_added);
    return 0;
}
예제 #9
0
파일: ins.c 프로젝트: x3ro/tinyos-legacy
void ins_constant(value cst, fncode fn)
/* Effects: Adds code to push cst onto the stack in 'fn'
   Modifies: fn
*/
{
  ins0(OPmcst, fn)->cst = add_constant(cst, fn);
}
예제 #10
0
static void do_init_stuff( char **cmdline )
/*****************************************/
{
    char        *env;
    char        buff[80];

    if( !MsgInit() )
        exit(1);

    AsmInit( -1, -1, -1, -1 );                // initialize hash table
    strcpy( buff, "__WASM__=" BANSTR( _BANVER ) );
    add_constant( buff );
    ForceInclude = getenv( "FORCE" );
    do_envvar_cmdline( "WASM" );
    parse_cmdline( cmdline );
    set_build_target();
    get_os_include();
    env = getenv( "INCLUDE" );
    if( env != NULL )
        AddStringToIncludePath( env );
    if( !Options.quiet && !Options.banner_printed ) {
        Options.banner_printed = TRUE;
        trademark();
    }
    open_files();
    PushLineQueue();
    AsmLookup( "$" );    // create "$" symbol for current segment counter
}
예제 #11
0
  Encoding* Encoding::alias(STATE, const char* name, const char* original) {
    int index = find_index(state, original);
    if(index < 0) return nil<Encoding>();

    Tuple* ref = encoding_reference(state, index, name);
    encoding_map(state)->store(state, encoding_symbol(state, name), ref);
    add_constant(state, name, from_index(state, index));

    return as<Encoding>(encoding_list(state)->get(state, index));
  }
예제 #12
0
파일: encoding.cpp 프로젝트: meh/rubinius
  Encoding* Encoding::create_bootstrap(STATE, const char* name,
                                       Index index, OnigEncodingType* enc)
  {
    Encoding* e = create(state, enc);
    symbol_map(state)->store(state, state->symbol(name), e);
    index_map(state)->store(state, Fixnum::from(index), e);
    add_constant(state, name, e);

    return e;
  }
예제 #13
0
void init_comparison_words(context_t *ctx)
{
    hashtable_t *htbl = ctx->exe_tok;
    add_primitive(htbl, "=",  __EQ,   "( x1 x2 -- f )", "compares top two stack elements, returns true flag if equal, false otherwise.");
    add_primitive(htbl, "<>", __NEQ,  "( x1 x2 -- f )", "compares top two stack elements, returns true flag if different, false otherwise.");
    add_primitive(htbl, "<",  __LT,   "( n1 n2 -- f )", "compares signed numbers n1 with n2, returns true if n1 is less then n2.");
    add_primitive(htbl, ">",  __GT,   "( n1 n2 -- f )", "compares signed numbers n1 with n2, returns true if n1 is greater then n2.");
    add_primitive(htbl, "U<", __ULT,  "( u1 u2 -- f )", "compares unsigned numbers u1 with u2, returns true if n1 is lower then n2.");
    add_primitive(htbl, "U>", __UGT,  "( u1 u2 -- f )", "compares unsigned numbers u1 with u2, returns true if n1 is higher then n2.");
    add_primitive(htbl, "0<", __ISNEG, "( n -- f )", "return a true flag if value of n is negative.");
    add_primitive(htbl, "0=", __ISZERO, "( x -- f )", "return a true flag if value of x is zero.");
    add_primitive(htbl, "0<>", __ISNOTZERO, "( x -- f )", "return a true flag if value of x is not zero.");
    add_primitive(htbl, "0>", __ISPOS,  "( n -- f )", "return a true flag if value of x is greater than zero.");
    add_primitive(htbl, "WITHIN", __WITHIN, "( x1 x2 x3 -- f )", "return a true flag if x1 is in the range of x2 ... x3-1.");

    // TODO: Move into system.fth
    add_constant(ctx, "FALSE", 0);
    add_constant(ctx, "TRUE", -1);
}
예제 #14
0
  Encoding* Encoding::create_bootstrap(STATE, const char* name,
                                       Index index, OnigEncodingType* enc)
  {
    Encoding* e = create(state, enc);
    Tuple* ref = encoding_reference(state, index);
    encoding_map(state)->store(state, encoding_symbol(state, name), ref);
    encoding_list(state)->set(state, index, e);
    add_constant(state, name, e);

    return e;
  }
예제 #15
0
파일: encoding.cpp 프로젝트: meh/rubinius
  Encoding* Encoding::define(STATE, const char* name,
                             OnigEncodingType* enc, Object* dummy)
  {
    Encoding* e = create(state, enc, dummy);

    e->name(state, String::create(state, name));

    symbol_map(state)->store(state, state->symbol(name), e);
    add_constant(state, name, e);

    return e;
  }
예제 #16
0
void set_cpu_parameters( void )
/*****************************/
{
    int token;

    // Start in masm mode
    Options.mode &= ~MODE_IDEAL;
    // set parameters passing convention macro
    if( SWData.cpu >= 3 ) {
        if( Options.watcom_parms_passed_by_regs ) {
            add_constant( "__REGISTER__" );
        } else {
            add_constant( "__STACK__" );
        }
    }
    switch( SWData.cpu ) {
    case 0:
        token = T_DOT_8086;
        break;
    case 1:
        token = T_DOT_186;
        break;
    case 2:
        token =  SWData.protect_mode ? T_DOT_286P : T_DOT_286;
        break;
    case 3:
        token =  SWData.protect_mode ? T_DOT_386P : T_DOT_386;
        break;
    case 4:
        token =  SWData.protect_mode ? T_DOT_486P : T_DOT_486;
        break;
    case 5:
        token =  SWData.protect_mode ? T_DOT_586P : T_DOT_586;
        break;
    case 6:
        token =  SWData.protect_mode ? T_DOT_686P : T_DOT_686;
        break;
    }
    cpu_directive( token );
}
예제 #17
0
// n,n pade approximation for the exponential
static void
horners_pade( GLU_complex a[ NCNC ] ,
	      const GLU_complex b[ NCNC ] )
{
  size_t i ;
  for( i = 0 ; i < NCNC ; i++ ) { a[i] = b[i] * pade[PADE_ORDER] ; } 
  for( i = PADE_ORDER-1 ; i > 0 ; i-- ) {    
    add_constant( a , pade[i] ) ; 
    multab_atomic_left( a , b ) ;    
  }
  for( i = 0 ; i < NC ; i++ ) { a[ i*(NC+1) ] += 1.0 ; }
  return ;
}
예제 #18
0
/*
 * Load a float32 immediate value into a float register.  If the value is
 * complicated, then add an entry to the constant pool.
 */
static void mov_freg_imm_32
	(jit_gencode_t gen, arm_inst_buf *inst, int reg, int value)
{
	arm_inst_word *fixup;

	/* Output a placeholder to load the value later */
	fixup = arm_inst_get_posn(*inst);
	arm_load_membase_float32(*inst, reg, ARM_PC, 0);

	/* Add the constant to the pool, which may cause a flush */
	jit_gen_save_inst_ptr(gen, *inst);
	add_constant(gen, value, fixup);
	jit_gen_load_inst_ptr(gen, *inst);
}
예제 #19
0
// horner's expansion for the exponential
static void
horners_exp( GLU_complex a[ NCNC ] ,
	     const GLU_complex b[ NCNC ] ,
	     const size_t n )
{
  size_t i ;
  // I use max iterations 13 for double prec and 8 for single it was before
  // this selection was borne out of heavy testing I would urge you to keep it
  #ifndef SINGLE_PREC
  for( i = 0 ; i < NCNC ; i++ ) { a[i] = b[i] * factorial[13] ; } 
  for( i = 12 ; i > 0 ; i-- ) {
    add_constant( a , factorial[i] ) ; 
    multab_atomic_left( a , b ) ;    
  }
  #else
  for( i = 0 ; i < NCNC ; i++ ) { a[i] = b[i] * factorial[9] ; } 
  for( i = 8 ; i > 0 ; i-- ) {    
    add_constant( a , factorial[i] ) ; 
    multab_atomic_left( a , b ) ;    
  }
  #endif
  for( i = 0 ; i < NC ; i++ ) { a[ i*(NC+1) ] += 1.0 ; }
  return ;
}
예제 #20
0
void permutation(WORDSIZE* state){        
    REGISTER t, a, b, c, d;    
    load_register(a, state, 0); load_register(b, state, 4); 
    load_register(c, state, 8); load_register(d, state, 12);           
    
    int index;                
    WORDSIZE round_constants[4] = {1, 0, 0, 0};    
    
    for (index = 1; index < ROUNDS + 1; index++){
        add_constant(a);
        mix_slice(a, b, c, d);
        shift_sections(b, c, d);}    
        
    store_register(a, state, 0); store_register(b, state, 4);
    store_register(c, state, 8); store_register(d, state, 12);}                
예제 #21
0
파일: ins.c 프로젝트: x3ro/tinyos-legacy
u8 *ins_closure(value code, u16 clen, fncode fn)
/* Effects: Adds code for a 'clen' variable closure with function 'code'
     to 'fn'
   Returns: Pointer to area to add the closure variables
*/
{
  ilist cins = add_ins(OPmclosure, 1, fn);

  cins->arg = clen;
  cins->cst = add_constant(code, fn);
  cins->cvars = allocate(fnmemory(fn), clen * sizeof(*cins->cvars));
  adjust_depth(1, fn);

  return cins->cvars;
}
예제 #22
0
  Encoding* Encoding::define(STATE, const char* name,
                             OnigEncodingType* enc, Object* dummy)
  {
    Encoding* e = create(state, enc, dummy);

    e->name(state, String::create(state, name));

    Array* list = encoding_list(state);
    size_t index = list->size();

    Tuple* ref = encoding_reference(state, index);
    encoding_map(state)->store(state, encoding_symbol(state, name), ref);
    list->set(state, index, e);
    add_constant(state, name, e);

    return e;
  }
예제 #23
0
/*
 * Load an immediate value into a word register.  If the value is
 * complicated, then add an entry to the constant pool.
 */
static void mov_reg_imm
	(jit_gencode_t gen, arm_inst_buf *inst, int reg, int value)
{
	arm_inst_word *fixup;

	/* Bail out if the value is not complex enough to need a pool entry */
	if(!arm_is_complex_imm(value))
	{
		arm_mov_reg_imm(*inst, reg, value);
		return;
	}

	/* Output a placeholder to load the value later */
	fixup = arm_inst_get_posn(*inst);
	arm_load_membase(*inst, reg, ARM_PC, 0);

	/* Add the constant to the pool, which may cause a flush */
	jit_gen_save_inst_ptr(gen, *inst);
	add_constant(gen, value, fixup);
	jit_gen_load_inst_ptr(gen, *inst);
}
예제 #24
0
logistic_normal::logistic_normal(const dmatrix *_O,const dvar_matrix *_E,
                                 const double _minProportion,const double _eps)
: m_eps(_eps), m_dMinimumProportion(_minProportion), m_O(*_O), m_E(*_E)
{
	
	m_y1 = m_O.rowmin();
	m_y2 = m_O.rowmax();

	m_b1 = m_O.colmin();
	m_b2 = m_O.colmax();

	if(m_E.colmin() != m_b1 || m_E.colmax() != m_b2 )
	{
		cerr<<"Observed and Predicted composition columns do not match"<<endl;
		ad_exit(1);
	}
	if(m_E.rowmin() != m_y1 || m_E.rowmax() != m_y2 )
	{
		cerr<<"Observed and Predicted composition rows do not match"<<endl;
		ad_exit(1);
	}

	// 1). Suppress zeros, if eps==0 use aggregate_and_compress_arrays
	if( m_eps > 0.0 )
	{
		// add constant
		add_constant(m_eps);

	}
	else if( m_eps == 0.0 && m_dMinimumProportion >= 0 )
	{
		// use aggregate_and_compress_arrays
		aggregate_and_compress_arrays();
	}

	// 3). Compute relative weights (m_dWy)
	compute_relative_weights();
	
}
예제 #25
0
static void do_init_stuff( char **cmdline )
/*****************************************/
{
    char        *env;

    if( !MsgInit() )
        exit(1);

    add_constant( "WASM=" BANSTR( _BANVER ), true );
    ForceInclude = AsmStrDup( getenv( "FORCE" ) );
    do_envvar_cmdline( "WASM" );
    parse_cmdline( cmdline );
    set_build_target();
    set_cpu_mode();
    set_fpu_mode();
    get_os_include();
    env = getenv( "INCLUDE" );
    if( env != NULL )
        AddItemToIncludePath( env, NULL );
    PrintBanner();
    open_files();
    PushLineQueue();
}
예제 #26
0
파일: cancer.c 프로젝트: SRI-CSL/pce
int main(int argc, char **argv) {
  int i, j;
  samp_table_t *table = &samp_table;

  char *fr_args[] = {"Person", "Person", NULL};
  char *other_args[] = {"Person", NULL};


  rand_reset(); // May be reset in options
  //  decode_options(argc, argv);
  init_samp_table(table);

  sort_table_t *sort_table = &table->sort_table;
  var_table_t *var_table = &table->var_table;
  atom_table_t *atom_table = &table->atom_table;

  /* Declare all sorts: */
  add_sort(sort_table, "Person");

  /* Declare all constants: */
  add_constant("Ann", "Person", table);
  add_constant("Bob", "Person", table);
  add_constant("Carl", "Person", table);
  add_constant("Dee", "Person", table);
  add_constant("Earl", "Person", table);
  add_constant("Fran", "Person", table);

  /* The "witness" arg is simply a direct (1) / indirect (0) indicator: */

  /* Declare all predicates: */
  add_predicate("Fr", fr_args, 0, table);
  add_predicate("Sm", other_args, 0, table);
  add_predicate("Ca", other_args, 0, table);
  add_predicate("Frl", other_args, 0, table);

  double weight = 1.0;
  double maxweight = DBL_MAX;
  input_atom_t *atom;
  input_fmla_t *fmla;
  input_formula_t *formula;

  /* Now add the formulae - we should inspect this for regularities
     that can be incorporated into a higher-level API.  */

  // add [x] ~Fr(x,x);
  char *var[] = { "x", NULL };
  char *args1[] = { "x", "x", NULL };
  atom = make_atom("Fr", args1, 0);
  fmla = make_fmla(NOT, atom_to_fmla(atom), NULL);
  formula = make_formula(var, fmla);
  add_cnf(NULL, formula, maxweight, NULL, 1);


  // add [x, y, z] Fr(x, y) and Fr(y, z) => Fr(x, z)  0.7;
  char *vars2[] = { "x", "y", "z", NULL };
  char *a1[] = { "x", "y", NULL };
  char *a2[] = { "y", "z", NULL };
  char *a3[] = { "x", "z", NULL };

  fmla = make_fmla(AND,
		   atom_to_fmla(make_atom("Fr", a1, 0)),
		   atom_to_fmla(make_atom("Fr", a2, 0)));
  fmla = make_fmla(IMPLIES, fmla, atom_to_fmla(make_atom("Fr", a3, 0)));
  formula = make_formula(vars2, fmla);
  add_cnf(NULL, formula, 0.7, NULL, 1);



  // add [x, y] Fr(x, y) => ~Frl(x);
  input_atom_t *atom1;
  char *vars3[] = { "x", "y", NULL };
  char *b1[] = { "x", "y", NULL };
  char *b2[] = { "x",  NULL };
  char *b3[] = { "y",  NULL };
  atom = make_atom("Fr", b1, 0);
  atom1 = make_atom("Frl", b2, 0);
  fmla = make_fmla(NOT, atom_to_fmla(atom1), NULL);
  fmla = make_fmla(IMPLIES, atom_to_fmla(atom), fmla);
  formula = make_formula(vars3, fmla);
  add_cnf(NULL, formula, maxweight, NULL, 1);



  // add [x] Frl(x) => Sm(x)  2.3;
  fmla = make_fmla(IMPLIES, atom_to_fmla(make_atom("Frl", b2, 0)), atom_to_fmla(make_atom("Sm", b2, 0)));
  formula = make_formula(b2, fmla);
  add_cnf(NULL, formula, 2.3, NULL, 1);



  // add [x] Sm(x) => Ca(x)  1.5;
  fmla = make_fmla(IMPLIES, atom_to_fmla(make_atom("Sm", b2, 0)), atom_to_fmla(make_atom("Ca", b2, 0)));
  formula = make_formula(b2, fmla);
  add_cnf(NULL, formula, 1.5, NULL, 1);



  // add [x, y] Fr(x, y) implies (Sm(x) iff Sm(y))  1.1;
  fmla = make_fmla(IMPLIES,
		   atom_to_fmla(make_atom("Sm", b2, 0)),
		   make_fmla(IFF,
			     atom_to_fmla(make_atom("Sm", b2, 0)),
			     atom_to_fmla(make_atom("Sm", b3, 0)))
		   );
  formula = make_formula(b1, fmla);
  add_cnf(NULL, formula, 1.1, NULL, 1);



  //add Fr(Ann, Bob);
  char *ann_bob[] = { "Ann", "Bob", NULL };
  formula = make_formula(NULL, atom_to_fmla(make_atom("Fr", ann_bob, 0)));
  add_cnf(NULL, formula, DBL_MAX, NULL, 1);



  //add Fr(Bob, Carl);
  char *bob_carl[] = { "Bob", "Carl", NULL };
  formula = make_formula(NULL, atom_to_fmla(make_atom("Fr", bob_carl, 0)));
  add_cnf(NULL, formula, DBL_MAX, NULL, 1);



  //add Fr(Dee, Earl);
  char *dee_earl[] = { "Dee", "Earl", NULL };
  formula = make_formula(NULL, atom_to_fmla(make_atom("Fr", dee_earl, 0)));
  add_cnf(NULL, formula, DBL_MAX, NULL, 1);


  // Now solve:
  mc_sat(table, lazy_mcsat(), 10000, // get_max_samples(),
	 get_sa_probability(), get_sa_temperature(),
	 get_rvar_probability(), get_max_flips(),
	 get_max_extra_flips(), get_mcsat_timeout(),
	 get_burn_in_steps(), get_samp_interval());

  // Print the results:
  dumptable(ALL, table);
}
예제 #27
0
static void DefineMacro( void ) { add_constant( CopyOfParm() ); }
예제 #28
0
static int set_build_target( void )
/*********************************/
{
    char *tmp;
    char *uscores = "__";

    if( Options.build_target == NULL ) {
#if defined(__OSI__)
        if( __OS == OS_DOS ) {
            SetTargName( "DOS", 3 );
        } else if( __OS == OS_OS2 ) {
            SetTargName( "OS2", 3 );
        } else if( __OS == OS_NT ) {
            SetTargName( "NT", 2 );
        } else if( __OS == OS_WIN ) {
            SetTargName( "WINDOWS", 7 );
        } else {
            SetTargName( "XXX", 3 );
        }
#elif defined(__QNX__)
        SetTargName( "QNX", 3 );
#elif defined(__LINUX__)
        SetTargName( "LINUX", 5 );
#elif defined(__BSD__)
        SetTargName( "BSD", 3 );
#elif defined(__OSX__) || defined(__APPLE__)
        SetTargName( "OSX", 3 );
#elif defined(__SOLARIS__) || defined( __sun )
        SetTargName( "SOLARIS", 7 );
#elif defined(__DOS__)
        SetTargName( "DOS", 3 );
#elif defined(__OS2__)
        SetTargName( "OS2", 3 );
#elif defined(__NT__)
        SetTargName( "NT", 2 );
#elif defined(__ZDOS__)
        SetTargName( "ZDOS", 4 );
#else
        #error unknown host OS
#endif
    }

    tmp = AsmTmpAlloc( strlen( Options.build_target ) + 5 ); // null + 4 uscores
    strcpy( tmp, uscores );
    strcat( tmp, Options.build_target );
    strcat( tmp, uscores );

    add_constant( tmp ); // always define something

    if( stricmp( Options.build_target, "DOS" ) == 0 ) {
        add_constant( "__MSDOS__" );
    } else if( stricmp( Options.build_target, "NETWARE" ) == 0 ) {
        if( (Code->info.cpu&P_CPU_MASK) >= P_386 ) {
            add_constant( "__NETWARE_386__" );
        } else {
            /* do nothing ... __NETWARE__ already defined */
        }
    } else if( stricmp( Options.build_target, "WINDOWS" ) == 0 ) {
        if( (Code->info.cpu&P_CPU_MASK) >= P_386 ) {
            add_constant( "__WINDOWS_386__" );
        } else {
            /* do nothing ... __WINDOWS__ already defined */
        }
    } else if( stricmp( Options.build_target, "QNX" ) == 0 ) {
        add_constant( "__UNIX__" );
    } else if( stricmp( Options.build_target, "LINUX" ) == 0 ) {
        add_constant( "__UNIX__" );
    } else if( stricmp( Options.build_target, "BSD" ) == 0 ) {
        add_constant( "__UNIX__" );
    }
    return( NOT_ERROR );
}
예제 #29
0
unsigned load_program(
	struct radeon_compiler *c,
	struct rc_test_file *test,
	const char *filename)
{
	char line[MAX_LINE_LENGTH];
	char path[MAX_PATH_LENGTH];
	FILE *file;
	unsigned *count;
	char **string_store;
	unsigned i = 0;

	memset(line, 0, sizeof(line));
	snprintf(path, MAX_PATH_LENGTH, "compiler/tests/%s", filename);
	file = fopen(path, "r");
	if (!file) {
		return 0;
	}
	memset(test, 0, sizeof(struct rc_test_file));

	count = &test->num_input_lines;

	while (fgets(line, MAX_LINE_LENGTH, file)){
		char last_char = line[MAX_LINE_LENGTH - 1];
		if (last_char && last_char != '\n') {
			fprintf(stderr, "Error line cannot be longer than 100 "
				"characters:\n%s\n", line);
			fclose(file);
			return 0;
		}

		// Comment
		if (line[0] == '#' || is_whitespace(line)) {
			continue;
		}

		if (line[0] == '=') {
			count = &test->num_expected_lines;
			continue;
		}

		(*count)++;
	}

	test->input = malloc(sizeof(char *) * test->num_input_lines);
	test->expected = malloc(sizeof(char *) * test->num_expected_lines);

	rewind(file);
	string_store = test->input;

	while(fgets(line, MAX_LINE_LENGTH, file)) {
		// Comment
		char * dst;
		if (line[0] == '#' || is_whitespace(line)) {
			continue;
		}

		if (line[0] == '=') {
			i = 0;
			string_store = test->expected;
			continue;
		}

		dst = string_store[i++] = malloc((strlen(line) + 1) *
							sizeof (char));
		strcpy(dst, line);
	}

	for (i = 0; i < test->num_input_lines; i++) {
		if (test->input[i][0] == 'c') {
			add_constant(c, test->input[i]);
			continue;
		}
		// XXX: Parse immediates from the file.
		add_instruction(c, test->input[i]);
	}

	fclose(file);
	return 1;
}
예제 #30
0
파일: math.c 프로젝트: FunnyLanguage/funny
void init_math_constants(Scheme *sc) {
	add_constant(sc, "*PI*", make_real(sc, M_PI));
	add_constant(sc, "*E*", make_real(sc, M_E));
}