本文整理汇总了C++中ptrhash_bp函数的典型用法代码示例。如果您正苦于以下问题:C++ ptrhash_bp函数的具体用法?C++ ptrhash_bp怎么用?C++ ptrhash_bp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ptrhash_bp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jl_deserialize_fptr
static jl_fptr_t jl_deserialize_fptr(ios_t *s)
{
int fptr = read_uint16(s);
if (fptr == 0)
return NULL;
void **pbp = ptrhash_bp(&id_to_fptr, (void*)(ptrint_t)fptr);
if (*pbp == HT_NOTFOUND)
jl_error("unknown function pointer ID");
return *(jl_fptr_t*)pbp;
}
示例2: jl_gc_add_finalizer
void jl_gc_add_finalizer(jl_value_t *v, jl_function_t *f)
{
jl_value_t **bp = (jl_value_t**)ptrhash_bp(&finalizer_table, v);
if (*bp == HT_NOTFOUND) {
*bp = (jl_value_t*)f;
}
else {
*bp = (jl_value_t*)jl_tuple2((jl_value_t*)f, *bp);
}
}
示例3: jl_symbol
// get binding for adding a method
// like jl_get_binding_wr, but uses existing imports instead of warning
// and overwriting.
JL_DLLEXPORT jl_binding_t *jl_get_binding_for_method_def(jl_module_t *m,
jl_sym_t *var)
{
if (jl_base_module && m->std_imports && !jl_binding_resolved_p(m,var)) {
jl_module_t *opmod = (jl_module_t*)jl_get_global(jl_base_module, jl_symbol("Operators"));
if (opmod != NULL && jl_defines_or_exports_p(opmod, var)) {
jl_printf(JL_STDERR,
"WARNING: module %s should explicitly import %s from %s\n",
jl_symbol_name(m->name), jl_symbol_name(var),
jl_symbol_name(jl_base_module->name));
jl_module_import(m, opmod, var);
}
}
jl_binding_t **bp = (jl_binding_t**)ptrhash_bp(&m->bindings, var);
jl_binding_t *b = *bp;
if (b != HT_NOTFOUND) {
if (b->owner != m && b->owner != NULL) {
jl_binding_t *b2 = jl_get_binding(b->owner, var);
if (b2 == NULL)
jl_errorf("invalid method definition: imported function %s.%s does not exist", jl_symbol_name(b->owner->name), jl_symbol_name(var));
if (!b->imported && (b2->value==NULL || jl_is_function(b2->value))) {
if (b2->value && !jl_is_gf(b2->value)) {
jl_errorf("error in method definition: %s.%s cannot be extended", jl_symbol_name(b->owner->name), jl_symbol_name(var));
}
else {
if (jl_base_module && m->std_imports && b->owner == jl_base_module) {
jl_module_t *opmod = (jl_module_t*)jl_get_global(jl_base_module, jl_symbol("Operators"));
if (opmod != NULL && jl_defines_or_exports_p(opmod, var)) {
jl_printf(JL_STDERR,
"WARNING: module %s should explicitly import %s from %s\n",
jl_symbol_name(m->name),
jl_symbol_name(var),
jl_symbol_name(b->owner->name));
return b2;
}
}
jl_errorf("error in method definition: function %s.%s must be explicitly imported to be extended", jl_symbol_name(b->owner->name),
jl_symbol_name(var));
}
}
return b2;
}
b->owner = m;
return b;
}
b = new_binding(var);
b->owner = m;
*bp = b;
jl_gc_wb_buf(m, b);
return *bp;
}
示例4: jl_module_export
void jl_module_export(jl_module_t *from, jl_sym_t *s)
{
jl_binding_t **bp = (jl_binding_t**)ptrhash_bp(&from->bindings, s);
if (*bp == HT_NOTFOUND) {
jl_binding_t *b = new_binding(s);
// don't yet know who the owner is
b->owner = NULL;
*bp = b;
}
assert(*bp != HT_NOTFOUND);
(*bp)->exportp = 1;
}
示例5: module_import_
static void module_import_(jl_module_t *to, jl_module_t *from, jl_sym_t *s,
int explicit)
{
if (to == from)
return;
jl_binding_t *b = jl_get_binding(from, s);
if (b == NULL) {
ios_printf(JL_STDERR,
"Warning: could not import %s.%s into %s\n",
from->name->name, s->name, to->name->name);
}
else {
jl_binding_t **bp = (jl_binding_t**)ptrhash_bp(&to->bindings, s);
jl_binding_t *bto = *bp;
if (bto != HT_NOTFOUND) {
if (bto == b) {
// importing a binding on top of itself. harmless.
}
else if (bto->owner == b->owner) {
// already imported
bto->imported = (explicit!=0);
}
else if (bto->owner != to && bto->owner != NULL) {
ios_printf(JL_STDERR,
"Warning: ignoring conflicting import of %s.%s into %s\n",
from->name->name, s->name, to->name->name);
}
else if (bto->constp || bto->value) {
assert(bto->owner == to);
if (bto->constp && bto->value && b->constp &&
b->value == bto->value) {
// import of equivalent binding
return;
}
ios_printf(JL_STDERR,
"Warning: import of %s.%s into %s conflicts with an existing identifier; ignored.\n",
from->name->name, s->name, to->name->name);
}
else {
bto->owner = b->owner;
bto->imported = (explicit!=0);
}
}
示例6:
jl_binding_t *jl_get_binding(jl_module_t *m, jl_sym_t *var)
{
jl_binding_t **bp = (jl_binding_t**)ptrhash_bp(&m->bindings, var);
if (*bp == HT_NOTFOUND) {
jl_binding_t *b = (jl_binding_t*)allocb(sizeof(jl_binding_t));
b->name = var;
b->value = NULL;
b->type = (jl_type_t*)jl_any_type;
b->constp = 0;
b->exportp = 0;
*bp = b;
// keep track of all variables added after the VARIABLES array
// is defined
if (varlist_binding &&
varlist_binding->value != NULL &&
jl_typeis(varlist_binding->value, jl_array_any_type)) {
jl_array_t *a = (jl_array_t*)varlist_binding->value;
jl_cell_1d_push(a, (jl_value_t*)var);
}
}
return *bp;
}
示例7:
// get binding for adding a method
// like jl_get_binding_wr, but uses existing imports instead of warning
// and overwriting.
jl_binding_t *jl_get_binding_for_method_def(jl_module_t *m, jl_sym_t *var)
{
jl_binding_t **bp = (jl_binding_t**)ptrhash_bp(&m->bindings, var);
jl_binding_t *b = *bp;
if (b != HT_NOTFOUND) {
if (b->owner != m && b->owner != NULL) {
jl_binding_t *b2 = jl_get_binding(b->owner, var);
if (b2 == NULL)
jl_errorf("invalid method definition: imported function %s.%s does not exist", b->owner->name->name, var->name);
if (!b->imported)
jl_errorf("error in method definition: function %s.%s must be explicitly imported to be extended", b->owner->name->name, var->name);
return b2;
}
b->owner = m;
return b;
}
b = new_binding(var);
b->owner = m;
*bp = b;
return *bp;
}
示例8: if
// get binding for assignment
JL_DLLEXPORT jl_binding_t *jl_get_binding_wr(jl_module_t *m, jl_sym_t *var, int error)
{
jl_binding_t **bp = (jl_binding_t**)ptrhash_bp(&m->bindings, var);
jl_binding_t *b = *bp;
if (b != HT_NOTFOUND) {
if (b->owner != m) {
if (b->owner == NULL) {
b->owner = m;
}
else if (error) {
jl_errorf("cannot assign variable %s.%s from module %s",
jl_symbol_name(b->owner->name), jl_symbol_name(var), jl_symbol_name(m->name));
}
}
return *bp;
}
b = new_binding(var);
b->owner = m;
*bp = b;
jl_gc_wb_buf(m, b, sizeof(jl_binding_t));
return *bp;
}
示例9: jl_module_exports_p
JL_DLLEXPORT int jl_module_exports_p(jl_module_t *m, jl_sym_t *var)
{
jl_binding_t **bp = (jl_binding_t**)ptrhash_bp(&m->bindings, var);
if (*bp == HT_NOTFOUND) return 0;
return (*bp)->exportp;
}
示例10: jl_set_expander
void jl_set_expander(jl_module_t *m, jl_sym_t *macroname, jl_function_t *f)
{
jl_function_t **bp = (jl_function_t**)ptrhash_bp(&m->macros, macroname);
*bp = f;
}
示例11: ios_pos
static jl_value_t *jl_deserialize_value(ios_t *s)
{
int pos = ios_pos(s);
int32_t tag = read_uint8(s);
if (tag == Null_tag)
return NULL;
if (tag == 0) {
tag = read_uint8(s);
jl_value_t *v = ptrhash_get(&deser_tag, (void*)(ptrint_t)tag);
assert(v != HT_NOTFOUND);
return v;
}
if (tag == BackRef_tag || tag == ShortBackRef_tag) {
assert(tree_literal_values == NULL);
ptrint_t offs = (tag == BackRef_tag) ? read_int32(s) : read_uint16(s);
void **bp = ptrhash_bp(&backref_table, (void*)(ptrint_t)offs);
assert(*bp != HT_NOTFOUND);
return (jl_value_t*)*bp;
}
jl_value_t *vtag=(jl_value_t*)ptrhash_get(&deser_tag,(void*)(ptrint_t)tag);
if (tag >= VALUE_TAGS) {
return vtag;
}
int usetable = (tree_literal_values == NULL);
size_t i;
if (vtag == (jl_value_t*)jl_tuple_type ||
vtag == (jl_value_t*)LongTuple_tag) {
size_t len;
if (vtag == (jl_value_t*)jl_tuple_type)
len = read_uint8(s);
else
len = read_int32(s);
jl_tuple_t *tu = jl_alloc_tuple_uninit(len);
if (usetable)
ptrhash_put(&backref_table, (void*)(ptrint_t)pos, (jl_value_t*)tu);
for(i=0; i < len; i++)
jl_tupleset(tu, i, jl_deserialize_value(s));
return (jl_value_t*)tu;
}
else if (vtag == (jl_value_t*)jl_symbol_type ||
vtag == (jl_value_t*)LongSymbol_tag) {
size_t len;
if (vtag == (jl_value_t*)jl_symbol_type)
len = read_uint8(s);
else
len = read_int32(s);
char *name = alloca(len+1);
ios_read(s, name, len);
name[len] = '\0';
jl_value_t *s = (jl_value_t*)jl_symbol(name);
if (usetable)
ptrhash_put(&backref_table, (void*)(ptrint_t)pos, s);
return s;
}
else if (vtag == (jl_value_t*)jl_array_type) {
jl_value_t *aty = jl_deserialize_value(s);
jl_value_t *elty = jl_tparam0(aty);
int16_t ndims = jl_unbox_long(jl_tparam1(aty));
size_t *dims = alloca(ndims*sizeof(size_t));
for(i=0; i < ndims; i++)
dims[i] = jl_unbox_long(jl_deserialize_value(s));
jl_array_t *a = jl_new_array_((jl_type_t*)aty, ndims, dims);
if (usetable)
ptrhash_put(&backref_table, (void*)(ptrint_t)pos, (jl_value_t*)a);
if (jl_is_bits_type(elty)) {
size_t tot = jl_array_len(a) * a->elsize;
ios_read(s, jl_array_data(a), tot);
}
else {
for(i=0; i < jl_array_len(a); i++) {
((jl_value_t**)a->data)[i] = jl_deserialize_value(s);
}
}
return (jl_value_t*)a;
}
else if (vtag == (jl_value_t*)jl_expr_type ||
vtag == (jl_value_t*)LongExpr_tag) {
size_t len;
if (vtag == (jl_value_t*)jl_expr_type)
len = read_uint8(s);
else
len = read_int32(s);
jl_expr_t *e = jl_exprn((jl_sym_t*)jl_deserialize_value(s), len);
if (usetable)
ptrhash_put(&backref_table, (void*)(ptrint_t)pos, (jl_value_t*)e);
e->etype = jl_deserialize_value(s);
for(i=0; i < len; i++) {
jl_cellset(e->args, i, jl_deserialize_value(s));
}
return (jl_value_t*)e;
}
else if (vtag == (jl_value_t*)LiteralVal_tag) {
return jl_cellref(tree_literal_values, read_uint16(s));
}
else if (vtag == (jl_value_t*)jl_tvar_type) {
jl_tvar_t *tv = (jl_tvar_t*)newobj((jl_type_t*)jl_tvar_type, 4);
if (usetable)
//.........这里部分代码省略.........
示例12: module_import_
// NOTE: we use explici since explicit is a C++ keyword
static void module_import_(jl_module_t *to, jl_module_t *from, jl_sym_t *s,
int explici)
{
if (to == from)
return;
jl_binding_t *b = jl_get_binding(from, s);
if (b == NULL) {
jl_printf(JL_STDERR,
"WARNING: could not import %s.%s into %s\n",
jl_symbol_name(from->name), jl_symbol_name(s),
jl_symbol_name(to->name));
}
else {
jl_binding_t **bp = (jl_binding_t**)ptrhash_bp(&to->bindings, s);
jl_binding_t *bto = *bp;
if (bto != HT_NOTFOUND) {
if (bto == b) {
// importing a binding on top of itself. harmless.
}
else if (bto->owner == b->owner) {
// already imported
bto->imported = (explici!=0);
}
else if (bto->owner != to && bto->owner != NULL) {
// already imported from somewhere else
jl_binding_t *bval = jl_get_binding(to, s);
if (bval->constp && bval->value && b->constp && b->value == bval->value) {
// equivalent binding
bto->imported = (explici!=0);
return;
}
jl_printf(JL_STDERR,
"WARNING: ignoring conflicting import of %s.%s into %s\n",
jl_symbol_name(from->name), jl_symbol_name(s),
jl_symbol_name(to->name));
}
else if (bto->constp || bto->value) {
// conflict with name owned by destination module
assert(bto->owner == to);
if (bto->constp && bto->value && b->constp && b->value == bto->value) {
// equivalent binding
return;
}
jl_printf(JL_STDERR,
"WARNING: import of %s.%s into %s conflicts with an existing identifier; ignored.\n",
jl_symbol_name(from->name), jl_symbol_name(s),
jl_symbol_name(to->name));
}
else {
bto->owner = b->owner;
bto->imported = (explici!=0);
}
}
else {
jl_binding_t *nb = new_binding(s);
nb->owner = b->owner;
nb->imported = (explici!=0);
nb->deprecated = b->deprecated;
*bp = nb;
jl_gc_wb_buf(to, nb);
}
}
}
示例13: ios_pos
static jl_value_t *jl_deserialize_value(ios_t *s)
{
int pos = ios_pos(s);
int32_t tag = read_uint8(s);
if (tag == Null_tag)
return NULL;
if (tag == 0) {
tag = read_uint8(s);
return (jl_value_t*)ptrhash_get(&deser_tag, (void*)(ptrint_t)tag);
}
if (tag == BackRef_tag) {
assert(tree_literal_values == NULL);
ptrint_t offs = read_int32(s);
void **bp = ptrhash_bp(&backref_table, (void*)(ptrint_t)offs);
assert(*bp != HT_NOTFOUND);
return (jl_value_t*)*bp;
}
jl_value_t *vtag=(jl_value_t*)ptrhash_get(&deser_tag,(void*)(ptrint_t)tag);
if (tag >= VALUE_TAGS) {
return vtag;
}
int usetable = (tree_literal_values == NULL);
size_t i;
if (vtag == (jl_value_t*)jl_tuple_type ||
vtag == (jl_value_t*)LongTuple_tag) {
size_t len;
if (vtag == (jl_value_t*)jl_tuple_type)
len = read_uint8(s);
else
len = read_int32(s);
jl_tuple_t *tu = jl_alloc_tuple_uninit(len);
if (usetable)
ptrhash_put(&backref_table, (void*)(ptrint_t)pos, (jl_value_t*)tu);
for(i=0; i < len; i++)
jl_tupleset(tu, i, jl_deserialize_value(s));
return (jl_value_t*)tu;
}
else if (vtag == (jl_value_t*)jl_symbol_type ||
vtag == (jl_value_t*)LongSymbol_tag) {
size_t len;
if (vtag == (jl_value_t*)jl_symbol_type)
len = read_uint8(s);
else
len = read_int32(s);
char *name = alloca(len+1);
ios_read(s, name, len);
name[len] = '\0';
jl_value_t *s = (jl_value_t*)jl_symbol(name);
if (usetable)
ptrhash_put(&backref_table, (void*)(ptrint_t)pos, s);
return s;
}
else if (vtag == (jl_value_t*)jl_array_type) {
jl_value_t *aty = jl_deserialize_value(s);
jl_value_t *elty = jl_tparam0(aty);
int16_t ndims = jl_unbox_long(jl_tparam1(aty));
size_t *dims = alloca(ndims*sizeof(size_t));
for(i=0; i < ndims; i++)
dims[i] = jl_unbox_long(jl_deserialize_value(s));
jl_array_t *a = jl_new_array_((jl_type_t*)aty, ndims, dims);
if (usetable)
ptrhash_put(&backref_table, (void*)(ptrint_t)pos, (jl_value_t*)a);
if (jl_is_bits_type(elty)) {
size_t tot = a->length * a->elsize;
ios_read(s, a->data, tot);
}
else {
for(i=0; i < a->length; i++) {
((jl_value_t**)a->data)[i] = jl_deserialize_value(s);
}
}
return (jl_value_t*)a;
}
else if (vtag == (jl_value_t*)jl_expr_type ||
vtag == (jl_value_t*)LongExpr_tag) {
size_t len;
if (vtag == (jl_value_t*)jl_expr_type)
len = read_uint8(s);
else
len = read_int32(s);
jl_expr_t *e = jl_exprn((jl_sym_t*)jl_deserialize_value(s), len);
if (usetable)
ptrhash_put(&backref_table, (void*)(ptrint_t)pos, (jl_value_t*)e);
e->etype = jl_deserialize_value(s);
for(i=0; i < len; i++) {
jl_cellset(e->args, i, jl_deserialize_value(s));
}
return (jl_value_t*)e;
}
else if (vtag == (jl_value_t*)LiteralVal_tag) {
return jl_cellref(tree_literal_values, read_uint16(s));
}
else if (vtag == (jl_value_t*)jl_tvar_type) {
jl_tvar_t *tv = (jl_tvar_t*)newobj((jl_type_t*)jl_tvar_type, 4);
if (usetable)
ptrhash_put(&backref_table, (void*)(ptrint_t)pos, tv);
tv->name = (jl_sym_t*)jl_deserialize_value(s);
//.........这里部分代码省略.........
示例14: jl_get_ptls_states
// TODO: add locks around global state mutation operations
jl_value_t *jl_eval_module_expr(jl_module_t *parent_module, jl_expr_t *ex)
{
jl_ptls_t ptls = jl_get_ptls_states();
assert(ex->head == module_sym);
if (jl_array_len(ex->args) != 3 || !jl_is_expr(jl_exprarg(ex, 2))) {
jl_error("syntax: malformed module expression");
}
int std_imports = (jl_exprarg(ex, 0) == jl_true);
jl_sym_t *name = (jl_sym_t*)jl_exprarg(ex, 1);
if (!jl_is_symbol(name)) {
jl_type_error("module", (jl_value_t*)jl_sym_type, (jl_value_t*)name);
}
jl_module_t *newm = jl_new_module(name);
jl_value_t *form = (jl_value_t*)newm;
JL_GC_PUSH1(&form);
ptrhash_put(&jl_current_modules, (void*)newm, (void*)((uintptr_t)HT_NOTFOUND + 1));
// copy parent environment info into submodule
newm->uuid = parent_module->uuid;
if (jl_base_module &&
(jl_value_t*)parent_module == jl_get_global(jl_base_module, jl_symbol("__toplevel__"))) {
newm->parent = newm;
jl_register_root_module(newm);
}
else {
jl_binding_t *b = jl_get_binding_wr(parent_module, name, 1);
jl_declare_constant(b);
if (b->value != NULL) {
if (!jl_is_module(b->value)) {
jl_errorf("invalid redefinition of constant %s", jl_symbol_name(name));
}
if (jl_generating_output()) {
jl_errorf("cannot replace module %s during compilation", jl_symbol_name(name));
}
jl_printf(JL_STDERR, "WARNING: replacing module %s.\n", jl_symbol_name(name));
// create a hidden gc root for the old module
uintptr_t *refcnt = (uintptr_t*)ptrhash_bp(&jl_current_modules, (void*)b->value);
*refcnt += 1;
}
newm->parent = parent_module;
b->value = (jl_value_t*)newm;
jl_gc_wb_binding(b, newm);
}
if (parent_module == jl_main_module && name == jl_symbol("Base")) {
// pick up Base module during bootstrap
jl_base_module = newm;
}
size_t last_age = ptls->world_age;
// add standard imports unless baremodule
if (std_imports) {
if (jl_base_module != NULL) {
jl_add_standard_imports(newm);
}
// add `eval` function
form = jl_call_scm_on_ast("module-default-defs", (jl_value_t*)ex, newm);
ptls->world_age = jl_world_counter;
jl_toplevel_eval_flex(newm, form, 0, 1);
form = NULL;
}
jl_array_t *exprs = ((jl_expr_t*)jl_exprarg(ex, 2))->args;
for (int i = 0; i < jl_array_len(exprs); i++) {
// process toplevel form
ptls->world_age = jl_world_counter;
form = jl_expand_stmt(jl_array_ptr_ref(exprs, i), newm);
ptls->world_age = jl_world_counter;
(void)jl_toplevel_eval_flex(newm, form, 1, 1);
}
ptls->world_age = last_age;
#if 0
// some optional post-processing steps
size_t i;
void **table = newm->bindings.table;
for(i=1; i < newm->bindings.size; i+=2) {
if (table[i] != HT_NOTFOUND) {
jl_binding_t *b = (jl_binding_t*)table[i];
// remove non-exported macros
if (jl_symbol_name(b->name)[0]=='@' &&
!b->exportp && b->owner == newm)
b->value = NULL;
// error for unassigned exports
/*
if (b->exportp && b->owner==newm && b->value==NULL)
jl_errorf("identifier %s exported from %s is not initialized",
jl_symbol_name(b->name), jl_symbol_name(newm->name));
*/
}
}
#endif
uintptr_t *refcnt = (uintptr_t*)ptrhash_bp(&jl_current_modules, (void*)newm);
assert(*refcnt > (uintptr_t)HT_NOTFOUND);
*refcnt -= 1;
// newm should be reachable from somewhere else by now
//.........这里部分代码省略.........
示例15: jl_binding_resolved_p
int jl_binding_resolved_p(jl_module_t *m, jl_sym_t *var)
{
jl_binding_t **bp = (jl_binding_t**)ptrhash_bp(&m->bindings, var);
if (*bp == HT_NOTFOUND) return 0;
return (*bp)->owner != NULL;
}