Skip to content
Snippets Groups Projects
Commit 8ba896ad authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Cleaned up {low_,}get_f_name() somewhat.

Rev: src/opcodes.c:1.158
parent a25f3f4c
No related branches found
No related tags found
No related merge requests found
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
|| This file is part of Pike. For copyright information see COPYRIGHT. || This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information. || for more information.
|| $Id: opcodes.c,v 1.157 2003/11/14 10:12:29 mast Exp $ || $Id: opcodes.c,v 1.158 2003/11/15 16:40:04 grubba Exp $
*/ */
#include "global.h" #include "global.h"
RCSID("$Id: opcodes.c,v 1.157 2003/11/14 10:12:29 mast Exp $"); RCSID("$Id: opcodes.c,v 1.158 2003/11/15 16:40:04 grubba Exp $");
#include "constants.h" #include "constants.h"
#include "interpret.h" #include "interpret.h"
#include "opcodes.h" #include "opcodes.h"
...@@ -297,56 +297,31 @@ char *low_get_f_name(int n,struct program *p) ...@@ -297,56 +297,31 @@ char *low_get_f_name(int n,struct program *p)
{ {
static char buf[30]; static char buf[30];
if (n<F_MAX_OPCODE && instrs[n-F_OFFSET].name) if (n<F_MAX_OPCODE)
{ {
if ((n >= 0) && instrs[n-F_OFFSET].name)
return instrs[n-F_OFFSET].name; return instrs[n-F_OFFSET].name;
}else if(n >= F_MAX_OPCODE) { sprintf(buf, "<OTHER %d>", n);
return buf;
}
if(p && if(p &&
(int)p->num_constants > (int)(n-F_MAX_OPCODE) && (int)p->num_constants > (int)(n-F_MAX_OPCODE) &&
p->constants[n-F_MAX_OPCODE].sval.type==T_FUNCTION && p->constants[n-F_MAX_OPCODE].sval.type==T_FUNCTION &&
(p->constants[n-F_MAX_OPCODE].sval.subtype == FUNCTION_BUILTIN) && (p->constants[n-F_MAX_OPCODE].sval.subtype == FUNCTION_BUILTIN) &&
p->constants[n-F_MAX_OPCODE].sval.u.efun) p->constants[n-F_MAX_OPCODE].sval.u.efun) {
{
return p->constants[n-F_MAX_OPCODE].sval.u.efun->name->str; return p->constants[n-F_MAX_OPCODE].sval.u.efun->name->str;
}else{
sprintf(buf, "Call efun %d", n - F_MAX_OPCODE);
return buf;
} }
}else{
sprintf(buf, "<OTHER %d>", n); sprintf(buf, "Call efun %d", n - F_MAX_OPCODE);
return buf; return buf;
} }
}
char *get_f_name(int n) char *get_f_name(int n)
{ {
static char buf[30]; if (Pike_fp && Pike_fp->context.prog)
if (n<F_MAX_OPCODE && instrs[n-F_OFFSET].name) return low_get_f_name(n, Pike_fp->context.prog);
{ return low_get_f_name(n, NULL);
return instrs[n-F_OFFSET].name;
}else if(n >= F_MAX_OPCODE) {
if(Pike_fp && Pike_fp->context.prog &&
(int)Pike_fp->context.prog->num_constants > (int)(n-F_MAX_OPCODE) &&
Pike_fp->context.prog->constants[n-F_MAX_OPCODE].sval.type==T_FUNCTION &&
Pike_fp->context.prog->constants[n-F_MAX_OPCODE].sval.subtype == FUNCTION_BUILTIN &&
Pike_fp->context.prog->constants[n-F_MAX_OPCODE].sval.u.efun)
{
return Pike_fp->
context.prog->
constants[n-F_MAX_OPCODE]
.sval
.u
.efun->
name->
str;
}else{
sprintf(buf, "Call efun %d", n - F_MAX_OPCODE);
return buf;
}
}else{
sprintf(buf, "<OTHER %d>", n);
return buf;
}
} }
#ifdef HAVE_COMPUTED_GOTO #ifdef HAVE_COMPUTED_GOTO
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment