示例#1
0
文件: symbols.cpp 项目: arn-e/circa
void set_symbol_from_string(caValue* val, caValue* str)
{
    // Find this name as an existing builtin symbol.
    int foundBuiltin = builtin_symbol_from_string(as_cstring(str));
    if (foundBuiltin != -1) {
        set_symbol(val, foundBuiltin);
        return;
    }

    // Find this name as an existing runtime symbol.
    caValue* foundRuntime = hashtable_get(g_runtimeSymbolMap, str);
    if (foundRuntime != NULL) {
        copy(foundRuntime, val);
        return;
    }

    // Create a new runtime symbol.
    caValue* newRuntime = hashtable_insert(g_runtimeSymbolMap, str);
    int index = g_nextRuntimeSymbol++;
    set_symbol(newRuntime, index);
    set_symbol(val, index);

    list_resize(g_runtimeSymbolTable, index+1);
    set_value(list_get(g_runtimeSymbolTable, index), str);
}
示例#2
0
 void Marshaller::marshal(Object* obj) {
   if(obj == Qnil) {
     stream << "n" << endl;
   } else if(obj == Qtrue) {
     stream << "t" << endl;
   } else if(obj == Qfalse) {
     stream << "f" << endl;
   } else if(obj->fixnum_p()) {
     set_int(obj);
   } else if(obj->symbol_p()) {
     set_symbol((Symbol*)obj);
   } else if(kind_of<Bignum>(obj)) {
     set_bignum(as<Bignum>(obj));
   } else if(kind_of<String>(obj)) {
     set_string(as<String>(obj));
   } else if(kind_of<SendSite>(obj)) {
     set_sendsite(as<SendSite>(obj));
   } else if(kind_of<Array>(obj)) {
     set_array(as<Array>(obj));
   } else if(kind_of<Tuple>(obj)) {
     set_tuple(as<Tuple>(obj));
   } else if(kind_of<Float>(obj)) {
     set_float(as<Float>(obj));
   } else if(kind_of<InstructionSequence>(obj)) {
     set_iseq(as<InstructionSequence>(obj));
   } else if(kind_of<CompiledMethod>(obj)) {
     set_cmethod(as<CompiledMethod>(obj));
   } else {
     Exception::type_error(state, "unknown object");
   }
 }
