Example #1
0
unsigned geoip_num_countries() {
	if ((void*)xqf_geoip_country_code == (void*)-1)
		return 0;

	if (!xqf_geoip_country_code) {
		unsigned i;

		xqf_geoip_country_name = lookup_symbol("GeoIP_country_name");
		xqf_geoip_country_code = lookup_symbol("GeoIP_country_code");

		if (!xqf_geoip_country_name || !xqf_geoip_country_code) {
			/* nasty hack to determine the number of countries at run time */
			MaxCountries = LAN_GeoIPid = 0;
			xqf_geoip_country_name = (void*)-1;
			xqf_geoip_country_code = (void*)-1;
			return 0;
		}

		for (i = 0; xqf_geoip_country_code[i*3] && i < 333 /* arbitrary limit */; ++i)
			/* nothing */;

		if (i >= 333) {
			xqf_geoip_country_name = (void*)-1;
			xqf_geoip_country_code = (void*)-1;
			xqf_error("failed to determine number of supported countries");
			return 0;
		}

		MaxCountries = LAN_GeoIPid = i;
	}

	debug(1, "MaxCountries %u", MaxCountries);

	return MaxCountries;
}
Example #2
0
File: interp.c Project: mdoug/FIAL
static inline int execute_call_B (node *stmt, exec_env *env)
{
	value proc;
	value lib;
	int res = 1;

	if(env->interp->omnis) {
		res = lookup_symbol(&lib, env->interp->omnis, stmt->sym);
	}
	if(res == 1) {
		assert(env->lib);
		if(!env->lib->libs) {
			env->error.code = ERROR_UNKNOWN_LIB;
			env->error.line = stmt->loc.line;
			env->error.col  = stmt->loc.col;
			env->error.file = env->lib->label;
			env->error.static_msg = "attempt to call a proc"
			                        " in an undeclared_lib";
			return -1;
		}
		res = lookup_symbol(&lib, env->lib->libs, stmt->sym);
		if(res == 1) {
			env->error.code = ERROR_UNKNOWN_PROC;
			env->error.line = stmt->loc.line;
			env->error.col  = stmt->loc.col;
			env->error.file = env->lib->label;
			env->error.static_msg = "attempt to access undeclared lib";
			return -1;
		}
	}
	if(lib.type == VALUE_LIB) {
		res = lookup_symbol(&proc, lib.lib->procs,
				    stmt->left->sym);
		if(res == 1) {
			env->error.code = ERROR_UNKNOWN_PROC;
			env->error.line = stmt->loc.line;
			env->error.col  = stmt->loc.col;
			env->error.file = env->lib->label;
			env->error.static_msg = "attempt to call unknown proc";
			return -1;
		}
		assert(proc.type == VALUE_NODE);
		return  perform_call_on_node(proc.node, stmt->right, lib.lib, env);
	} else {
		assert(lib.type == VALUE_C_LIB);
		res = lookup_symbol(&proc, lib.c_lib->funcs, stmt->left->sym);
		if(res == 1) {
			env->error.code = ERROR_UNKNOWN_PROC;
			env->error.line = stmt->loc.line;
			env->error.col  = stmt->loc.col;
			env->error.file = env->lib->label;
			env->error.static_msg = "attempt to call unknown function";
			return -1;
		}
		return interp_call_on_func(proc.func, stmt->right, env);

	}
	assert(0);
	return -1;
}
Example #3
0
void pointInfo(char *name){
  int i,j;
  if(name == NULL){
    pointColor[0][0] = 20;
    pointColor[1][0] = 200;
    pointColor[2][0] = 30;
    for(i = 0; i < 3; i++){
      for(j = 1; j < 3; j++){
	pointColor[i][j] = 0;
      }
    }
  }
  else {
    SYMTAB *co;
    co = (SYMTAB *)lookup_symbol(name);
    pointColor[0][0] = co->s.c->r[0];
    pointColor[1][0] = co->s.c->g[0];
    pointColor[2][0] = co->s.c->b[0];
    pointColor[0][1] = co->s.c->r[1];
    pointColor[1][1] = co->s.c->g[1];
    pointColor[2][1] = co->s.c->b[1];
    pointColor[0][2] = co->s.c->r[2];
    pointColor[1][2] = co->s.c->g[2];
    pointColor[2][2] = co->s.c->b[2];
  }
}
static int
inspect_type (struct demangle_parse_info *info,
	      struct demangle_component *ret_comp,
	      canonicalization_ftype *finder,
	      void *data)
{
  int i;
  char *name;
  struct symbol *sym;
  volatile struct gdb_exception except;

  /* Copy the symbol's name from RET_COMP and look it up
     in the symbol table.  */
  name = (char *) alloca (ret_comp->u.s_name.len + 1);
  memcpy (name, ret_comp->u.s_name.s, ret_comp->u.s_name.len);
  name[ret_comp->u.s_name.len] = '\0';

  /* Ignore any typedefs that should not be substituted.  */
  for (i = 0; i < ARRAY_SIZE (ignore_typedefs); ++i)
    {
      if (strcmp (name, ignore_typedefs[i]) == 0)
	return 0;
    }

  sym = NULL;
  TRY_CATCH (except, RETURN_MASK_ALL)
  {
    sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
  }
Example #5
0
void lm32_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
                         int flags)
{
    LM32CPU *cpu = LM32_CPU(cs);
    CPULM32State *env = &cpu->env;
    int i;

    if (!env || !f) {
        return;
    }

    cpu_fprintf(f, "IN: PC=%x %s\n",
                env->pc, lookup_symbol(env->pc));

    cpu_fprintf(f, "ie=%8.8x (IE=%x EIE=%x BIE=%x) im=%8.8x ip=%8.8x\n",
             env->ie,
             (env->ie & IE_IE) ? 1 : 0,
             (env->ie & IE_EIE) ? 1 : 0,
             (env->ie & IE_BIE) ? 1 : 0,
             lm32_pic_get_im(env->pic_state),
             lm32_pic_get_ip(env->pic_state));
    cpu_fprintf(f, "eba=%8.8x deba=%8.8x\n",
             env->eba,
             env->deba);

    for (i = 0; i < 32; i++) {
        cpu_fprintf(f, "r%2.2d=%8.8x ", i, env->regs[i]);
        if ((i + 1) % 4 == 0) {
            cpu_fprintf(f, "\n");
        }
    }
    cpu_fprintf(f, "\n\n");
}
Example #6
0
static struct mdebug_extra_func_info *
find_proc_desc (CORE_ADDR pc)
{
  struct block *b = block_for_pc (pc);
  struct mdebug_extra_func_info *proc_desc = NULL;
  struct symbol *sym = NULL;

  if (b)
    {
      CORE_ADDR startaddr;
      find_pc_partial_function (pc, NULL, &startaddr, NULL);

      if (startaddr > BLOCK_START (b))
	/* This is the "pathological" case referred to in a comment in
	   print_frame_info.  It might be better to move this check into
	   symbol reading.  */
	sym = NULL;
      else
	sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, LABEL_DOMAIN, 0, NULL);
    }

  if (sym)
    {
      proc_desc = (struct mdebug_extra_func_info *) SYMBOL_VALUE (sym);

      /* If we never found a PDR for this function in symbol reading,
	 then examine prologues to find the information.  */
      if (proc_desc->pdr.framereg == -1)
	proc_desc = NULL;
    }

  return proc_desc;
}
Example #7
0
void nios2_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
                          int flags)
{
    Nios2CPU *cpu = NIOS2_CPU(cs);
    CPUNios2State *env = &cpu->env;
    int i;

    if (!env || !f) {
        return;
    }

    cpu_fprintf(f, "IN: PC=%x %s\n",
                env->regs[R_PC], lookup_symbol(env->regs[R_PC]));

    for (i = 0; i < NUM_CORE_REGS; i++) {
        cpu_fprintf(f, "%9s=%8.8x ", regnames[i], env->regs[i]);
        if ((i + 1) % 4 == 0) {
            cpu_fprintf(f, "\n");
        }
    }
    cpu_fprintf(f, " mmu write: VPN=%05X PID %02X TLBACC %08X\n",
                env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK,
                (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4,
                env->mmu.tlbacc_wr);
    cpu_fprintf(f, "\n\n");
}
Example #8
0
File: eval.c Project: ingramj/bs
static object *eval_definition(object *exp, object *env)
{
    define_variable(definition_variable(exp),
            bs_eval(definition_value(exp), env),
            env);
    return lookup_symbol("ok");
}
Example #9
0
int
inside_main_func (CORE_ADDR pc)
{
  if (pc == 0)
    return 1;
  if (symfile_objfile == 0)
    return 0;

  /* If the addr range is not set up at symbol reading time, set it up now.
     This is for FRAME_CHAIN_VALID_ALTERNATE. I do this for coff, because
     it is unable to set it up and symbol reading time. */

  if (symfile_objfile->ei.main_func_lowpc == INVALID_ENTRY_LOWPC &&
      symfile_objfile->ei.main_func_highpc == INVALID_ENTRY_HIGHPC)
    {
      struct symbol *mainsym;

      mainsym = lookup_symbol (main_name (), NULL, VAR_NAMESPACE, NULL, NULL);
      if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
	{
	  symfile_objfile->ei.main_func_lowpc =
	    BLOCK_START (SYMBOL_BLOCK_VALUE (mainsym));
	  symfile_objfile->ei.main_func_highpc =
	    BLOCK_END (SYMBOL_BLOCK_VALUE (mainsym));
	}
    }
  return (symfile_objfile->ei.main_func_lowpc <= pc &&
	  symfile_objfile->ei.main_func_highpc > pc);
}
Example #10
0
File: eval.c Project: ingramj/bs
/**** Conversion ****/
static inline object *make_if(object *predicate, object *consequent,
        object *alternative)
{
    return cons(lookup_symbol("if"),
            cons(predicate,
                cons(consequent,
                    cons(alternative, get_empty_list()))));
}
Example #11
0
struct type *
lang_bool_type (void)
{
    struct symbol *sym;
    struct type *type;
    switch (current_language->la_language)
    {
    case language_fortran:
        sym = lookup_symbol ("logical", NULL, VAR_DOMAIN, NULL, NULL);
        if (sym)
        {
            type = SYMBOL_TYPE (sym);
            if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
                return type;
        }
        return builtin_type_f_logical_s2;
    case language_cplus:
    case language_pascal:
        if (current_language->la_language==language_cplus)
        {
            sym = lookup_symbol ("bool", NULL, VAR_DOMAIN, NULL, NULL);
        }
        else
        {
            sym = lookup_symbol ("boolean", NULL, VAR_DOMAIN, NULL, NULL);
        }
        if (sym)
        {
            type = SYMBOL_TYPE (sym);
            if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
                return type;
        }
        return builtin_type_bool;
    case language_java:
        sym = lookup_symbol ("boolean", NULL, VAR_DOMAIN, NULL, NULL);
        if (sym)
        {
            type = SYMBOL_TYPE (sym);
            if (type && TYPE_CODE (type) == TYPE_CODE_BOOL)
                return type;
        }
        return java_boolean_type;
    default:
        return builtin_type_int;
    }
}
Example #12
0
struct type *
get_java_object_type (void)
{
  struct symbol *sym;

  sym = lookup_symbol ("java.lang.Object", NULL, STRUCT_DOMAIN, NULL);
  if (sym == NULL)
    error (_("cannot find java.lang.Object"));
  return SYMBOL_TYPE (sym);
}
void
gcc_convert_symbol (void *datum,
		    struct gcc_c_context *gcc_context,
		    enum gcc_c_oracle_request request,
		    const char *identifier)
{
  struct compile_c_instance *context = datum;
  domain_enum domain;
  int found = 0;

  switch (request)
    {
    case GCC_C_ORACLE_SYMBOL:
      domain = VAR_DOMAIN;
      break;
    case GCC_C_ORACLE_TAG:
      domain = STRUCT_DOMAIN;
      break;
    case GCC_C_ORACLE_LABEL:
      domain = LABEL_DOMAIN;
      break;
    default:
      gdb_assert_not_reached ("Unrecognized oracle request.");
    }

  /* We can't allow exceptions to escape out of this callback.  Safest
     is to simply emit a gcc error.  */
  TRY
    {
      struct symbol *sym;

      sym = lookup_symbol (identifier, context->base.block, domain, NULL);
      if (sym != NULL)
	{
	  convert_symbol_sym (context, identifier, sym, domain);
	  found = 1;
	}
      else if (domain == VAR_DOMAIN)
	{
	  struct bound_minimal_symbol bmsym;

	  bmsym = lookup_minimal_symbol (identifier, NULL, NULL);
	  if (bmsym.minsym != NULL)
	    {
	      convert_symbol_bmsym (context, bmsym);
	      found = 1;
	    }
	}
    }

  CATCH (e, RETURN_MASK_ALL)
    {
      C_CTX (context)->c_ops->error (C_CTX (context), e.message);
    }
Example #14
0
struct type *
java_lookup_class (char *name)
{
  struct symbol *sym;

  sym = lookup_symbol (name, expression_context_block, STRUCT_DOMAIN, NULL);
  if (sym != NULL)
    return SYMBOL_TYPE (sym);
  /* FIXME - should search inferior's symbol table.  */
  return NULL;
}
Example #15
0
static unsigned long resolve_symbol(Elf32_Shdr *sechdrs, 
				    const char *name)
{
	const struct kernel_symbol *ks;

	debug("%s: %s\n", __FUNCTION__, name);
	ks = lookup_symbol(name, __usymtab_start,
		__usymtab_end);

	if (ks)
		return ks->value;
	return 0;
}
static CORE_ADDR
moxie_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
  CORE_ADDR func_addr = 0, func_end = 0;
  char *func_name;

  /* See if we can determine the end of the prologue via the symbol table.
     If so, then return either PC, or the PC after the prologue, whichever
     is greater.  */
  if (find_pc_partial_function (pc, &func_name, &func_addr, &func_end))
    {
      CORE_ADDR post_prologue_pc
	= skip_prologue_using_sal (gdbarch, func_addr);
      if (post_prologue_pc != 0)
	return max (pc, post_prologue_pc);
      else
	{
	  /* Can't determine prologue from the symbol table, need to examine
	     instructions.  */
	  struct symtab_and_line sal;
	  struct symbol *sym;
	  struct moxie_frame_cache cache;
	  CORE_ADDR plg_end;
	  
	  memset (&cache, 0, sizeof cache);
	  
	  plg_end = moxie_analyze_prologue (func_addr, 
					    func_end, &cache, NULL);
	  /* Found a function.  */
	  sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL);
	  /* Don't use line number debug info for assembly source
	     files. */
	  if (sym && SYMBOL_LANGUAGE (sym) != language_asm)
	    {
	      sal = find_pc_line (func_addr, 0);
	      if (sal.end && sal.end < func_end)
		{
		  /* Found a line number, use it as end of
		     prologue.  */
		  return sal.end;
		}
	    }
	  /* No useable line symbol.  Use result of prologue parsing
	     method.  */
	  return plg_end;
	}
    }

  /* No function symbol -- just return the PC.  */
  return (CORE_ADDR) pc;
}
Example #17
0
/******************************************************************************
 *
 *	L I S T A P R O C (char *name)
 *
 * Routine used by the ICL command "LIST" and lists the procedure with the
 * name "name".
 *
 * Uses lookup_symbol() to find the proc entry in the global symbol table and,
 * if found, use listproc() to list it
 *
 ******************************************************************************
 */
