本文整理汇总了C++中symbol_tablet::move方法的典型用法代码示例。如果您正苦于以下问题:C++ symbol_tablet::move方法的具体用法?C++ symbol_tablet::move怎么用?C++ symbol_tablet::move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类symbol_tablet
的用法示例。
在下文中一共展示了symbol_tablet::move方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add_failed_symbol
void add_failed_symbol(symbolt &symbol, symbol_tablet &symbol_table)
{
if(!symbol.is_lvalue) return;
if(symbol.type.get(ID_C_failed_symbol)!="")
return;
if(symbol.type.id()==ID_pointer)
{
symbolt new_symbol;
new_symbol.is_lvalue=true;
new_symbol.module=symbol.module;
new_symbol.mode=symbol.mode;
new_symbol.base_name=failed_symbol_id(symbol.base_name);
new_symbol.name=failed_symbol_id(symbol.name);
new_symbol.type=symbol.type.subtype();
new_symbol.value.make_nil();
new_symbol.type.set(ID_C_is_failed_symbol, true);
symbol.type.set(ID_C_failed_symbol, new_symbol.name);
if(new_symbol.type.id()==ID_pointer)
add_failed_symbol(new_symbol, symbol_table); // recursive call
symbol_table.move(new_symbol);
}
}
示例2: function_to_call
code_function_callt function_to_call(
symbol_tablet &symbol_table,
const irep_idt &id,
const irep_idt &argument)
{
// already there?
symbol_tablet::symbolst::const_iterator s_it=
symbol_table.symbols.find(id);
if(s_it==symbol_table.symbols.end())
{
// not there
pointer_typet p(char_type());
p.subtype().set(ID_C_constant, true);
code_typet function_type;
function_type.return_type()=empty_typet();
function_type.parameters().push_back(
code_typet::parametert(p));
symbolt new_symbol;
new_symbol.name=id;
new_symbol.base_name=id;
new_symbol.type=function_type;
symbol_table.move(new_symbol);
s_it=symbol_table.symbols.find(id);
assert(s_it!=symbol_table.symbols.end());
}
// signature is expected to be
// (type *) -> ...
if(s_it->second.type.id()!=ID_code ||
to_code_type(s_it->second.type).parameters().size()!=1 ||
to_code_type(s_it->second.type).parameters()[0].type().id()!=ID_pointer)
{
std::string error="function `"+id2string(id)+"' has wrong signature";
throw error;
}
string_constantt function_id_string(argument);
code_function_callt call;
call.lhs().make_nil();
call.function()=
symbol_exprt(s_it->second.name, s_it->second.type);
call.arguments().resize(1);
call.arguments()[0]=
typecast_exprt(
address_of_exprt(
index_exprt(
function_id_string, from_integer(0, index_type()))),
to_code_type(s_it->second.type).parameters()[0].type());
return call;
}
示例3: add_stack_depth_symbol
symbol_exprt add_stack_depth_symbol(symbol_tablet &symbol_table)
{
const irep_idt identifier="$stack_depth";
signedbv_typet type(sizeof(int)*8);
symbolt new_symbol;
new_symbol.name=identifier;
new_symbol.base_name=identifier;
new_symbol.pretty_name=identifier;
new_symbol.type=type;
new_symbol.is_static_lifetime=true;
new_symbol.value=from_integer(0, type);
new_symbol.mode=ID_C;
new_symbol.is_thread_local=true;
new_symbol.is_lvalue=true;
symbol_table.move(new_symbol);
return symbol_exprt(identifier, type);
}
示例4: java_entry_point
//.........这里部分代码省略.........
if(matches.size()>=2)
{
message.error() << "main method in `" << main_class
<< "' is ambiguous" << messaget::eom;
return true; // give up with error, no main
}
// function symbol
symbol=symbol_table.symbols.find(*matches.begin())->second;
// check if it has a body
if(symbol.value.is_nil())
{
message.error() << "main method `" << main_class
<< "' has no body" << messaget::eom;
return true; // give up with error
}
}
assert(!symbol.value.is_nil());
assert(symbol.type.id()==ID_code);
const code_typet &code_type=to_code_type(symbol.type);
create_initialize(symbol_table);
if(java_static_lifetime_init(symbol_table, symbol.location, message_handler))
return true;
code_blockt init_code;
// build call to initialization function
{
symbol_tablet::symbolst::iterator init_it=
symbol_table.symbols.find(INITIALIZE);
if(init_it==symbol_table.symbols.end())
{
message.error() << "failed to find " INITIALIZE " symbol"
<< messaget::eom;
return true; // give up with error
}
code_function_callt call_init;
call_init.lhs().make_nil();
call_init.add_source_location()=symbol.location;
call_init.function()=init_it->second.symbol_expr();
init_code.move_to_operands(call_init);
}
// build call to the main method
code_function_callt call_main;
call_main.add_source_location()=symbol.location;
call_main.function()=symbol.symbol_expr();
const code_typet::parameterst ¶meters=
code_type.parameters();
exprt::operandst main_arguments;
main_arguments.resize(parameters.size());
for(std::size_t param_number=0;
param_number<parameters.size();
param_number++)
{
bool is_this=param_number==0 &&
parameters[param_number].get_this();
bool allow_null=config.main!="" && !is_this;
main_arguments[param_number]=
object_factory(parameters[param_number].type(),
init_code, allow_null, symbol_table);
}
call_main.arguments()=main_arguments;
init_code.move_to_operands(call_main);
// add "main"
symbolt new_symbol;
code_typet main_type;
main_type.return_type()=empty_typet();
new_symbol.name=goto_functionst::entry_point();
new_symbol.type.swap(main_type);
new_symbol.value.swap(init_code);
new_symbol.mode=ID_java;
if(symbol_table.move(new_symbol))
{
message.error() << "failed to move main symbol" << messaget::eom;
return true;
}
return false;
}