2004-05-19
2004-05-19 09:19:13 by Henrik Grubbström (Grubba) <grubba@grubba.org>
-
aeed27c748d7480092d737a9c12a6c3e4bacbfe0
(52 lines)
(+37/-15)
[
Show
| Annotate
]
Branch: 7.9
Added ID_ENTRY_TYPE_CONSTANT.
Rev: src/encode.c:1.215
2:
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
- || $Id: encode.c,v 1.214 2004/05/12 14:58:29 grubba Exp $
+ || $Id: encode.c,v 1.215 2004/05/19 09:19:13 grubba Exp $
*/
#include "global.h"
31:
#include "opcodes.h"
#include "peep.h"
- RCSID("$Id: encode.c,v 1.214 2004/05/12 14:58:29 grubba Exp $");
+ RCSID("$Id: encode.c,v 1.215 2004/05/19 09:19:13 grubba Exp $");
/* #define ENCODE_DEBUG */
111:
#define COUNTER_START (-MAX_SMALL)
/* Entries used to encode the identifier_references table. */
+ #define ID_ENTRY_TYPE_CONSTANT -4
#define ID_ENTRY_EFUN_CONSTANT -3
#define ID_ENTRY_RAW -2
#define ID_ENTRY_EOT -1
1248: Inside #if defined(PIKE_PORTABLE_BYTECODE)
/* constants */
for(d=0;d<p->num_constants;d++)
{
- if ((p->constants[d].sval.type != T_FUNCTION) ||
- (p->constants[d].sval.subtype != FUNCTION_BUILTIN)) {
+ if ((p->constants[d].sval.type == T_FUNCTION) &&
+ (p->constants[d].sval.subtype == FUNCTION_BUILTIN)) {
+ code_number(ID_ENTRY_EFUN_CONSTANT, data);
+ } else if (p->constants[d].sval.type == T_TYPE) {
+ code_number(ID_ENTRY_TYPE_CONSTANT, data);
+ } else {
continue;
}
- code_number(ID_ENTRY_EFUN_CONSTANT, data);
+
code_number(d, data);
/* value */
encode_value2(&p->constants[d].sval, data, 0);
1563:
for(d=0;d<p->num_constants;d++)
{
#ifdef PIKE_PORTABLE_BYTECODE
- if ((p->constants[d].sval.type == T_FUNCTION) &&
- (p->constants[d].sval.subtype == FUNCTION_BUILTIN)) {
+ if (((p->constants[d].sval.type == T_FUNCTION) &&
+ (p->constants[d].sval.subtype == FUNCTION_BUILTIN)) ||
+ (p->constants[d].sval.type == T_TYPE)) {
/* Already encoded above. */
continue;
}
3574: Inside #if defined(ENCODE_DEBUG)
#ifdef ENCODE_DEBUG
data->depth+=2;
#endif
- while (entry_type == ID_ENTRY_EFUN_CONSTANT) {
+ while ((entry_type == ID_ENTRY_EFUN_CONSTANT) ||
+ (entry_type == ID_ENTRY_TYPE_CONSTANT)) {
INT32 efun_no;
struct program_constant *constant;
decode_number(efun_no, data);
EDB(2,
- fprintf(stderr, "%*sDecoding efun constant #%d.\n",
+ fprintf(stderr, "%*sDecoding efun/type constant #%d.\n",
data->depth, "", efun_no));
if ((efun_no < 0) || (efun_no >= local_num_constants)) {
ref_push_program (p);
decode_error(Pike_sp - 1, NULL,
- "Bad efun number: %d (expected 0 - %d).\n",
+ "Bad efun/type number: %d (expected 0 - %d).\n",
efun_no, local_num_constants-1);
}
constant = p->constants+efun_no;
/* value */
decode_value2(data);
-
+ switch(entry_type) {
+ case ID_ENTRY_EFUN_CONSTANT:
if ((Pike_sp[-1].type != T_FUNCTION) ||
(Pike_sp[-1].subtype != FUNCTION_BUILTIN)) {
ref_push_program (p);
decode_error(Pike_sp - 1, Pike_sp - 2,
"Expected efun constant: ");
}
-
+ break;
+ case ID_ENTRY_TYPE_CONSTANT:
+ if (Pike_sp[-1].type != T_TYPE) {
+ ref_push_program (p);
+ decode_error(Pike_sp - 1, Pike_sp - 2,
+ "Expected type constant: ");
+ }
+ break;
+ default:
+ Pike_error("Internal error: Unsupported early constant (%d)\n",
+ entry_type);
+ break;
+ }
/* name */
decode_value2(data);
if (Pike_sp[-1].type == T_STRING) {