value
listaproc(char *name)
{
    node *proc;

    if ((proc = lookup_symbol(name, SYM_PROC)) != NODENIL) {
	outfpstring("\n");
	listproc(name, proc, 0);
	outfpstring("\n");
	return trueval;
    } else
	return exception(
		"PROCERR  LIST: Unrecognised procedure or command name");
}
static void
convert_symbol_sym (struct compile_c_instance *context, const char *identifier,
		    struct symbol *sym, domain_enum domain)
{
  const struct block *static_block, *found_block;
  int is_local_symbol;

  found_block = block_found;

  /* If we found a symbol and it is not in the  static or global
     scope, then we should first convert any static or global scope
     symbol of the same name.  This lets this unusual case work:

     int x; // Global.
     int func(void)
     {
     int x;
     // At this spot, evaluate "extern int x; x"
     }
  */

  static_block = block_static_block (found_block);
  /* STATIC_BLOCK is NULL if FOUND_BLOCK is the global block.  */
  is_local_symbol = (found_block != static_block && static_block != NULL);
  if (is_local_symbol)
    {
      struct symbol *global_sym;

      global_sym = lookup_symbol (identifier, NULL, domain, NULL);
      /* If the outer symbol is in the static block, we ignore it, as
	 it cannot be referenced.  */
      if (global_sym != NULL
	  && block_found != block_static_block (block_found))
	{
	  if (compile_debug)
	    fprintf_unfiltered (gdb_stdlog,
				"gcc_convert_symbol \"%s\": global symbol\n",
				identifier);
	  convert_one_symbol (context, global_sym, 1, 0);
	}
    }