示例#3
0
文件: arg.c 项目: bondians/quence
int resolve_label_ref(argument *arg) {
	if (Mode == mode_label_undef) {
		if (symbol_exists(labels, (char *) Index)) {
			char *msg;
			char *label;

			Mode = mode_constant;
			label = (char *) Index;
			Value = symbol_value(labels, label);
			Index = 0;

			msg = validate_argument(arg);

			if (msg) {
				eprintf("Resolving Label \"%s\": %s\n", label, msg);
				return 1;
			}

			return 0;
		} else {
			if (unresolved_labels) {
				set_symbol(
					unresolved_labels,
					(char *) Index,
					symbol_value(unresolved_labels, (char *) Index) + 1
				);
			}
			return 1;
		}
	}

	return 0;
}
示例#4
0
void change_event_make_append(Value* event, Block* target, Value* expression)
{
    change_event_set_blank(event, 1);
    set_symbol(change_event_type(event), s_ChangeAppend);
    set_block(change_event_target(event), target);
    set_value(change_event_field(event, 0), expression);
}
示例#5
0
void test_equality_with_symbol()
{
    Value val;
    set_symbol(&val, s_Append);
    test_assert(string_equals(&val, ":Append"));
    test_assert(!string_equals(&val, "Append"));
    test_assert(!string_equals(&val, "Appen"));
}
示例#6
0
FileWatch* add_file_watch_native_patch(World* world, const char* filename, const char* moduleName)
{
    circa::Value action;
    set_list(&action, 2);
    set_symbol(list_get(&action, 0), sym_NativePatch);
    set_string(list_get(&action, 1), moduleName);
    return add_file_watch_action(world, filename, &action);
}
示例#7
0
Value* block_get_property(Block* block, Symbol key)
{
    if (is_null(&block->properties))
        return NULL;

    Value keyVal;
    set_symbol(&keyVal, key);
    return hashtable_get(&block->properties, &keyVal);
}
示例#8
0
Value* block_insert_property(Block* block, Symbol key)
{
    if (is_null(&block->properties))
        set_hashtable(&block->properties);

    Value keyVal;
    set_symbol(&keyVal, key);
    return hashtable_insert(&block->properties, &keyVal);
}
示例#9
0
void block_remove_property(Block* block, Symbol key)
{
    if (is_null(&block->properties))
        return;

    Value keyVal;
    set_symbol(&keyVal, key);
    hashtable_remove(&block->properties, &keyVal);
}
示例#10
0
void call_library(char *lib_name)
/*
 *      generate a call to a library routine.
 */
{
				AMODE *ap;
				ap = set_symbol(lib_name,1);
        gen_code(op_call,0,ap,0);
}
示例#11
0
文件: symbol.c 项目: bondians/quence
symbol_table init_table(symbol_init symbols[]) {
	symbol_table table = new_table();
	int idx;

	for (idx = 0; symbols[idx].name; idx++) {
		set_symbol(table, symbols[idx].name, symbols[idx].value);
	}

	return table;
}
示例#12
0
Term* find_local_name(Block* block, const char* nameStr, Symbol lookupType)
{
    NameSearch nameSearch;
    nameSearch.block = block;
    set_string(&nameSearch.name, nameStr);
    set_symbol(&nameSearch.position, s_last);
    nameSearch.ordinal = -1;
    nameSearch.lookupType = lookupType;
    nameSearch.searchParent = false;
    return run_name_search(&nameSearch);
}
示例#13
0
Term* find_local_name(Block* block, Value* name, Symbol lookupType)
{
    NameSearch nameSearch;
    nameSearch.block = block;
    copy(name, &nameSearch.name);
    set_symbol(&nameSearch.position, s_last);
    nameSearch.ordinal = -1;
    nameSearch.lookupType = lookupType;
    nameSearch.searchParent = false;
    return run_name_search(&nameSearch);
}
示例#14
0
/* Create a new symbol object (gdb.Symbol) that encapsulates the struct
   symbol object from GDB.  */
