pike.git/src/program.c:1589:
void add_relocated_int_to_program(INT32 i)
{
add_to_relocations(Pike_compiler->new_program->num_program);
ins_int(i, (void (*)(char))add_to_program);
}
void use_module(struct svalue *s)
{
struct compilation *c = THIS_COMPILATION;
- if( (1<<s->type) & (BIT_MAPPING | BIT_OBJECT | BIT_PROGRAM))
+ if( (1<<TYPEOF(*s)) & (BIT_MAPPING | BIT_OBJECT | BIT_PROGRAM))
{
c->num_used_modules++;
Pike_compiler->num_used_modules++;
assign_svalue_no_free((struct svalue *)
low_make_buf_space(sizeof(struct svalue),
&c->used_modules), s);
if(Pike_compiler->module_index_cache)
{
free_mapping(Pike_compiler->module_index_cache);
Pike_compiler->module_index_cache=0;
pike.git/src/program.c:1643:
static struct node_s *index_modules(struct pike_string *ident,
struct mapping **module_index_cache,
int num_used_modules,
struct svalue *modules)
{
if(*module_index_cache)
{
struct svalue *tmp=low_mapping_string_lookup(*module_index_cache,ident);
if(tmp)
{
- if(!(SAFE_IS_ZERO(tmp) && tmp->subtype==1))
+ if(!(SAFE_IS_ZERO(tmp) && SUBTYPEOF(*tmp)==1))
return mksvaluenode(tmp);
return 0;
}
}
/* fprintf(stderr,"index_module: %s\n",ident->str); */
{
JMP_BUF tmp;
pike.git/src/program.c:1672:
push_svalue(m+e);
ref_push_string(ident);
f_index(2);
if(!IS_UNDEFINED(Pike_sp-1))
{
struct node_s *ret;
UNSETJMP(tmp);
if (Pike_compiler->compiler_pass == 2 &&
- ((Pike_sp[-1].type == T_OBJECT &&
+ ((TYPEOF(Pike_sp[-1]) == T_OBJECT &&
Pike_sp[-1].u.object == placeholder_object) ||
- (Pike_sp[-1].type == T_PROGRAM &&
+ (TYPEOF(Pike_sp[-1]) == T_PROGRAM &&
Pike_sp[-1].u.program == placeholder_program))) {
my_yyerror("Got placeholder %s (resolver problem) "
"when indexing a module with %S.",
- get_name_of_type (Pike_sp[-1].type), ident);
+ get_name_of_type (TYPEOF(Pike_sp[-1])), ident);
ret = 0;
}
else {
if(!*module_index_cache)
*module_index_cache = allocate_mapping(10);
mapping_string_insert(*module_index_cache, ident, Pike_sp-1);
ret = mksvaluenode(Pike_sp-1);
#if 0 && defined (COMPILER_DEBUG)
safe_pike_fprintf (stderr, "Index %S: %O\n", ident, Pike_sp - 1);
#endif
pike.git/src/program.c:1806:
}
if (!safe_apply_current2(PC_RESOLV_FUN_NUM, 3, NULL))
handle_compile_exception ("Error resolving '%S'.", ident);
if (Pike_compiler->compiler_pass != 2) {
/* If we get a program that hasn't gone through pass 1 yet then we
* have to register a dependency now in our pass 1 so that our
* pass 2 gets delayed. Otherwise the other program might still be
* just as unfinished when we come back here in pass 2. */
struct program *p = NULL;
- if (Pike_sp[-1].type == T_PROGRAM)
+ if (TYPEOF(Pike_sp[-1]) == T_PROGRAM)
p = Pike_sp[-1].u.program;
- else if (Pike_sp[-1].type == T_OBJECT ||
- (Pike_sp[-1].type == T_FUNCTION &&
- Pike_sp[-1].subtype != FUNCTION_BUILTIN))
+ else if (TYPEOF(Pike_sp[-1]) == T_OBJECT ||
+ (TYPEOF(Pike_sp[-1]) == T_FUNCTION &&
+ SUBTYPEOF(Pike_sp[-1]) != FUNCTION_BUILTIN))
p = Pike_sp[-1].u.object->prog;
if (p && !(p->flags & PROGRAM_PASS_1_DONE))
report_compiler_dependency (p);
}
if (Pike_compiler->compiler_pass == 2 &&
- ((Pike_sp[-1].type == T_OBJECT &&
+ ((TYPEOF(Pike_sp[-1]) == T_OBJECT &&
Pike_sp[-1].u.object == placeholder_object) ||
- (Pike_sp[-1].type == T_PROGRAM &&
+ (TYPEOF(Pike_sp[-1]) == T_PROGRAM &&
Pike_sp[-1].u.program == placeholder_program))) {
my_yyerror("Got placeholder %s (resolver problem) "
"when resolving '%S'.",
- get_name_of_type (Pike_sp[-1].type), ident);
+ get_name_of_type (TYPEOF(Pike_sp[-1])), ident);
} else {
if(!resolve_cache)
resolve_cache=dmalloc_touch(struct mapping *, allocate_mapping(10));
mapping_string_insert(resolve_cache,ident,Pike_sp-1);
if(!IS_UNDEFINED (Pike_sp-1))
{
ret=mkconstantsvaluenode(Pike_sp-1);
}
}
pike.git/src/program.c:2605:
* wait for the other threads to complete either.
*/
low_init_threads_disable();
c->compilation_depth++;
if (!Pike_compiler->compiler_frame) {
new_node_s_context();
}
- tmp.type=T_PROGRAM;
+ SET_SVAL_TYPE(tmp, T_PROGRAM);
if(!p)
{
p=low_allocate_program();
if(name)
{
tmp.u.program=p;
id=add_constant(name, &tmp, flags & ~ID_EXTERN);
#if 0
fprintf(stderr,"Compiling class %s, depth=%d\n",
name->str, c->compilation_depth);
pike.git/src/program.c:3295: Inside #if defined(PIKE_DEBUG)
}
fprintf(stderr, "\n"
"%*sConstant table:\n"
"%*s ####: Type Raw\n",
indent, "", indent, "");
for (d = 0; d < p->num_constants; d++) {
struct program_constant *c = p->constants + d;
#if 1
fprintf(stderr, "%*s %4d: %-15s %p\n",
indent, "",
- d, get_name_of_type (c->sval.type),
+ d, get_name_of_type (TYPEOF(c->sval)),
c->sval.u.ptr);
#else /* !0 */
fprintf(stderr, "%*s %4d: %-15s %"PRINTPTRDIFFT"d\n",
indent, "",
- d, get_name_of_type (c->sval.type),
+ d, get_name_of_type (TYPEOF(c->sval)),
c->offset);
#endif /* 0 */
}
fprintf(stderr, "\n"
"%*sString table:\n"
"%*s ####: Value\n",
indent, "", indent, "");
for (d = 0; d < p->num_strings; d++) {
fprintf(stderr, "%*s %4d: [%p]\"%s\"(%"PRINTPTRDIFFT"d characters)\n",
pike.git/src/program.c:3398:
if(p->storage_needed < 0)
Pike_fatal("Program->storage_needed < 0.\n");
if(p->num_identifier_index > p->num_identifier_references)
Pike_fatal("Too many identifier index entries in program!\n");
for(e=0;e<p->num_constants;e++)
{
struct svalue *s = & p->constants[e].sval;
check_svalue(s);
- if (p->flags & PROGRAM_FINISHED && s->type == T_OBJECT &&
+ if (p->flags & PROGRAM_FINISHED && TYPEOF(*s) == T_OBJECT &&
s->u.object->next == s->u.object)
Pike_fatal ("Got fake object in constant in finished program.\n");
#if 0
if(p->constants[e].name) check_string(p->constants[e].name);
#else /* ! 0 */
if (p->constants[e].offset >= p->num_identifiers) {
Pike_fatal("Constant initializer outside num_identifiers (%d >= %d).\n",
p->constants[e].offset, p->num_identifiers);
}
#endif /* 0 */
pike.git/src/program.c:4705:
add_to_identifier_references(fun);
}
}
PMOD_EXPORT void do_inherit(struct svalue *s,
INT32 flags,
struct pike_string *name)
{
struct program *p=program_from_svalue(s);
low_inherit(p,
- s->type == T_FUNCTION ? s->u.object : 0,
- s->type == T_FUNCTION ? s->subtype : -1,
+ TYPEOF(*s) == T_FUNCTION ? s->u.object : 0,
+ TYPEOF(*s) == T_FUNCTION ? SUBTYPEOF(*s) : -1,
0,
flags,
name);
}
void compiler_do_inherit(node *n,
INT32 flags,
struct pike_string *name)
{
struct program *p;
pike.git/src/program.c:4761:
continue_inherit:
/* FIXME: Support external constants. */
if(numid != IDREF_MAGIC_THIS &&
(IDENTIFIER_IS_CONSTANT((i=ID_FROM_INT(p, numid))->
identifier_flags)) &&
(i->func.const_info.offset != -1))
{
struct svalue *s=&PROG_FROM_INT(p, numid)->
constants[i->func.const_info.offset].sval;
- if(s->type != T_PROGRAM)
+ if(TYPEOF(*s) != T_PROGRAM)
{
do_inherit(s,flags,name);
return;
}else{
low_inherit(s->u.program,
0,
numid,
offset+42,
flags,
name);
pike.git/src/program.c:4813:
ref_push_string(s);
if (!TEST_COMPAT(7,6)) {
/* In Pike 7.7 and later filenames belonging to Pike are assumed
* to be encoded according to UTF-8.
*/
f_string_to_utf8(1);
}
if (safe_apply_current2(PC_HANDLE_INHERIT_FUN_NUM, 1, NULL))
- if (Pike_sp[-1].type != T_INT)
+ if (TYPEOF(Pike_sp[-1]) != T_INT)
return 1;
else {
my_yyerror("Couldn't find program %S", s);
}
else {
handle_compile_exception ("Error finding program");
}
pop_stack();
return 0;
pike.git/src/program.c:5358: Inside #if 0
if (!c) {
c = &svalue_int_zero;
}
#endif
#ifdef PIKE_DEBUG
if(name!=debug_findstring(name))
Pike_fatal("define_constant on nonshared string.\n");
if (c) {
check_svalue (c);
- if (c->type > MAX_TYPE)
+ if (TYPEOF(*c) > MAX_TYPE)
/* check_svalue allows some things like T_SVALUE_PTR. */
- Pike_fatal ("Invalid type in svalue: %d\n", c->type);
+ Pike_fatal ("Invalid type in svalue: %d\n", TYPEOF(*c));
}
#endif
n = isidentifier(name);
if(
#if 1
c &&
#endif
- c->type == T_FUNCTION &&
- c->subtype != FUNCTION_BUILTIN &&
+ TYPEOF(*c) == T_FUNCTION &&
+ SUBTYPEOF(*c) != FUNCTION_BUILTIN &&
c->u.object->prog)
{
struct program_state *state = Pike_compiler;
- struct reference *idref = PTR_FROM_INT(c->u.object->prog, c->subtype);
+ struct reference *idref = PTR_FROM_INT(c->u.object->prog, SUBTYPEOF(*c));
struct program *p = PROG_FROM_PTR(c->u.object->prog, idref);
struct identifier *id = p->identifiers + idref->identifier_offset;
int depth = 0;
while (state && (c->u.object->prog != state->new_program)) {
depth++;
state = state->previous;
}
if(state) {
/* Alias for a symbol in the current or surrounding programs.
*/
pike.git/src/program.c:5399:
c=& p->constants[id->func.const_info.offset].sval;
} else if (IDENTIFIER_IS_VARIABLE(id->identifier_flags) &&
(state == Pike_compiler)) {
my_yyerror("Attempt to make a constant %S of a variable.",
name);
c = NULL;
} else {
/* Alias for a function or a variable or constant in a surrounding
* scope.
*/
- int n = c->subtype;
+ int n = SUBTYPEOF(*c);
struct reference *remote_ref = PTR_FROM_INT(state->new_program, n);
if (!(remote_ref->id_flags & (ID_INLINE|ID_HIDDEN))) {
/* We need to get a suitable reference. */
n = really_low_reference_inherited_identifier(state, 0, n);
}
return define_alias(name, id->type, flags, depth, n);
}
}
}
pike.git/src/program.c:5434:
{
yyerror("Pass2: Constant disappeared!");
}else{
struct identifier *id;
id=ID_FROM_INT(Pike_compiler->new_program,n);
if(id->func.const_info.offset>=0) {
/* Update the stored constant. */
assign_svalue (&PROG_FROM_INT(Pike_compiler->new_program,n)->
constants[id->func.const_info.offset].sval, c);
} else {
- id->run_time_type = (unsigned char) c->type;
+ id->run_time_type = (unsigned char) TYPEOF(*c);
id->func.const_info.offset = store_constant(c, 0, 0);
}
free_type(id->type);
- if ((c->type == T_INT) && !(flags & ID_INLINE)) {
+ if ((TYPEOF(*c) == T_INT) && !(flags & ID_INLINE)) {
if (c->u.integer) {
copy_pike_type(id->type, int_type_string);
} else {
copy_pike_type(id->type, zero_type_string);
}
} else {
id->type = get_type_of_svalue(c);
}
#ifdef PROGRAM_BUILD_DEBUG
fprintf (stderr, "%.*sstored constant #%d at %d\n",
pike.git/src/program.c:5476:
#endif
copy_shared_string(dummy.name, name);
dummy.identifier_flags = IDENTIFIER_CONSTANT;
dummy.filename_strno = store_prog_string(cc->lex.current_file);
dummy.linenumber = cc->lex.current_line;
#if 1
if (c) {
#endif
- if ((c->type == T_INT) && !(flags & ID_INLINE)) {
+ if ((TYPEOF(*c) == T_INT) && !(flags & ID_INLINE)) {
if (c->u.integer) {
copy_pike_type(dummy.type, int_type_string);
} else {
copy_pike_type(dummy.type, zero_type_string);
}
} else {
dummy.type = get_type_of_svalue(c);
}
- dummy.run_time_type = (unsigned char) c->type;
+ dummy.run_time_type = (unsigned char) TYPEOF(*c);
dummy.func.const_info.offset = store_constant(c, 0, 0);
dummy.opt_flags=OPT_SIDE_EFFECT | OPT_EXTERNAL_DEPEND;
- if(c->type == PIKE_T_PROGRAM && (c->u.program->flags & PROGRAM_CONSTANT))
+ if(TYPEOF(*c) == PIKE_T_PROGRAM && (c->u.program->flags & PROGRAM_CONSTANT))
dummy.opt_flags=0;
#if 1
}
else {
copy_pike_type(dummy.type, mixed_type_string);
dummy.run_time_type=T_MIXED;
dummy.func.const_info.offset = -1;
dummy.opt_flags=0;
}
#endif
pike.git/src/program.c:5573:
ret=add_constant(id, c, flags);
free_string(id);
return ret;
}
PMOD_EXPORT int add_integer_constant(const char *name,
INT_ARG_TYPE i,
INT32 flags)
{
struct svalue tmp;
- tmp.u.integer=i;
- tmp.type=T_INT;
- tmp.subtype=NUMBER_NUMBER;
+ SET_SVAL(tmp, T_INT, NUMBER_NUMBER, integer, i);
return simple_add_constant(name, &tmp, flags);
}
PMOD_EXPORT int quick_add_integer_constant(const char *name,
int name_length,
INT_ARG_TYPE i,
INT32 flags)
{
struct svalue tmp;
struct pike_string *id;
INT32 ret;
- tmp.u.integer=i;
- tmp.type=T_INT;
- tmp.subtype=NUMBER_NUMBER;
+ SET_SVAL(tmp, T_INT, NUMBER_NUMBER, integer, i);
id=make_shared_binary_string(name,name_length);
ret=add_constant(id, &tmp, flags);
free_string(id);
return ret;
}
PMOD_EXPORT int add_float_constant(const char *name,
FLOAT_ARG_TYPE f,
INT32 flags)
{
struct svalue tmp;
- tmp.type=T_FLOAT;
- tmp.u.float_number = (FLOAT_TYPE) f;
- tmp.subtype=0;
+ SET_SVAL(tmp, T_FLOAT, 0, float_number, (FLOAT_TYPE)f);
return simple_add_constant(name, &tmp, flags);
}
PMOD_EXPORT int quick_add_float_constant(const char *name,
int name_length,
FLOAT_ARG_TYPE f,
INT32 flags)
{
struct svalue tmp;
struct pike_string *id;
INT32 ret;
- tmp.u.float_number = (FLOAT_TYPE) f;
- tmp.type=T_FLOAT;
- tmp.subtype=0;
+ SET_SVAL(tmp, T_FLOAT, 0, float_number, (FLOAT_TYPE)f);
id=make_shared_binary_string(name,name_length);
ret=add_constant(id, &tmp, flags);
free_string(id);
return ret;
}
PMOD_EXPORT int add_string_constant(const char *name,
const char *str,
INT32 flags)
{
INT32 ret;
struct svalue tmp;
- tmp.type=T_STRING;
- tmp.subtype=0;
- tmp.u.string=make_shared_string(str);
+ SET_SVAL(tmp, T_STRING, 0, string, make_shared_string(str));
ret=simple_add_constant(name, &tmp, flags);
free_svalue(&tmp);
return ret;
}
PMOD_EXPORT int add_program_constant(const char *name,
struct program *p,
INT32 flags)
{
INT32 ret;
struct svalue tmp;
if (p) {
- tmp.type=T_PROGRAM;
- tmp.subtype=0;
- tmp.u.program=p;
+ SET_SVAL(tmp, T_PROGRAM, 0, program, p);
} else {
/* Probable compilation error in a C-module. */
- tmp.type = T_INT;
- tmp.subtype = NUMBER_UNDEFINED;
- tmp.u.integer = 0;
+ SET_SVAL(tmp, T_INT, NUMBER_UNDEFINED, integer, 0);
my_yyerror("Program constant \"%s\" is NULL.", name);
}
ret=simple_add_constant(name, &tmp, flags);
return ret;
}
PMOD_EXPORT int add_object_constant(const char *name,
struct object *o,
INT32 flags)
{
INT32 ret;
struct svalue tmp;
- tmp.type=T_OBJECT;
- tmp.subtype=0;
- tmp.u.object=o;
+ SET_SVAL(tmp, T_OBJECT, 0, object, o);
ret=simple_add_constant(name, &tmp, flags);
return ret;
}
PMOD_EXPORT int add_function_constant(const char *name, void (*cfun)(INT32),
const char * type, int flags)
{
struct svalue s;
INT32 ret;
- s.type=T_FUNCTION;
- s.subtype=FUNCTION_BUILTIN;
- s.u.efun=make_callable(cfun, name, type, flags, 0, 0);
+ SET_SVAL(s, T_FUNCTION, FUNCTION_BUILTIN, efun,
+ make_callable(cfun, name, type, flags, 0, 0));
ret=simple_add_constant(name, &s, 0);
free_svalue(&s);
return ret;
}
PMOD_EXPORT int debug_end_class(const char *name, ptrdiff_t namelen, INT32 flags)
{
INT32 ret;
struct svalue tmp;
struct pike_string *id;
- tmp.type=T_PROGRAM;
- tmp.subtype=0;
- tmp.u.program=end_program();
+ SET_SVAL(tmp, T_PROGRAM, 0, program, end_program());
if(!tmp.u.program)
Pike_fatal("Failed to initialize class '%s'\n",name);
id=make_shared_binary_string(name,namelen);
ret=add_constant(id, &tmp, flags);
/* The following is not really true, but it helps encode_value()... */
Pike_compiler->new_program->flags |=
tmp.u.program->flags & PROGRAM_HAS_C_METHODS;
free_string(id);
free_svalue(&tmp);
pike.git/src/program.c:5753: Inside #if defined(PROFILING)
#ifdef PROFILING
fun.self_time=0;
fun.num_calls=0;
fun.total_time=0;
#endif
/* If this is an lfun, match against the predefined type. */
if ((lfun_type = low_mapping_string_lookup(lfun_types, name))) {
#ifdef PIKE_DEBUG
- if (lfun_type->type != T_TYPE) {
+ if (TYPEOF(*lfun_type) != T_TYPE) {
Pike_fatal("Bad entry in lfun_types for key \"%s\"\n", name->str);
}
#endif /* PIKE_DEBUG */
if (!pike_types_le(type, lfun_type->u.type)) {
int level = REPORT_NOTICE;
if (!match_types(type, lfun_type->u.type)) {
level = REPORT_ERROR;
} else if (c->lex.pragmas & ID_STRICT_TYPES) {
level = REPORT_WARNING;
}
pike.git/src/program.c:6295: Inside #if 0
return -1;
}
#endif /* 0 */
return i;
}
int lfun_lookup_id(struct pike_string *lfun_name)
{
struct svalue *id = low_mapping_string_lookup(lfun_ids, lfun_name);
if (!id) return -1;
- if (id->type == T_INT) return id->u.integer;
+ if (TYPEOF(*id) == T_INT) return id->u.integer;
my_yyerror("Bad entry in lfun lookup table for %S.", lfun_name);
return -1;
}
/*
* lookup the number of a function in a program given the name in
* a shared_string
*/
int low_find_shared_string_identifier(struct pike_string *name,
struct program *prog)
pike.git/src/program.c:6440:
JMP_BUF jmp;
if (SETJMP(jmp)) {
handle_compile_exception ("Error comparing constants.");
/* Assume that if `==() throws an error, the svalues aren't equal. */
e = Pike_compiler->new_program->num_constants;
} else {
for(e=0;e<Pike_compiler->new_program->num_constants;e++)
{
struct program_constant *c = Pike_compiler->new_program->constants+e;
- if (foo->type == c->sval.type) {
+ if (TYPEOF(*foo) == TYPEOF(c->sval)) {
/* Make sure only to compare within the same basic type. */
- if (foo->type == T_OBJECT) {
+ if (TYPEOF(*foo) == T_OBJECT) {
/* Special case objects -- We don't want strange LFUN effects... */
if ((foo->u.object == c->sval.u.object) &&
- (foo->subtype == c->sval.subtype)) {
+ (SUBTYPEOF(*foo) == SUBTYPEOF(c->sval))) {
UNSETJMP(jmp);
return e;
}
- } else if (foo->type == T_INT) {
+ } else if (TYPEOF(*foo) == T_INT) {
if (foo->u.integer == c->sval.u.integer) {
/* Make sure UNDEFINED is kept (but not in compat mode). */
- if (foo->u.integer || (foo->subtype == c->sval.subtype) ||
+ if (foo->u.integer || (SUBTYPEOF(*foo) == SUBTYPEOF(c->sval)) ||
TEST_COMPAT(7, 6)) {
UNSETJMP(jmp);
return e;
}
}
} else if(equal ? is_equal(& c->sval,foo) : is_eq(& c->sval,foo)) {
UNSETJMP(jmp);
return e;
}
}
pike.git/src/program.c:6502:
}
id = ID_FROM_INT(p, e);
if (IDENTIFIER_IS_ALIAS(id->identifier_flags)) {
/* FIXME!
*/
continue;
} else if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) {
if (id->func.const_info.offset >= 0) {
struct program *p2 = PROG_FROM_INT(p, e);
struct svalue *val = &p2->constants[id->func.const_info.offset].sval;
- if ((val->type != T_PROGRAM) ||
+ if ((TYPEOF(*val) != T_PROGRAM) ||
!(val->u.program->flags & PROGRAM_USES_PARENT)) {
ref_push_string(ID_FROM_INT(p, e)->name);
n++;
}
} else {
/* Prototype constant. */
ref_push_string(ID_FROM_INT(p, e)->name);
n++;
}
}
pike.git/src/program.c:6541:
}
id = ID_FROM_INT(p, e);
if (IDENTIFIER_IS_ALIAS(id->identifier_flags)) {
/* FIXME!
*/
continue;
} else if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) {
if (id->func.const_info.offset >= 0) {
struct program *p2 = PROG_FROM_INT(p, e);
struct svalue *val = &p2->constants[id->func.const_info.offset].sval;
- if ((val->type != T_PROGRAM) ||
+ if ((TYPEOF(*val) != T_PROGRAM) ||
!(val->u.program->flags & PROGRAM_USES_PARENT)) {
push_svalue(val);
n++;
}
} else {
/* Prototype constant. */
push_int(0);
n++;
}
}
pike.git/src/program.c:6580:
}
id = ID_FROM_INT(p, e);
if (IDENTIFIER_IS_ALIAS(id->identifier_flags)) {
/* FIXME!
*/
continue;
} else if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) {
if (id->func.const_info.offset >= 0) {
struct program *p2 = PROG_FROM_INT(p, e);
struct svalue *val = &p2->constants[id->func.const_info.offset].sval;
- if ((val->type != T_PROGRAM) ||
+ if ((TYPEOF(*val) != T_PROGRAM) ||
!(val->u.program->flags & PROGRAM_USES_PARENT)) {
ref_push_type_value(ID_FROM_INT(p, e)->type);
n++;
}
} else {
/* Prototype constant. */
ref_push_type_value(ID_FROM_INT(p, e)->type);
n++;
}
}
pike.git/src/program.c:6655:
}
}
if (IDENTIFIER_IS_CONSTANT(id->identifier_flags)) {
if (id->func.const_info.offset >= 0) {
struct program *p2 = PROG_FROM_INT(p, e);
struct svalue *val = &p2->constants[id->func.const_info.offset].sval;
assign_svalue_no_free(to, val);
} else {
/* Prototype constant. */
- to->type = T_INT;
- to->subtype = NUMBER_NUMBER;
- to->u.integer = 0;
+ SET_SVAL(*to, T_INT, NUMBER_NUMBER, integer, 0);
}
#if 0 && defined (COMPILER_DEBUG)
safe_pike_fprintf (stderr, "low_program_index_no_free2 %O->%S: %O\n",
what, s, to);
#endif
return 1;
}
return 0;
}
pike.git/src/program.c:6679:
struct svalue *ind)
{
int e;
struct pike_string *s;
struct object *parent = NULL;
struct svalue *sub = NULL;
struct program *p;
struct identifier *id;
int parent_identifier = -1;
- if (what->type == T_PROGRAM) {
+ if (TYPEOF(*what) == T_PROGRAM) {
p = what->u.program;
- } else if ((what->type == T_FUNCTION) &&
- (what->subtype != FUNCTION_BUILTIN) &&
+ } else if ((TYPEOF(*what) == T_FUNCTION) &&
+ (SUBTYPEOF(*what) != FUNCTION_BUILTIN) &&
((parent = what->u.object)->prog) &&
IDENTIFIER_IS_CONSTANT((id = ID_FROM_INT(parent->prog,
- what->subtype))->identifier_flags) &&
+ SUBTYPEOF(*what)))->identifier_flags) &&
(id->func.const_info.offset != -1) &&
- ((sub = &PROG_FROM_INT(parent->prog, what->subtype)->
- constants[id->func.const_info.offset].sval)->type == T_PROGRAM)) {
+ (TYPEOF(*(sub = &PROG_FROM_INT(parent->prog, SUBTYPEOF(*what))->
+ constants[id->func.const_info.offset].sval)) == T_PROGRAM)) {
p = sub->u.program;
- parent_identifier = what->subtype;
+ parent_identifier = SUBTYPEOF(*what);
} else {
/* Not a program. */
return 0;
}
- if (ind->type != T_STRING) {
+ if (TYPEOF(*ind) != T_STRING) {
Pike_error("Can't index a program with a %s (expected string)\n",
- get_name_of_type(ind->type));
+ get_name_of_type(TYPEOF(*ind)));
}
s = ind->u.string;
e=find_shared_string_identifier(s, p);
if(e!=-1)
{
if (low_program_index_no_free(to, p, e, parent, parent_identifier))
return 1;
}
- to->type=T_INT;
- to->subtype=NUMBER_UNDEFINED;
- to->u.integer=0;
+ SET_SVAL(*to, T_INT, NUMBER_UNDEFINED, integer, 0);
return 1;
}
/*
* Line number support routines, now also tells what file we are in.
*
* FIXME: Consider storing the filenames in strings (like what is now done
* for identifiers).
*/
pike.git/src/program.c:7501:
NULL, 0, expected_t, NULL, 0, got_t, 0, "%s", msg);
}
struct pike_string *format_exception_for_error_msg (struct svalue *thrown)
{
struct pike_string *s = NULL;
push_svalue (thrown);
SAFE_APPLY_MASTER ("describe_error", 1);
- if (sp[-1].type == T_STRING) {
+ if (TYPEOF(sp[-1]) == T_STRING) {
f_string_trim_all_whites(1);
push_constant_text("\n");
push_constant_text(" ");
f_replace(3);
return (--sp)->u.string;
}
else {
pop_stack();
return NULL;
}
pike.git/src/program.c:7985:
*! call the preprocessor manually by calling @[cpp()].
*!
*! @seealso
*! @[compile_string()], @[compile_file()], @[cpp()], @[master()],
*! @[CompilationHandler]
*/
static void f_compilation_env_compile(INT32 args)
{
apply_current(CE_PIKE_COMPILER_FUN_NUM, args);
args = 1;
- if (Pike_sp[-1].type != T_OBJECT) {
+ if (TYPEOF(Pike_sp[-1]) != T_OBJECT) {
Pike_error("Bad return value from PikeCompiler().\n");
}
apply(Pike_sp[-1].u.object, "compile", 0);
stack_pop_n_elems_keep_top(args);
}
/*! @decl mixed resolv(string identifier, string filename, @
*! object|void handler)
*/
static void f_compilation_env_resolv(INT32 args)
pike.git/src/program.c:8185:
}
if(c->placeholder) {
free_object(c->placeholder);
c->placeholder = NULL;
}
if(c->lex.current_file) {
free_string(c->lex.current_file);
c->lex.current_file = NULL;
}
free_svalue(& c->default_module);
- c->default_module.type = T_INT;
- c->default_module.subtype = NUMBER_NUMBER;
+ SET_SVAL(c->default_module, T_INT, NUMBER_NUMBER, integer, 0);
free_supporter(&c->supporter);
verify_supporters();
}
static void run_init(struct compilation *c)
{
debug_malloc_touch(c);
if (c->compat_handler) free_object(c->compat_handler);
c->compat_handler=0;
pike.git/src/program.c:8241: Inside #if 0
#if 0
int i;
struct program *p;
struct reference *refs;
#endif /* 0 */
debug_malloc_touch(c);
Pike_compiler->compiler = c;
/* Get the proper default module. */
safe_apply_current2(PC_GET_DEFAULT_MODULE_FUN_NUM, 0, NULL);
- if(Pike_sp[-1].type == T_INT)
+ if(TYPEOF(Pike_sp[-1]) == T_INT)
{
pop_stack();
ref_push_mapping(get_builtin_constants());
}
assign_svalue(&c->default_module, Pike_sp-1);
pop_stack();
use_module(& c->default_module);
Pike_compiler->compat_major=PIKE_MAJOR_VERSION;
pike.git/src/program.c:8493:
{
struct program *p = c->target;
/* Free the constants in the failed program, to untangle the
* cyclic references we might have to this program, typically
* in parent pointers in nested classes. */
if (p->constants) {
int i;
for (i = 0; i < p->num_constants; i++) {
free_svalue(&p->constants[i].sval);
- p->constants[i].sval.type = T_INT;
- p->constants[i].sval.subtype = NUMBER_NUMBER;
+ SET_SVAL(p->constants[i].sval, T_INT, NUMBER_NUMBER,
+ integer, 0);
}
}
/* We have to notify the master object that
* a previous compile() actually failed, even
* if we did not know it at the time
*/
CDFPRINTF((stderr, "th(%ld) %p unregistering failed delayed compile.\n",
(long) th_self(), p));
ref_push_program(p);
pike.git/src/program.c:8622:
switch (e) {
case PROG_EVENT_INIT:
CDFPRINTF((stderr, "th(%ld) compilation: INIT(%p).\n",
(long) th_self(), c));
MEMSET(c, 0, sizeof(*c));
c->supporter.self = Pike_fp->current_object; /* NOTE: Not ref-counted! */
c->compilation_inherit =
Pike_fp->context - Pike_fp->current_object->prog->inherits;
initialize_buf(&c->used_modules);
- add_ref(c->default_module.u.mapping = get_builtin_constants());
- c->default_module.type = T_MAPPING;
+ SET_SVAL(c->default_module, T_MAPPING, 0, mapping, get_builtin_constants());
+ add_ref(c->default_module.u.mapping);
c->major = -1;
c->minor = -1;
c->lex.current_line = 1;
c->lex.current_file = make_shared_string("-");
c->compilation_depth = -1;
break;
case PROG_EVENT_EXIT:
CDFPRINTF((stderr, "th(%ld) compilation: EXIT(%p).\n",
(long) th_self(), c));
toss_buffer(&c->used_modules);
pike.git/src/program.c:9063:
}
Pike_compiler->compat_major=major;
Pike_compiler->compat_minor=minor;
/* Optimization: The up to date compiler shouldn't need a compat handler. */
if((major != PIKE_MAJOR_VERSION) || (minor != PIKE_MINOR_VERSION))
{
apply_current(PC_GET_COMPILATION_HANDLER_FUN_NUM, args);
- if((Pike_sp[-1].type == T_OBJECT) && (Pike_sp[-1].u.object->prog))
+ if((TYPEOF(Pike_sp[-1]) == T_OBJECT) && (Pike_sp[-1].u.object->prog))
{
- if (Pike_sp[-1].subtype) {
+ if (SUBTYPEOF(Pike_sp[-1])) {
/* FIXME: */
Pike_error("Subtyped compat handlers are not supported yet.\n");
}
if (c->compat_handler == Pike_sp[-1].u.object) {
/* Still at the same compat level. */
pop_stack();
push_int(0);
return;
} else {
if(c->compat_handler) free_object(c->compat_handler);
pike.git/src/program.c:9109:
return;
}
}
STACK_LEVEL_CHECK(0);
Pike_fp->args = 0; /* Clean up the stack frame. */
apply_current(PC_GET_DEFAULT_MODULE_FUN_NUM, 0);
- if(Pike_sp[-1].type == T_INT)
+ if(TYPEOF(Pike_sp[-1]) == T_INT)
{
pop_stack();
ref_push_mapping(get_builtin_constants());
}
STACK_LEVEL_CHECK(1);
assign_svalue(&c->default_module, Pike_sp-1);
/* Replace the implicit import of all_constants() with
pike.git/src/program.c:9245:
struct svalue *a, *b;
struct compilation *c = THIS_COMPILATION;
struct pike_string *deprecated_string;
get_all_args("push_type_attribute", args, "%W%*%*", &attr, &a, &b);
if (Pike_compiler->compiler_pass == 2) {
MAKE_CONST_STRING(deprecated_string, "deprecated");
if ((attr == deprecated_string) &&
!(c->lex.pragmas & ID_NO_DEPRECATION_WARNINGS) &&
- !((a->type == PIKE_T_TYPE) && (a->u.type == zero_type_string))) {
+ !((TYPEOF(*a) == PIKE_T_TYPE) && (a->u.type == zero_type_string))) {
/* Don't warn about setting deprecated values to zero. */
push_svalue(b);
yytype_report(REPORT_WARNING, NULL, 0, NULL,
NULL, 0, NULL,
1, "Using deprecated %O value.");
}
}
pop_n_elems(args);
push_int(1);
}
pike.git/src/program.c:9302:
struct compilation *c = THIS_COMPILATION;
struct pike_string *deprecated_string;
get_all_args("apply_type_attribute", args, "%W%*.%*", &attr, &a, &b);
if (Pike_compiler->compiler_pass == 2) {
MAKE_CONST_STRING(deprecated_string, "deprecated");
if ((attr == deprecated_string) &&
!(c->lex.pragmas & ID_NO_DEPRECATION_WARNINGS) &&
(!b ||
- ((b->type == T_INT) && (b->subtype == NUMBER_UNDEFINED) &&
+ ((TYPEOF(*b) == T_INT) && (SUBTYPEOF(*b) == NUMBER_UNDEFINED) &&
(!b->u.integer)))) {
/* push_svalue(a); */
yytype_report(REPORT_WARNING, NULL, 0, NULL,
NULL, 0, NULL,
0, "Calling a deprecated value.");
}
}
pop_n_elems(args);
push_int(1);
}
pike.git/src/program.c:9361:
*! @[pop_type_attribute()], @[push_type_attribute()]
*/
static void f_compilation_apply_attribute_constant(INT32 args)
{
struct compilation *c = THIS_COMPILATION;
struct pike_string *attribute;
struct pike_string *test;
struct svalue *sval;
get_all_args("apply_attribute_constant", args, "%S%*", &attribute, &sval);
- if ((sval->type == T_INT) && !sval->u.integer) {
+ if ((TYPEOF(*sval) == T_INT) && !sval->u.integer) {
pop_n_elems(args);
push_undefined();
return;
}
MAKE_CONST_STRING(test, "sprintf_format");
if (attribute == test) {
f___handle_sprintf_format(args);
return;
}
pike.git/src/program.c:9738:
f_compilation_env_get_default_module,
tFunc(tNone, tOr(tMap(tStr, tMix), tObj)), 0);
ADD_FUNCTION("handle_inherit", f_compilation_env_handle_inherit,
tFunc(tStr tStr tOr(tObj, tVoid), tPrg(tObj)), 0);
{
struct svalue type_value;
/* enum SeverityLevel { NOTICE, WARNING, ERROR, FATAL } */
- type_value.type = PIKE_T_TYPE;
- type_value.subtype = 0;
- type_value.u.type = CONSTTYPE(tName("SeverityLevel", tInt03));
+ SET_SVAL(type_value, PIKE_T_TYPE, 0, type,
+ CONSTTYPE(tName("SeverityLevel", tInt03)));
simple_add_constant("SeverityLevel", &type_value, 0);
free_svalue(&type_value);
add_integer_constant("NOTICE", REPORT_NOTICE, 0);
add_integer_constant("WARNING", REPORT_WARNING, 0);
add_integer_constant("ERROR", REPORT_ERROR, 0);
add_integer_constant("FATAL", REPORT_FATAL, 0);
}
compilation_env_program = end_program();
pike.git/src/program.c:9796:
verify_supporters();
c->p = NULL;
add_ref(c->prog=aprog);
if((c->handler=ahandler)) add_ref(ahandler);
c->major=amajor;
c->minor=aminor;
if((c->target=atarget)) add_ref(atarget);
if((c->placeholder=aplaceholder)) add_ref(aplaceholder);
- c->default_module.type=T_INT;
- c->default_module.subtype = NUMBER_NUMBER;
+ SET_SVAL(c->default_module, T_INT, NUMBER_NUMBER, integer, 0);
if (c->handler)
{
if (safe_apply_handler ("get_default_module", c->handler, NULL,
0, BIT_MAPPING|BIT_OBJECT|BIT_ZERO)) {
if(SAFE_IS_ZERO(Pike_sp-1))
{
pop_stack();
ref_push_mapping(get_builtin_constants());
}
pike.git/src/program.c:10008:
} else {
push_int(0);
}
}
static void sprintf_trampoline (INT32 args)
{
dynamic_buffer save_buf;
dynbuf_string str;
- if (!args || sp[-args].type != T_INT || sp[-args].u.integer != 'O' ||
+ if (!args || TYPEOF(sp[-args]) != T_INT || sp[-args].u.integer != 'O' ||
!THIS->frame || !THIS->frame->current_object) {
pop_n_elems (args);
push_int (0);
return;
}
pop_n_elems (args);
ref_push_function (THIS->frame->current_object, THIS->func);
init_buf(&save_buf);
describe_svalue (sp - 1, 0, 0);
pike.git/src/program.c:10092:
void placeholder_index(INT32 args)
{
pop_n_elems(args);
ref_push_object(Pike_fp->current_object);
}
static void placeholder_sprintf (INT32 args)
{
struct pike_string *s;
- if (!args || sp[-args].type != T_INT || sp[-args].u.integer != 'O') {
+ if (!args || TYPEOF(sp[-args]) != T_INT || sp[-args].u.integer != 'O') {
pop_n_elems (args);
push_int (0);
return;
}
pop_n_elems (args);
MAKE_CONST_STRING (s, "__placeholder_object");
ref_push_string (s);
}
pike.git/src/program.c:10124:
MAKE_CONST_STRING(UNDEFINED_string,"UNDEFINED");
MAKE_CONST_STRING(parser_system_string, "parser");
MAKE_CONST_STRING(type_check_system_string, "type_check");
lfun_ids = allocate_mapping(NUM_LFUNS);
lfun_types = allocate_mapping(NUM_LFUNS);
for (i=0; i < NELEM(lfun_names); i++) {
lfun_strings[i] = make_shared_string(lfun_names[i]);
- id.type = T_INT;
- id.subtype = NUMBER_NUMBER;
- id.u.integer = i;
- key.type = T_STRING;
- key.u.string = lfun_strings[i];
+ SET_SVAL(id, T_INT, NUMBER_NUMBER, integer, i);
+ SET_SVAL(key, T_STRING, 0, string, lfun_strings[i]);
mapping_insert(lfun_ids, &key, &id);
- val.type = T_TYPE;
- val.u.type = make_pike_type(raw_lfun_types[i]);
+ SET_SVAL(val, T_TYPE, 0, type, make_pike_type(raw_lfun_types[i]));
mapping_insert(lfun_types, &key, &val);
free_type(val.u.type);
}
lfun_getter_type_string = make_pike_type(tFuncV(tNone, tVoid, tMix));
lfun_setter_type_string = make_pike_type(tFuncV(tZero, tVoid, tVoid));
compile_compiler();
enter_compiler(NULL, 0);
pike.git/src/program.c:10173:
*! that are later modified into instances of the compiled program
*! by the compiler.
*!
*! @seealso
*! @[__placeholder_object]
*/
{
struct svalue s;
debug_start_new_program(0, "__null_program");
null_program=end_program();
- s.type=T_PROGRAM;
- s.u.program=null_program;
+ SET_SVAL(s, T_PROGRAM, 0, program, null_program);
low_add_constant("__null_program",&s);
debug_malloc_touch(null_program);
}
/*! @decl constant __placeholder_object
*!
*! Object used internally by the compiler.
*!
*! @seealso
*! @[__null_program]
pike.git/src/program.c:10196:
{
struct svalue s;
start_new_program();
ADD_FUNCTION("`()", placeholder_index, tFuncV(tNone,tMix,tObj), 0);
ADD_FUNCTION("`[]", placeholder_index, tFunc(tMix,tObj), 0);
ADD_FUNCTION("_sprintf", placeholder_sprintf,
tFunc(tInt tOr(tMapping,tVoid),tStr), 0);
placeholder_program=end_program();
placeholder_object=fast_clone_object(placeholder_program);
- s.type=T_OBJECT;
- s.subtype = 0;
- s.u.object=placeholder_object;
+ SET_SVAL(s, T_OBJECT, 0, object, placeholder_object);
low_add_constant("__placeholder_object",&s);
debug_malloc_touch(placeholder_object);
}
exit_compiler();
}
void cleanup_program(void)
{
size_t e;
pike.git/src/program.c:10553:
/* Got an extra ref from gc_cycle_pop_object(). */
int e;
if(p->parent)
{
free_program(p->parent);
p->parent=0;
}
for(e=0;e<p->num_constants;e++)
{
free_svalue(& p->constants[e].sval);
- p->constants[e].sval.type=T_INT;
- p->constants[e].sval.subtype = NUMBER_NUMBER;
+ SET_SVAL(p->constants[e].sval, T_INT, NUMBER_NUMBER, integer, 0);
}
for(e=0;e<p->num_inherits;e++)
{
if(p->inherits[e].parent)
{
free_object(p->inherits[e].parent);
p->inherits[e].parent=0;
}
if(e && p->inherits[e].prog)
pike.git/src/program.c:10593:
}
#ifdef PIKE_DEBUG
if (gc_debug)
for (p = first_program; p != gc_internal_program; p = p->next) {
int e,tmp=0;
if (!p)
Pike_fatal("gc_internal_program was bogus.\n");
for(e=0;e<p->num_constants;e++)
{
- if(p->constants[e].sval.type == T_PROGRAM && p->constants[e].sval.u.program == p)
+ if(TYPEOF(p->constants[e].sval) == T_PROGRAM &&
+ p->constants[e].sval.u.program == p)
tmp++;
}
if(tmp >= p->refs)
gc_fatal(p, 1 ,"garbage collector failed to free program!!!\n");
}
#endif
return unreferenced;
}
pike.git/src/program.c:10793:
loc.o = o;
loc.inherit = INHERIT_FROM_INT(p, i);
loc.parent_identifier = i;
find_external_context(&loc, id->func.ext_ref.depth);
i = id->func.ext_ref.id + loc.inherit->identifier_level;
o = loc.o;
}
if(!IDENTIFIER_IS_CONSTANT(id->identifier_flags)) return 0;
if(id->func.const_info.offset==-1) return 0;
f = &PROG_FROM_INT(p,i)->constants[id->func.const_info.offset].sval;
- if(f->type!=T_PROGRAM) return 0;
+ if(TYPEOF(*f) != T_PROGRAM) return 0;
return f->u.program;
}
PMOD_EXPORT struct program *program_from_function(const struct svalue *f)
{
- if(f->type != T_FUNCTION) return 0;
- if(f->subtype == FUNCTION_BUILTIN) return 0;
- return low_program_from_function(f->u.object, f->subtype);
+ if(TYPEOF(*f) != T_FUNCTION) return 0;
+ if(SUBTYPEOF(*f) == FUNCTION_BUILTIN) return 0;
+ return low_program_from_function(f->u.object, SUBTYPEOF(*f));
}
/* NOTE: Does not add references to the return value! */
PMOD_EXPORT struct program *program_from_svalue(const struct svalue *s)
{
- switch(s->type)
+ switch(TYPEOF(*s))
{
case T_OBJECT:
{
struct program *p = s->u.object->prog;
#if 0
int call_fun;
#endif
if (!p) return 0;
#if 0
- p = p->inherits[s->subtype].prog;
+ p = p->inherits[SUBTYPEOF(*s)].prog;
if ((call_fun = FIND_LFUN(p, LFUN_CALL)) >= 0) {
/* Get the program from the return type. */
struct identifier *id = ID_FROM_INT(p, call_fun);
/* FIXME: do it. */
return 0;
}
#endif
push_svalue(s);
f_object_program(1);
p=program_from_svalue(Pike_sp-1);