  if (compile_debug)
    fprintf_unfiltered (gdb_stdlog,
			"gcc_convert_symbol \"%s\": local symbol\n",
			identifier);
  convert_one_symbol (context, sym, 0, is_local_symbol);
}
Example #19
0
SYMTAB *add_symbol(char *name, enum sym_t type, void *data)
{
  SYMTAB *t;
  size_t len;

  t = (SYMTAB *)lookup_symbol(name);
  if (t==NULL)
    {
      if (lastsym >= MAX_SYMBOLS)
	{
	  return NULL;
	}
      t = (SYMTAB *)&(symtab[lastsym]);
      lastsym++;
    }
  else
    {
      return t;
    }

  strncpy(t->name,name, MAX_NAME);
  t->name[MAX_NAME] = '\0';
  t->type = type;
  switch (type)
    {
    case SYM_CONSTANTS:
      len = sizeof(t->s.c);
      break;
    case SYM_MATRIX:
      len = sizeof(t->s.m);
      break;
    case SYM_LIGHT:
      len = sizeof(t->s.l);
      break;
    case SYM_KNOBLIST:
      len = sizeof(t->s.k);
      break;
    case SYM_VALUE:
      t->s.value = (double)(int)data;
    case SYM_FILE:
    case SYM_STRING:
      len = 0;
      break;
    }
  if (data != NULL && len)
    memcpy(&t->s, data, len);
  return (SYMTAB *)&(symtab[lastsym-1]);
}
Example #20
0
/*****************************************************************************
 * A S S I G N _ H E L P E R 1 ( node *var, value val )
 *
 * Similare to assign_helper but used by reload_vars_hds.
 * Therefore if the variable is a parameter given as a value, we assume it is
 * not required to be reset.
 ******************************************************************************
 */
