本文整理汇总了C++中dereference函数的典型用法代码示例。如果您正苦于以下问题:C++ dereference函数的具体用法?C++ dereference怎么用?C++ dereference使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dereference函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: clReleaseMemObject
cl_int
clReleaseMemObject(cl_mem d_memobj)
{
auto memobj = pobj(d_memobj);
if (!memobj->isA(Coal::Object::T_MemObject))
return CL_INVALID_MEM_OBJECT;
if (memobj->dereference())
delete memobj;
return CL_SUCCESS;
}
开发者ID:rcn-ee,项目名称:ti-opencl,代码行数:13,代码来源:api_memory.cpp
示例2: clReleaseDevice
cl_int
clReleaseDevice(cl_device_id d_device)
{
auto device = pobj(d_device);
if (!device->isA(Coal::Object::T_Device))
return CL_INVALID_DEVICE;
if (device->dereference())
delete device;
return CL_SUCCESS;
}
开发者ID:yukke-fj,项目名称:shamrock,代码行数:13,代码来源:api_device.cpp
示例3: clReleaseSampler
cl_int
clReleaseSampler(cl_sampler d_sampler)
{
auto sampler = pobj(d_sampler);
if (!sampler->isA(Coal::Object::T_Sampler))
return CL_INVALID_SAMPLER;
if (sampler->dereference())
delete sampler;
return CL_SUCCESS;
}
开发者ID:rcn-ee,项目名称:ti-opencl,代码行数:13,代码来源:api_sampler.cpp
示例4: assert
void preconditiont::compute_rec(exprt &dest)
{
if(dest.id()==ID_address_of)
{
// only do index!
assert(dest.operands().size()==1);
compute_address_of(dest.op0());
}
else if(dest.id()==ID_dereference)
{
assert(dest.operands().size()==1);
const irep_idt &lhs_identifier=SSA_step.ssa_lhs.get_object_name();
// aliasing may happen here
value_setst::valuest expr_set;
value_sets.get_values(target, dest.op0(), expr_set);
std::unordered_set<irep_idt, irep_id_hash> symbols;
for(value_setst::valuest::const_iterator
it=expr_set.begin();
it!=expr_set.end();
it++)
find_symbols(*it, symbols);
if(symbols.find(lhs_identifier)!=symbols.end())
{
// may alias!
exprt tmp;
tmp.swap(dest.op0());
dereference(target, tmp, ns, value_sets);
dest.swap(tmp);
compute_rec(dest);
}
else
{
// nah, ok
compute_rec(dest.op0());
}
}
else if(dest==SSA_step.ssa_lhs.get_original_expr())
{
dest=SSA_step.ssa_rhs;
s.get_original_name(dest);
}
else
Forall_operands(it, dest)
compute_rec(*it);
}
开发者ID:DanielNeville,项目名称:cbmc,代码行数:50,代码来源:precondition.cpp
示例5: unifyTVarR
ExprType* unifyTVarR(ExprType *type, ExprType* expected, Hashtable *varTypes, Region *r) {
char buf[128];
if(T_VAR_NUM_DISJUNCTS(expected)==0) { /* free */
if(occursIn(expected, type)) {
return NULL;
}
insertIntoHashTable(varTypes, getTVarName(T_VAR_ID(expected), buf), type);
return dereference(expected, varTypes, r);
} else { /* union type */
int i;
ExprType *ty = NULL;
for(i=0;i<T_VAR_NUM_DISJUNCTS(expected);i++) {
if(getNodeType(type) == getNodeType(T_VAR_DISJUNCT(expected,i))) { /* union types can only include primitive types */
ty = type;
}
}
if(ty != NULL) {
insertIntoHashTable(varTypes, getTVarName(T_VAR_ID(expected), buf), ty);
return dereference(expected, varTypes, r);
}
return ty;
}
}
开发者ID:UPPMAX,项目名称:irods,代码行数:24,代码来源:utils.c
示例6: clReleaseCommandQueue
cl_int
clReleaseCommandQueue(cl_command_queue d_command_queue)
{
auto command_queue = pobj(d_command_queue);
if (!command_queue->isA(Coal::Object::T_CommandQueue))
return CL_INVALID_COMMAND_QUEUE;
command_queue->flush();
if (command_queue->dereference())
delete command_queue;
return CL_SUCCESS;
}
开发者ID:rcn-ee,项目名称:ti-opencl,代码行数:15,代码来源:api_command.cpp
示例7: subscript
static
subscript(stream, node, need_lval) {
auto type = node[3][2]; /* type being subscripted */
/* For (hopefully temporary) compatibility with stage-4, we allow an
* implicit int to be dereferenced as an int*. */
extern compat_flag;
auto elt_sz = compat_flag && type == implct_int() ? 4
: type_size( type[3] ); /* remove * or [] from type */
auto sz = type_size( node[2] );
scale_elt(stream, elt_sz, 1);
pop_add(stream, 0, 4);
dereference(stream, sz, need_lval);
}
开发者ID:ras52,项目名称:bootstrap,代码行数:16,代码来源:codegen.c
示例8: dereference
void Designator::add_key(const std::string& key_param,
const Location& loc) {
dereference(loc);
if (!at) {
throw Exception(loc, "null cannot be used as dictionary");
}
if (at->get_type() == Attribute::tree) {
at = at->get_node()->get_attribute();
} else if (at->get_type() == Attribute::flow_graph_node) {
at = at->get_fgnode()->get_attribute();
}
if (at->get_type() != Attribute::dictionary) {
throw Exception(loc, "is not a dictionary");
}
key = key_param; lvalue = true;
}
开发者ID:afborchert,项目名称:astl,代码行数:16,代码来源:designator.cpp
示例9: name
symbol * name(int dcl)
{
symbol * q = NULL;
if(sym_exists(token) || dcl)
{
int c = 0;
int v = 0;
int l = 0;
l = caddr(sym_addr(token, &c, &v, &q));
scan();
g_mov_bx(l);
g_push_bx();
dereference();
} else
{
error("Expected identifier");
}
return q;
}
开发者ID:catseye,项目名称:Illgol-Grand-Mal,代码行数:19,代码来源:parse.c
示例10: binary_op
static
binary_op(stream, node, need_lval) {
auto op = node[0], sz = type_size( node[2] );
expr_code( stream, node[3], is_assop(op) );
asm_push( stream );
expr_code( stream, node[4], 0 );
if ( op == '[]' ) subscript(stream, node, need_lval);
else if ( op == '*' ) pop_mult(stream, 0, node[2][5]);
else if ( op == '/' ) pop_div(stream, 0, node[2][5]);
else if ( op == '%' ) pop_mod(stream, 0, node[2][5]);
else if ( op == '+' ) add_op(stream, node, 0, sz);
else if ( op == '-' ) add_op(stream, node, 0, sz);
else if ( op == '<<' ) pop_lshift(stream, 0);
else if ( op == '>>' ) pop_rshift(stream, 0);
else if ( op == '&' ) pop_bitand(stream, 0, sz);
else if ( op == '|' ) pop_bitor(stream, 0, sz);
else if ( op == '^' ) pop_bitxor(stream, 0, sz);
else if ( op == '=' ) pop_assign(stream, sz);
else if ( op == '*=' ) pop_mult(stream, 1);
else if ( op == '/=' ) pop_div(stream, 1);
else if ( op == '%=' ) pop_mod(stream, 1);
else if ( op == '+=' ) add_op(stream, node, 1, sz);
else if ( op == '-=' ) add_op(stream, node, 1, sz);
else if ( op == '<<=' ) pop_lshift(stream, 1);
else if ( op == '>>=' ) pop_rshift(stream, 1);
else if ( op == '&=' ) pop_bitand(stream, 1, sz);
else if ( op == '|=' ) pop_bitor(stream, 1, sz);
else if ( op == '^=' ) pop_bitxor(stream, 1, sz);
else int_error("Unknown operator: '%Mc'", op);
/* The assignment operators are implemented to return lvalues, but
* the C standard says they're not lvalues. (The C++ standard has
* them as lvalues.) */
if ( is_assop(op) )
dereference(stream, type_size(node[2]), 0);
}
开发者ID:ras52,项目名称:bootstrap,代码行数:40,代码来源:codegen.c
示例11: second_chance_select
/**
* Second chance select implementation for choosing pages to
* swap out. This will loop through the queue and find the
* oldest unreferenced page.
* Note: Since we use software emulated reference bits, in case
* everything is mapped in the HW page table this degenerates
* to pure FIFO.
*
* @param page_queue
* @return oldest unreferenced page (removed from the queue)
*/
static page_queue_item* second_chance_select(struct pages_head* page_queue) {
page_queue_item* page;
// do a second chance search for a page over all currently active pages
for(page = page_queue->tqh_first; page != NULL; page = page_queue->tqh_first) {
if(is_referenced(page)) {
TAILQ_REMOVE(page_queue, page, entries); // remove oldest page
dereference(page);
TAILQ_INSERT_TAIL(page_queue, page, entries); // insert at front
}
else {
// remove the page from the working set
TAILQ_REMOVE(page_queue, page, entries);
return page;
}
}
return NULL; // no pages in queue (bad)
}
开发者ID:gz,项目名称:aos10,代码行数:33,代码来源:swapper.c
示例12: read_lhs
exprt local_SSAt::read_lhs(
const exprt &expr,
locationt loc) const
{
// dereference first
exprt tmp1=dereference(expr, loc);
ssa_objectt object(tmp1, ns);
// is this an object we track?
if(ssa_objects.objects.find(object)!=
ssa_objects.objects.end())
{
// yes, it is
if(assignments.assigns(loc, object))
return name(object, OUT, loc);
else
return read_rhs(object, loc);
}
else
return read_rhs(tmp1, loc);
}
开发者ID:AnnaTrost,项目名称:deltacheck,代码行数:22,代码来源:local_ssa.cpp
示例13: leftSymbolName
VisitResult ExpressionVisitor::Visit(IndexNode* node)
{
node->Walk(this, false);
ValueNode* leftSide = static_cast<ValueNode*>(node->mLeft.get());
ValueNode* indexExpr = static_cast<ValueNode*>(node->mIndex.get());
std::string leftSymbolName(leftSide->mToken.mText, leftSide->mToken.mLength);
std::string indexSymbolName(indexExpr->mToken.mText, indexExpr->mToken.mLength);
if(leftSide->mResolvedType->mMode == TypeMode::Pointer)
{
node->mResolvedType = dereference(leftSide->mResolvedType);
}
else
{
ErrorInvalidIndexer(node);
}
if(indexExpr->mResolvedType->mName != "Integer")
{
ErrorInvalidIndexer(node);
}
return VisitResult::Stop;
}
开发者ID:Marktopus,项目名称:SchoolRepo,代码行数:23,代码来源:User4.cpp
示例14: unary_pre
static
unary_pre(stream, node, need_lval) {
auto op = node[0];
auto op_needs_lv = op == '++' || op == '--' || op == '&';
auto sz = type_size(node[2]);
expr_code( stream, node[3], op_needs_lv );
if ( op == '+' ) {
/* Arrays degrade to pointers. */
auto src_sz;
if ( node[3][2][0] == '[]' ) src_sz = 4;
else src_sz = type_size(node[3][2]);
promote(stream, node[2][5], src_sz, sz);
}
else if ( op == '-' ) arith_neg(stream);
else if ( op == '~' ) bit_not(stream);
else if ( op == '!' ) logic_not(stream);
else if ( op == '&' ) ;
else if ( op == '*' ) dereference(stream, sz, need_lval);
else if ( op == '++' ) increment(stream, sz, ptr_inc_sz(node[2]) );
else if ( op == '--' ) increment(stream, sz, -ptr_inc_sz(node[2]) );
else int_error("Unknown operator: '%Mc'", op);
}
开发者ID:ras52,项目名称:bootstrap,代码行数:23,代码来源:codegen.c
示例15: if
void Serializer::serialize(Any object, ITypeMeta* type)
{
auto flags = type->getFlags();
if (flags & ITypeMeta::IsCustomSerializing)
{
auto classMeta = static_cast<IClassMeta*>(type);
classMeta->functions["serialize"]->invoke(object, this);
}
else if (flags & ITypeMeta::IsPointer)
{
lua_newtable(L);
lua_pushinteger(L, 1);
auto pointeeType = type->getRunTimePointeeType(object);
object = pointeeType->dereference(object);
serialize(object, pointeeType);
lua_settable(L, -3);
}
else if (type == typeMetaOf<std::string>())
{
lua_pushstring(L, object.as<std::string>().c_str());
}
else if (flags & ITypeMeta::IsClass)
{
auto classMeta = static_cast<IClassMeta*>(type);
serializeAsClass(object, classMeta);
}
else if (type == typeMetaOf<int>())
{
lua_pushinteger(L, object.as<int>());
}
else if (type == typeMetaOf<float>())
{
lua_pushnumber(L, object.as<float>());
}
}
开发者ID:Alprog,项目名称:Judy,代码行数:37,代码来源:Serializer.cpp
示例16: switch
bool Item::isTrue() const
{
switch( dereference()->type() )
{
case FLC_ITEM_BOOL:
return asBoolean() != 0;
case FLC_ITEM_INT:
return asInteger() != 0;
case FLC_ITEM_NUM:
return asNumeric() != 0.0;
case FLC_ITEM_RANGE:
return asRangeStart() != asRangeEnd() || asRangeIsOpen();
case FLC_ITEM_STRING:
return asString()->size() != 0;
case FLC_ITEM_ARRAY:
return asArray()->length() != 0;
case FLC_ITEM_DICT:
return asDict()->length() != 0;
case FLC_ITEM_FUNC:
case FLC_ITEM_OBJECT:
case FLC_ITEM_CLASS:
case FLC_ITEM_METHOD:
case FLC_ITEM_MEMBUF:
case FLC_ITEM_LBIND:
// methods are always filled, so they are always true.
return true;
}
return false;
}
开发者ID:IamusNavarathna,项目名称:lv3proj,代码行数:37,代码来源:item.cpp
示例17: as
T const* as(value const& v)
{
return boost::get<T>(&dereference(v));
}
开发者ID:iankronquist,项目名称:puppetcpp,代码行数:4,代码来源:value.hpp
示例18:
const T* operator->() const
{ return &(dereference()); }
开发者ID:3rf,项目名称:mongo,代码行数:2,代码来源:iterators.hpp
示例19: dereference
const T& operator[](difference_type) const
{ return dereference(); }
开发者ID:3rf,项目名称:mongo,代码行数:2,代码来源:iterators.hpp
示例20: main
int main(int argv, char** argc) {
if (argv == 1) {
std::cerr << "Must provide a command and arguments! Try parse, rewrite, compile, assemble\n";
return 0;
}
std::string flag = "";
std::string command = argc[1];
std::string input;
std::string secondInput;
if (std::string(argc[1]) == "-s") {
flag = command.substr(1);
command = argc[2];
input = "";
std::string line;
while (std::getline(std::cin, line)) {
input += line + "\n";
}
secondInput = argv == 3 ? "" : argc[3];
}
else {
if (argv == 2) {
std::cerr << "Not enough arguments for serpent cmdline\n";
throw(0);
}
input = argc[2];
secondInput = argv == 3 ? "" : argc[3];
}
bool haveSec = secondInput.length() > 0;
if (command == "parse" || command == "parse_serpent") {
std::cout << printAST(parseSerpent(input), haveSec) << "\n";
}
else if (command == "rewrite") {
std::cout << printAST(rewrite(parseLLL(input, true)), haveSec) << "\n";
}
else if (command == "compile_to_lll") {
std::cout << printAST(compileToLLL(input), haveSec) << "\n";
}
else if (command == "build_fragtree") {
std::cout << printAST(buildFragmentTree(parseLLL(input, true))) << "\n";
}
else if (command == "compile_lll") {
std::cout << binToHex(compileLLL(parseLLL(input, true))) << "\n";
}
else if (command == "dereference") {
std::cout << printAST(dereference(parseLLL(input, true)), haveSec) <<"\n";
}
else if (command == "pretty_assemble") {
std::cout << printTokens(prettyAssemble(parseLLL(input, true))) <<"\n";
}
else if (command == "pretty_compile_lll") {
std::cout << printTokens(prettyCompileLLL(parseLLL(input, true))) << "\n";
}
else if (command == "pretty_compile") {
std::cout << printTokens(prettyCompile(input)) << "\n";
}
else if (command == "assemble") {
std::cout << assemble(parseLLL(input, true)) << "\n";
}
else if (command == "serialize") {
std::cout << binToHex(serialize(tokenize(input, Metadata(), false))) << "\n";
}
else if (command == "flatten") {
std::cout << printTokens(flatten(parseLLL(input, true))) << "\n";
}
else if (command == "deserialize") {
std::cout << printTokens(deserialize(hexToBin(input))) << "\n";
}
else if (command == "compile") {
std::cout << binToHex(compile(input)) << "\n";
}
else if (command == "encode_datalist") {
std::vector<Node> tokens = tokenize(input);
std::vector<std::string> o;
for (int i = 0; i < (int)tokens.size(); i++) {
o.push_back(tokens[i].val);
}
std::cout << binToHex(encodeDatalist(o)) << "\n";
}
else if (command == "decode_datalist") {
std::vector<std::string> o = decodeDatalist(hexToBin(input));
std::vector<Node> tokens;
for (int i = 0; i < (int)o.size(); i++)
tokens.push_back(token(o[i]));
std::cout << printTokens(tokens) << "\n";
}
else if (command == "tokenize") {
std::cout << printTokens(tokenize(input));
}
else if (command == "biject") {
if (argv == 3)
std::cerr << "Not enough arguments for biject\n";
int pos = decimalToUnsigned(secondInput);
std::vector<Node> n = prettyCompile(input);
if (pos >= (int)n.size())
std::cerr << "Code position too high\n";
Metadata m = n[pos].metadata;
std::cout << "Opcode: " << n[pos].val << ", file: " << m.file <<
", line: " << m.ln << ", char: " << m.ch << "\n";
}
}
开发者ID:GrimDerp,项目名称:serpent,代码行数:100,代码来源:cmdline.cpp
注:本文中的dereference函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论