pike.git
/
src
/
program.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/program.c:11690:
Inside #if 0
} return -1; } #endif /* 0 */ /* returns 1 if a implements b */ static int low_implements(struct program *a, struct program *b) {
+
DECLARE_CYCLIC();
int e;
-
+
int ret = 1;
struct pike_string *s=findstring("__INIT");
-
+
+
if (BEGIN_CYCLIC(a, b)) return 1; /* Tentatively ok, */
+
SET_CYCLIC_RET(1);
+
for(e=0;e<b->num_identifier_references;e++) { struct identifier *bid; int i; if (b->identifier_references[e].id_flags & (ID_PROTECTED|ID_HIDDEN|ID_VARIANT)) continue; /* Skip protected & hidden */ bid = ID_FROM_INT(b,e); if(s == bid->name) continue; /* Skip __INIT */ i = find_shared_string_identifier(bid->name,a); if (i == -1) { if (b->identifier_references[e].id_flags & (ID_OPTIONAL)) continue; /* It's ok... */ #if 0 fprintf(stderr, "Missing identifier \"%s\"\n", bid->name->str); #endif /* 0 */
-
return
0;
+
ret
=
0;
+
break;
} if (!pike_types_le(bid->type, ID_FROM_INT(a, i)->type)) { if(!match_types(ID_FROM_INT(a,i)->type, bid->type)) { #if 0 fprintf(stderr, "Identifier \"%s\" is incompatible.\n", bid->name->str); #endif /* 0 */
-
return
0;
+
ret
=
0;
+
break;
} else { #if 0 fprintf(stderr, "Identifier \"%s\" is not strictly compatible.\n", bid->name->str); #endif /* 0 */ } } }
-
return
1
;
+
+
END_CYCLIC();
+
return
ret
;
} #define IMPLEMENTS_CACHE_SIZE 1024 struct implements_cache_s { INT32 aid, bid, ret; }; static struct implements_cache_s implements_cache[IMPLEMENTS_CACHE_SIZE]; static int implements_hval( INT32 aid, INT32 bid ) { return ((aid<<4) ^ bid ^ (aid>>4)) & (IMPLEMENTS_CACHE_SIZE-1); }
pike.git/src/program.c:11763:
implements_cache[hval].ret = low_implements(a,b); /* NOTE: If low_implements() returns 0, the cache may have received * some false positives. Those should be cleared. */ return implements_cache[hval].ret; } /* Returns 1 if a is compatible with b */ static int low_is_compatible(struct program *a, struct program *b) {
+
DECLARE_CYCLIC();
int e;
-
+
int ret = 1;
struct pike_string *s=findstring("__INIT");
-
+
if (BEGIN_CYCLIC(a, b)) return 1;
+
SET_CYCLIC_RET(1);
+
/* Optimize the loop somewhat */ if (a->num_identifier_references < b->num_identifier_references) { struct program *tmp = a; a = b; b = tmp; } for(e=0;e<b->num_identifier_references;e++) { struct identifier *bid;
pike.git/src/program.c:11797:
} /* Note: Uses weaker check for constant integers. */ if(((bid->run_time_type != PIKE_T_INT) || (ID_FROM_INT(a, i)->run_time_type != PIKE_T_INT)) && !match_types(ID_FROM_INT(a,i)->type, bid->type)) { #if 0 fprintf(stderr, "Identifier \"%s\" is incompatible.\n", bid->name->str); #endif /* 0 */
-
return
0;
+
ret
=
0;
+
break;
} }
-
return
1
;
+
+
END_CYCLIC();
+
return
ret
;
} static struct implements_cache_s is_compatible_cache[IMPLEMENTS_CACHE_SIZE]; /* Returns 1 if a is compatible with b * ie it's possible to write a hypothetical c that implements both. */ PMOD_EXPORT int is_compatible(struct program *a, struct program *b) { unsigned long hval; unsigned long rhval;