PyObject *
symbol_to_symbol_object (struct symbol *sym)
{
    symbol_object *sym_obj;

    sym_obj = PyObject_New (symbol_object, &symbol_object_type);
    if (sym_obj)
        set_symbol (sym_obj, sym);

    return (PyObject *) sym_obj;
}
示例#15
0
void call_library(char *lib_name)
/*
 *      generate a call to a library routine.
 */
{
    AMODE *ap;
    ap = set_symbol(lib_name, 1);
	if (prm_lscrtdll)
	{
		ap->mode = am_direct;
	}
    gen_codes(op_call, 0, ap, 0);
}
示例#16
0
void rewrite_block(Block* block, caValue* contents, caValue* reply)
{
    clear_block(block);
    parser::compile(block, parser::statement_list, as_cstring(contents));

    if (has_static_errors(block)) {
        std::stringstream errors;
        print_static_errors_formatted(block);
        set_string(reply, errors.str());
    } else {
        set_symbol(reply, sym_Success);
    }
}
示例#17
0
static int varg_set_symbol(char *symbol, char *value)
{
        $DESCRIPTOR(symbol_desc, "");
        $DESCRIPTOR(value_desc, "");
        int status;

        symbol_desc.dsc$w_length = strlen(symbol);
        symbol_desc.dsc$a_pointer = symbol;
        value_desc.dsc$w_length = strlen(value);
        value_desc.dsc$a_pointer = value;
        status = lib$set_symbol(&symbol_desc, &value_desc);
        return status;
}
示例#18
0
文件: istmt.c 项目: jossk/OrangeC
IMODE *call_library(char *lib_name, int size)
/*
 *      generate a call to a library routine.
 */
{
    IMODE *result;
    result = set_symbol(lib_name, 1);
    gen_icode(i_gosub, 0, result, 0);
    gen_icode(i_parmadj, 0, make_parmadj(size), make_parmadj(size));
    result = tempreg(ISZ_UINT, 0);
    result->retval = TRUE;
    return result;
}
示例#19
0
文件: debug.cpp 项目: arn-e/circa
void perf_stats_to_list(caValue* list)
{
    set_list(list, c_numPerfStats);
    for (int i = c_firstStatIndex; i < sym_LastStatIndex-1; i++) {
        Symbol name = i;
        int64 value = PERF_STATS[i - c_firstStatIndex];
        caValue* element = list_get(list, i - c_firstStatIndex);
        set_list(element, 2);
        set_symbol(list_get(element, 0), name);
        char buf[100];
        sprintf(buf, "%llu", value);
        set_string(list_get(element, 1), buf);
    }
}
示例#20
0
void scppinit(void)
{
	if (!strcmp(currentfunc->name,"_main")) {
		AMODE *ap1,*ap2,*ap3,*ap4;
		int lbl = nextlabel++;
		initstack();
		ap1 = temp_data();
		ap4 = xalloc(sizeof(AMODE));
		ap4->preg = ap1->preg;
		ap4->mode = am_indisp;
		ap4->offset = makenode(en_icon,0,0);
		ap2 = set_symbol("cppistart",0);
		ap3 = set_symbol("cppiend",0);
		gen_code(op_mov,4,ap1,ap2);
		gen_label(lbl);
		gen_code(op_push,4,ap1,0);
		gen_code(op_call,4,ap4,0);
		gen_code(op_pop,4,ap1,0);
		gen_code(op_add,4,ap1,make_immed(4));
		gen_code(op_cmp,4,ap1,ap3);
		gen_code(op_jb,0,make_label(lbl),0);
		freeop(ap1);
	}
}
示例#21
0
bool StockTransactions::purchase(Stocks symbol, MMTransactions& mm, int shares)
{
	double cost = symbol.get_currentPrice() * shares;
	if (mm.withdraw(cost))
	{
		set_price(cost);
		set_shares(shares);
		set_symbol(symbol.get_symbol());
		m_transactionType = transactionType::PURCHASE;
		return true;
	}
	else
	{
		return false;
	}
}
示例#22
0
文件: grace.cpp 项目: sunpho84/sunpho
grace grace::set(int n,...)
{
  char *what;

  va_list vl;
  va_start(vl,n);
  for(int i=0;i<n;i++)
    {
      what=va_arg(vl,char*);
      set_color(what);
      set_line_type(what);
      set_symbol(what);
    }
  va_end(vl);
  
  return *this;
}
示例#23
0
文件: interp.c 项目: mdoug/FIAL
static inline int set_env_symbol (exec_env *env, symbol sym, value *val)
{
	value tmp;
	block *iter = env->block_stack;

	memset(&tmp, 0, sizeof(tmp));

	for(; iter != NULL; iter = iter->next) {
		int result; 

		if(!iter->values)
			continue;
		result = lookup_symbol(&tmp, iter->values, sym);
		if(result == 0) {
			set_symbol(iter->values, sym, val, env->interp);
			return 0;
		}
	}

	return -1;
}
示例#24
0
Term* find_name_at(Value* location, Value* name, Symbol lookupType)
{
    NameSearch nameSearch;

    copy(name, &nameSearch.name);

    if (is_block(location)) {
        Block* block = as_block(location);
        nameSearch.block = block;
        set_symbol(&nameSearch.position, s_last);
    } else if (is_term_ref(location)) {
        Term* term = as_term_ref(location);
        nameSearch.block = term->owningBlock;
        set_int(&nameSearch.position, term->index);
    } else {
        internal_error("find_name_at");
    }
    nameSearch.ordinal = -1;
    nameSearch.lookupType = lookupType;
    nameSearch.searchParent = true;
    return run_name_search(&nameSearch);
}
示例#25
0
bool is_assignment(object *exp) {
    return is_tagged_list(exp, set_symbol());
}
示例#26
0
void file_source_create_from_tarball(Value* file_source, Value* blob)
{
    set_list(file_source, 2);
    set_symbol(list_get(file_source, 0), s_Tarball);
    set_value(list_get(file_source, 1), blob);
}
示例#27
0
void file_source_create_using_filesystem(Value* file_source, const char* rootDir)
{
    set_list(file_source, 2);
    set_symbol(list_get(file_source, 0), s_Filesystem);
    set_string(list_get(file_source, 1), rootDir);
}
示例#28
0
void block_set_symbol_prop(Block* block, Symbol name, Symbol value)
{
    set_symbol(block_insert_property(block, name), value);
}
示例#29
0
void *panel_command (void *cmdline)
#endif
{
#define MAX_CMD_LEN (32768)
    char  cmd[ MAX_CMD_LEN ];           /* Copy of panel command     */
    char *pCmdLine;
    unsigned i;
    int hercecho = 1;                   /* Default echo to console   */

    pCmdLine = cmdline;
    ASSERT( pCmdLine );
    /* Every command will be stored in history list,
       EXCEPT: null commands, script commands, scp input,
       and "silent" commands (prefixed with '-') */
    if (*pCmdLine != 0 && !FindSCRCTL(thread_id()))
    {
        if (!(*pCmdLine == '-'))    /* (normal command?) */
        {
#if defined( _FEATURE_SYSTEM_CONSOLE )
            if (*pCmdLine == '.' || *pCmdLine == '!')
            {
                if (sysblk.scpecho)
                    history_add( cmdline );
            }
            else
#endif /* defined( _FEATURE_SYSTEM_CONSOLE ) */
                history_add( cmdline );
        }
    }

    /* Copy panel command to work area, skipping leading blanks */

    /* If the command starts with a -, then strip it and indicate
     * that we do NOT want the command echoed to the console. */
    hercecho = 1; /* (default) */
    while (*pCmdLine && isspace( *pCmdLine ))
        pCmdLine++;
    i = 0;
    while (*pCmdLine && i < (MAX_CMD_LEN-1))
    {
        if (i == 0 && (0            /* (1st character?) */
                       || *pCmdLine == '-'     /* (silent command) */
                       || *pCmdLine == '#'     /* (silent comment) */
                      ))
        {
            hercecho = 0;           /* (silence please) */
            if (*pCmdLine == '-')   /* (silent command) */
            {
                pCmdLine++;         /* (skip past the '-' ... */
                /* ... and remove blanks) */
                while (*pCmdLine && isspace(*pCmdLine))
                    pCmdLine++;     /* (get past blank) */
            }
        }
        cmd[i] = *pCmdLine;
        i++;
        pCmdLine++;
    }
    cmd[i] = 0;

    /* (just pressing the enter key shouldn't be echoed) */
    if (0 == cmd[0])
        hercecho = 0;               /* (silence please) */

#if defined( OPTION_CMDTGT )
    /* Check for herc, scp or pscp command... */

    /* Please note: 'cmdtgt' is a hercules command, but will be
       passed to the scp if scp target is set! This means that
       once the scp target has been set, to change the target
       back to herc, you must use: "herc cmdtgt herc". This is
       because the 'herc' command is ALWAYS a Hercules command
       (regardless of command target mode), whereas the 'cmdtgt'
       is passed to the scp whenever scp target mode is set.
       Thus you must explicitly request 'cmdtgt' be processed
       by Hercules and not the scp, by using the 'herc' prefix.
    */
    if (0
            || !strncasecmp( cmd, "herc ", 5 )   /* Hercules     */
            || !strncasecmp( cmd, "scp ",  4 )   /* Guest O/S    */
            || !strncasecmp( cmd, "pscp ", 5 )   /* Priority SCP */
       )
    {
        if (hercecho)
            EchoHercCmdLine( cmd );
        HercCmdLine( cmd );
        return NULL;
    }

    /* Send the command to the currently active command target */
    switch (sysblk.cmdtgt)
    {
    case CMDTGT_HERC:           /* Hercules */
    {
        /* (stay compatible) */
#endif /* defined( OPTION_CMDTGT ) */

#if defined( _FEATURE_SYSTEM_CONSOLE )
        if(cmd[0] == '.' || cmd[0] == '!')
        {
            int priomsg = cmd[0] == '!'  ? TRUE : FALSE;
            int scpecho = sysblk.scpecho ? TRUE : FALSE;
            if (!cmd[1]) {      /* (empty command given?) */
                cmd[1] = ' ';   /* (must send something!) */
                cmd[2] = 0;
            }
            scp_command( cmd+1, priomsg, scpecho );
        }
        else
#endif /* defined( _FEATURE_SYSTEM_CONSOLE ) */
        {
            if (hercecho && *cmd)
                EchoHercCmdLine( cmd );
#if defined( OPTION_CONFIG_SYMBOLS )
            /* Perform variable substitution */
            /* First, set some 'dynamic' symbols
               to their own values */
            set_symbol( "CUU",  "$(CUU)"  );
            set_symbol( "CCUU", "$(CCUU)" );
            set_symbol( "DEVN", "$(DEVN)" );
            {
                char *cl = resolve_symbol_string( cmd );
                HercCmdLine( cl );
                free( cl );
            }
#else /* !defined( OPTION_CONFIG_SYMBOLS ) */
            HercCmdLine( cmd );
#endif /* defined( OPTION_CONFIG_SYMBOLS ) */
        }
#if defined( OPTION_CMDTGT )
        break;
    }
    case CMDTGT_SCP:        /* Guest O/S */
    {
        int priomsg = FALSE;    /* normal scp command     */
        int scpecho = TRUE;     /* (always echo to hmc)   */
        if (!cmd[0]) {      /* (empty command given?) */
            cmd[0] = ' ';   /* (MUST send something!) */
            cmd[1] = 0;
        }
        scp_command( cmd, priomsg, scpecho );
        break;
    }
    case CMDTGT_PSCP:       /* Priority SCP */
    {
        int priomsg = TRUE;     /* Priority scp command   */
        int scpecho = TRUE;     /* (always echo to hmc)   */
        if (!cmd[0]) {      /* (empty command given?) */
            cmd[0] = ' ';   /* (MUST send something!) */
            cmd[1] = 0;
        }
        scp_command( cmd, priomsg, scpecho );
        break;
    }
    }
#endif /* defined( OPTION_CMDTGT ) */

    return NULL;
}
示例#30
0
文件: interp.c 项目: mdoug/FIAL
static inline int declare_variable (node *stmt, exec_env *env)
{
	value tmp, v1;
	int failure =  0;
	node  *iter = NULL;

	assert(env->block_stack);
	memset(&tmp, 0, sizeof(tmp));

	if(!env->block_stack->values) {
		assert(env->block_stack->values == NULL);
		env->block_stack->values = create_symbol_map();
		if(!env->block_stack->values) {
			env->error.code = ERROR_BAD_ALLOC;
			env->error.line = stmt->loc.line;
			env->error.col  = stmt->loc.col;
			env->error.file = env->lib->label;
			env->error.static_msg = "Could not create needed value table";
			return -1;
		}
	}
	assert(env->block_stack->values);

/*
 * I think I am taking this out, I am ok with allowing redeclaration
 * of variables within the same block.  I'm not worried about the
 * compiler, mangling variable names is not a big problem. But, under
 * the current implementation,  Allowing it would lead to bugs.
 *
 * I forgot what bugs would be caused by this, unfortunately, I didn't
 * write it down as far as I can see.  Anyway, I am ok leaving this
 * until I redesign the main value stack data structure.
 */

	for(iter = stmt->left; iter!= NULL; iter=iter->right) {
		failure = lookup_symbol(&v1, env->block_stack->values,
					iter->sym);
		if(!failure) {
			env->error.code = ERROR_VARIABLE_REDECLARED;
			env->error.line = stmt->loc.line;
			env->error.col  = stmt->loc.col;
			env->error.file = env->lib->label;
			env->error.static_msg = "Attempt to redeclare "
    				"variable within the same "
				"block.";
			return -1;
		} else {
			value val = tmp;
			if(iter->left)
				if(handle_assign_right(&val, iter->left, 
				                       env) < 0) 
					return -1;
			if ( set_symbol(env->block_stack->values, iter->sym,
					&val, env->interp) < 0) {
				env->error.code = ERROR_BAD_ALLOC;
				env->error.static_msg =
					"couldn't allocate space for new value";
				FIAL_set_error(env);
				return -1;
			}
		}
	}
	return 0;
}