value
assign_helper1(node *var, value val)
{
    node *param;

    if ((param = lookup_symbol(string_part(var->val), SYM_PARAMETER))
	    != NODENIL)
	if (param->interpret == parameter_interpret)
	    return (put_value(symboltable_part(param->val),
		    string_part(param->sub[0]->val), SYM_VARIABLE, val));
	else
	    return trueval;
    else
	return (put_value(activesymtab(SYM_VARIABLE), string_part(var->val),
		SYM_VARIABLE, val));
}
Example #21
0
void *HELPER(lookup_tb_ptr)(CPUArchState *env)
{
    CPUState *cpu = ENV_GET_CPU(env);
    TranslationBlock *tb;
    target_ulong cs_base, pc;
    uint32_t flags;

    tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, curr_cflags());
    if (tb == NULL) {
        return tcg_ctx->code_gen_epilogue;
    }
    qemu_log_mask_and_addr(CPU_LOG_EXEC, pc,
                           "Chain %p [%d: " TARGET_FMT_lx "] %s\n",
                           tb->tc.ptr, cpu->cpu_index, pc,
                           lookup_symbol(pc));
    return tb->tc.ptr;
}
Example #22
0
struct type *
java_lookup_class (char *name)
{
  struct symbol *sym;
  sym = lookup_symbol (name, expression_context_block, STRUCT_DOMAIN, NULL);
  if (sym != NULL)
    return SYMBOL_TYPE (sym);
#if 0
  CORE_ADDR addr;
  if (called from parser)
    {
      call lookup_class (or similar) in inferior;
      if not
      found:
	return NULL;
      addr = found in inferior;
    }
Example #23
0
static void
expand_token (struct obstack *obs, token_type t, token_data *td, int line)
{
  symbol *sym;

  switch (t)
    { /* TOKSW */
    case TOKEN_EOF:
    case TOKEN_MACDEF:
      break;

    case TOKEN_OPEN:
    case TOKEN_COMMA:
    case TOKEN_CLOSE:
    case TOKEN_SIMPLE:
    case TOKEN_STRING:
      shipout_text (obs, TOKEN_DATA_TEXT (td), strlen (TOKEN_DATA_TEXT (td)),
                    line);
      break;

    case TOKEN_WORD:
      sym = lookup_symbol (TOKEN_DATA_TEXT (td), SYMBOL_LOOKUP);
      if (sym == NULL || SYMBOL_TYPE (sym) == TOKEN_VOID
          || (SYMBOL_TYPE (sym) == TOKEN_FUNC
              && SYMBOL_BLIND_NO_ARGS (sym)
              && peek_token () != TOKEN_OPEN))
        {
#ifdef ENABLE_CHANGEWORD
          shipout_text (obs, TOKEN_DATA_ORIG_TEXT (td),
                        strlen (TOKEN_DATA_ORIG_TEXT (td)), line);
#else
          shipout_text (obs, TOKEN_DATA_TEXT (td),
                        strlen (TOKEN_DATA_TEXT (td)), line);
#endif
        }
      else
        expand_macro (sym);
      break;

    default:
      M4ERROR ((warning_status, 0,
                "INTERNAL ERROR: bad token type in expand_token ()"));
      abort ();
    }
}
Example #24
0
static struct mdebug_extra_func_info *
find_proc_desc (CORE_ADDR pc)
{
  const struct block *b = block_for_pc (pc);
  struct mdebug_extra_func_info *proc_desc = NULL;
  struct symbol *sym = NULL;
  const char *sh_name = NULL;

  if (b)
    {
      CORE_ADDR startaddr;
      find_pc_partial_function (pc, &sh_name, &startaddr, NULL);

      if (startaddr > BLOCK_START (b))
	/* This is the "pathological" case referred to in a comment in
	   print_frame_info.  It might be better to move this check into
	   symbol reading.  */
	sym = NULL;
      else
	sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, LABEL_DOMAIN,
			     0).symbol;
    }

  if (sym)
    {
      proc_desc = (struct mdebug_extra_func_info *) SYMBOL_VALUE_BYTES (sym);

      /* Correct incorrect setjmp procedure descriptor from the library
         to make backtrace through setjmp work.  */
      if (proc_desc->pdr.pcreg == 0
	  && strcmp (sh_name, "setjmp") == 0)
	{
	  proc_desc->pdr.pcreg = ALPHA_RA_REGNUM;
	  proc_desc->pdr.regmask = 0x80000000;
	  proc_desc->pdr.regoffset = -4;
	}

      /* If we never found a PDR for this function in symbol reading,
	 then examine prologues to find the information.  */
      if (proc_desc->pdr.framereg == -1)
	proc_desc = NULL;
    }

  return proc_desc;
}
Example #25
0
File: interp.c Project: mdoug/FIAL
static inline int lookup_symbol_value (value *val, symbol sym, exec_env *env)
{
	value v1;
	block *iter = env->block_stack;
	for(; iter != NULL; iter = iter->next) {
		int failure;

		if(!iter->values)
			continue;
		failure = lookup_symbol(&v1, iter->values, sym);
		if(!failure ) {
			*val = v1;
			return 0;
		}
	}
	memset(val, 0, sizeof(*val));
	return 1;
}
Example #26
0
/******************************************************************************
 *
 *	A S S I G N _ H E L P E R (node *var, value val)
 *
 * Assign the value 'val' to the variable 'var'.
 * 'Var' is a name_interpret() node whose string_part member contains the
 * identity of the variable.
 *
 * If the variable is a parameter then, on calling the current procedure we
 * could have passed
 * EITHER
 * an expression, which is evaluated and the formal's value member points to
 * that value
 * OR
 * a variable.  In this latter  case the formal's node value will point to a
 * node whose type is TYPE_SYMTAB, whose interpret member is
 * parameter_interpret(), whose symboltable_part() member points to the symbol
 * table of the corresponding actual variable and whose sub[0] member points
 * to a node that is the corresponding actual variable (ie a name_interpret()
 * whose string_part() member points to the identifier).
 *
 * If the variable is not a parameter then we can use
 * put_value(activesymtab(SYM_VARIABLE), var's name, SYM_VARIABLE,val)....) to
 * achieve the storage otherwise we can use put_value(symboltable from formal
 * entry, actual parameter's name,SYM_VARIABLE,val).
 ******************************************************************************
 */
value
assign_helper(node *var, value val)
{
    node *param;

    if ((param = lookup_symbol(string_part(var->val), SYM_PARAMETER))
	    != NODENIL) {
	if (param->interpret == parameter_interpret)
	    return (put_value(symboltable_part(param->val),
		    string_part(param->sub[0]->val), SYM_VARIABLE, val));
	else if( param->interpret == undefined_interpret)
	    put_value(symbols, string_part(var->val), SYM_PARAMETER, val);
	else
	    return exception(
		"ASSNOTVAR Assignment to parameter not passed as a variable");
    } else
	return (put_value(activesymtab(SYM_VARIABLE), string_part(var->val),
		SYM_VARIABLE, val));
}
Example #27
0
File: eval.c Project: ingramj/bs
static object *expand_clauses(object *clauses)
{
    if (is_empty_list(clauses)) {
        return get_boolean(0);
    } else {
        object *first = car(clauses);
        object *rest = cdr(clauses);
        if (cond_predicate(first) == lookup_symbol("else")) {
            if (is_empty_list(rest)) {
                return sequence_to_exp(cond_actions(first));
            } else {
                error("else clause must be last in cond expression");
            }
        } else {
            return make_if(cond_predicate(first),
                    sequence_to_exp(cond_actions(first)),
                    expand_clauses(rest));
        }
    }
}
Example #28
0
obj vmake_os_error( const char *fn, int num_args, va_list va )
{
  int i, e = errno;
  obj argv, props;

  argv = alloc( SLOT(num_args), vector_class );

  for (i=0; i<num_args; i++)
    gvec_write_init( argv, SLOT(i), va_arg(va,obj) );

  props = cons( cons( lookup_symbol( "stack" ), 
                      make_exception_stack() ), 
                NIL_OBJ );

  return make4( os_error_class, 
                props,
                int2fx(e), 
                make_string( fn ),
                argv );
}
Example #29
0
static void
nlm_symfile_read (struct objfile *objfile, int mainline)
{
  bfd *abfd = objfile->obfd;
  struct cleanup *back_to;
  CORE_ADDR offset;
  struct symbol *mainsym;

  init_minimal_symbol_collection ();
  back_to = make_cleanup_discard_minimal_symbols ();

  /* FIXME, should take a section_offsets param, not just an offset.  */

  offset = ANOFFSET (objfile->section_offsets, 0);

  /* Process the NLM export records, which become the bfd's canonical symbol
     table. */

  nlm_symtab_read (abfd, offset, objfile);

  /* Install any minimal symbols that have been collected as the current
     minimal symbols for this objfile. */

  install_minimal_symbols (objfile);
  do_cleanups (back_to);

  stabsect_build_psymtabs (objfile, mainline, ".stab",
			   ".stabstr", ".text");

  mainsym = lookup_symbol (main_name (), NULL, VAR_DOMAIN, NULL, NULL);

  if (mainsym
      && SYMBOL_CLASS (mainsym) == LOC_BLOCK)
    {
      objfile->ei.main_func_lowpc = BLOCK_START (SYMBOL_BLOCK_VALUE (mainsym));
      objfile->ei.main_func_highpc = BLOCK_END (SYMBOL_BLOCK_VALUE (mainsym));
    }

  /* FIXME:  We could locate and read the optional native debugging format
     here and add the symbols to the minimal symbol table. */
}
Example #30
0
SYMTAB *add_symbol(char *name, int type, void *data)
{
  SYMTAB *t;

  t = (SYMTAB *)lookup_symbol(name);
  if (t==NULL)
    {
      if (lastsym >= MAX_SYMBOLS)
	{
	  return NULL;
	}
      t = (SYMTAB *)&(symtab[lastsym]);
      lastsym++;
    }
  else
    {
      return t;
    }

  t->name = (char *)malloc(strlen(name)+1);
  strcpy(t->name,name);
  t->type = type;
  switch (type)
    {
    case SYM_CONSTANTS:
      t->s.c = (struct constants *)data;
      break;
    case SYM_MATRIX:
      t->s.m = (struct matrix *)data;
      break;
    case SYM_LIGHT:
      t->s.l = (struct light *)data;
      break;
    case SYM_VALUE:
      t->s.value = (double)(int)data;
      break;
    case SYM_FILE:
      break;
    }
  return (SYMTAB *)&(symtab[lastsym-1]);
}