e576bb | 2002-10-11 | Martin Nilsson | |
|
aedfb1 | 2002-10-09 | Martin Nilsson | |
|
f90e54 | 1995-08-17 | Fredrik Hübinette (Hubbe) | | #include "global.h"
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #include "las.h"
#include "program.h"
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | #include "pike_types.h"
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #include "stralloc.h"
#include "interpret.h"
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | #include "constants.h"
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #include "array.h"
|
bb55f8 | 1997-03-16 | Fredrik Hübinette (Hubbe) | | #include "pike_macros.h"
|
b2d3e4 | 2000-12-01 | Fredrik Hübinette (Hubbe) | | #include "pike_error.h"
|
d3fa6e | 1998-05-17 | Henrik Grubbström (Grubba) | | #include "pike_memory.h"
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #include "svalue.h"
|
1a26b2 | 2004-12-30 | Henrik Grubbström (Grubba) | | #include "pike_embed.h"
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | #include "builtin_functions.h"
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | #include "peep.h"
#include "docode.h"
|
419fab | 1997-03-09 | Fredrik Hübinette (Hubbe) | | #include "operators.h"
|
6d2254 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | #include "object.h"
|
f76b4c | 2000-05-11 | Henrik Grubbström (Grubba) | | #include "opcodes.h"
#include "lex.h"
|
5e4442 | 2001-02-25 | Fredrik Hübinette (Hubbe) | | #include "mapping.h"
#include "multiset.h"
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | #include "pike_compiler.h"
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
7e877a | 2003-04-02 | Martin Stjernholm | | static int do_docode2(node *n, int flags);
|
b07918 | 1998-04-27 | Fredrik Hübinette (Hubbe) | |
|
6c8ada | 2001-01-14 | Martin Stjernholm | | typedef void (*cleanup_func)(void *);
struct cleanup_frame
{
struct cleanup_frame *prev;
cleanup_func cleanup;
void *cleanup_arg;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | int stack_depth;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | };
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | struct statement_label_name
{
struct statement_label_name *next;
struct pike_string *str;
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | INT_TYPE line_number;
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | };
struct statement_label
{
struct statement_label *prev;
struct statement_label_name *name;
|
6c8ada | 2001-01-14 | Martin Stjernholm | |
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | INT32 break_label, continue_label;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | int emit_break_label;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | int stack_depth;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | struct cleanup_frame *cleanups;
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | };
|
6c8ada | 2001-01-14 | Martin Stjernholm | |
static struct statement_label top_statement_label_dummy =
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | {0, 0, -1, -1, 0, -1, 0};
|
6c8ada | 2001-01-14 | Martin Stjernholm | | static struct statement_label *current_label = &top_statement_label_dummy;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | #ifdef PIKE_DEBUG
static int current_stack_depth = -4711;
#else
static int current_stack_depth = 0;
#endif
|
6c8ada | 2001-01-14 | Martin Stjernholm | |
#define PUSH_CLEANUP_FRAME(func, arg) do { \
struct cleanup_frame cleanup_frame__; \
cleanup_frame__.cleanup = (cleanup_func) (func); \
cleanup_frame__.cleanup_arg = (void *)(ptrdiff_t) (arg); \
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | cleanup_frame__.stack_depth = current_stack_depth; \
|
6c8ada | 2001-01-14 | Martin Stjernholm | | DO_IF_DEBUG( \
if (current_label->cleanups == (void *)(ptrdiff_t) -1) \
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("current_label points to an unused statement_label.\n"); \
|
6c8ada | 2001-01-14 | Martin Stjernholm | | ) \
if (current_label->break_label == -2) { \
DO_IF_DEBUG( \
if (current_label->prev->break_label == -2) \
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Found two open statement_label entries in a row.\n"); \
|
6c8ada | 2001-01-14 | Martin Stjernholm | | ) \
cleanup_frame__.prev = current_label->prev->cleanups; \
current_label->prev->cleanups = &cleanup_frame__; \
} \
else { \
cleanup_frame__.prev = current_label->cleanups; \
current_label->cleanups = &cleanup_frame__; \
}
#define POP_AND_DONT_CLEANUP \
if (current_label->cleanups == &cleanup_frame__) \
current_label->cleanups = cleanup_frame__.prev; \
else { \
DO_IF_DEBUG( \
if (current_label->prev->cleanups != &cleanup_frame__) \
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Cleanup frame lost from statement_label cleanup list.\n");\
|
6c8ada | 2001-01-14 | Martin Stjernholm | | ) \
current_label->prev->cleanups = cleanup_frame__.prev; \
} \
} while (0)
#define POP_AND_DO_CLEANUP \
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | do_pop(current_stack_depth - cleanup_frame__.stack_depth); \
|
6c8ada | 2001-01-14 | Martin Stjernholm | | cleanup_frame__.cleanup(cleanup_frame__.cleanup_arg); \
POP_AND_DONT_CLEANUP
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | |
|
1544fd | 2001-01-31 | Martin Stjernholm | |
#ifdef PIKE_DEBUG
#define BLOCK_BEGIN \
PUSH_CLEANUP_FRAME(do_cleanup_synch_mark, 0); \
if (d_flag > 2) emit0(F_SYNCH_MARK);
#define BLOCK_END \
if (current_stack_depth != cleanup_frame__.stack_depth) { \
print_tree(n); \
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Stack not in synch after block: is %d, should be %d.\n", \
|
1544fd | 2001-01-31 | Martin Stjernholm | | current_stack_depth, cleanup_frame__.stack_depth); \
} \
if (d_flag > 2) emit0(F_POP_SYNCH_MARK); \
POP_AND_DONT_CLEANUP
#else
#define BLOCK_BEGIN
#define BLOCK_END
#endif
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | #define PUSH_STATEMENT_LABEL do { \
struct statement_label new_label__; \
new_label__.prev = current_label; \
|
6c8ada | 2001-01-14 | Martin Stjernholm | | if (current_label->break_label != -2) { \
/* Only cover the current label if it's closed. */ \
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | new_label__.name = 0; \
new_label__.break_label = new_label__.continue_label = -1; \
|
e9ebb7 | 2001-01-15 | Martin Stjernholm | | new_label__.emit_break_label = 0; \
|
6c8ada | 2001-01-14 | Martin Stjernholm | | new_label__.cleanups = 0; \
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | new_label__.stack_depth = current_stack_depth; \
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | current_label = &new_label__; \
} \
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | else { \
DO_IF_DEBUG( \
new_label__.cleanups = (void *)(ptrdiff_t) -1; \
new_label__.stack_depth = current_stack_depth; \
) \
current_label->stack_depth = current_stack_depth; \
}
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | |
#define POP_STATEMENT_LABEL \
current_label = new_label__.prev; \
|
6c8ada | 2001-01-14 | Martin Stjernholm | | DO_IF_DEBUG( \
if (new_label__.cleanups && \
new_label__.cleanups != (void *)(ptrdiff_t) -1) \
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Cleanup frames still left in statement_label.\n")); \
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | } while (0)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | struct switch_data
{
INT32 index;
INT32 less_label, greater_label, default_label;
INT32 values_on_stack;
INT32 *jumptable;
struct pike_type *type;
};
static struct switch_data current_switch = {0, 0, 0, 0, 0, NULL, NULL};
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | void upd_int(int offset, INT32 tmp)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | MEMCPY(Pike_compiler->new_program->program+offset, (char *)&tmp,sizeof(tmp));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | INT32 read_int(int offset)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | return EXTRACT_INT(Pike_compiler->new_program->program+offset);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | static int label_no=0;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
be478c | 1997-08-30 | Henrik Grubbström (Grubba) | | int alloc_label(void) { return ++label_no; }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | int do_jump(int token,INT32 lbl)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | if(lbl==-1) lbl=alloc_label();
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit1(token, lbl);
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | return lbl;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | |
#define LBLCACHESIZE 4711
#define CURRENT_INSTR ((long)instrbuf.s.len / (long)sizeof(p_instr))
#define MAX_UNWIND 100
static int lbl_cache[LBLCACHESIZE];
|
8b6256 | 2006-02-25 | Martin Stjernholm | | static int do_branch(INT32 lbl)
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | if(lbl==-1)
{
lbl=alloc_label();
}else{
INT32 last,pos=lbl_cache[lbl % LBLCACHESIZE];
if(pos < (last=CURRENT_INSTR) && (CURRENT_INSTR - pos) < MAX_UNWIND)
{
#define BUF ((p_instr *)instrbuf.s.str)
if(BUF[pos].opcode == F_LABEL && BUF[pos].arg == lbl)
{
for(;pos < last;pos++)
{
if(BUF[pos].opcode != F_LABEL)
{
insert_opcode2(BUF[pos].opcode,
BUF[pos].arg,
BUF[pos].arg2,
BUF[pos].line,
BUF[pos].file);
}
}
}
}
}
emit1(F_BRANCH, lbl);
return lbl;
}
|
8b6256 | 2006-02-25 | Martin Stjernholm | | static void low_insert_label(int lbl)
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | lbl_cache[ lbl % LBLCACHESIZE ] = CURRENT_INSTR;
emit1(F_LABEL, lbl);
}
|
8b6256 | 2006-02-25 | Martin Stjernholm | | static int ins_label(int lbl)
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | {
if(lbl==-1) lbl=alloc_label();
low_insert_label(lbl);
return lbl;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
1493c5 | 2008-08-28 | Henrik Grubbström (Grubba) | | void modify_stack_depth(int delta)
{
current_stack_depth += delta;
#ifdef PIKE_DEBUG
if (current_stack_depth < 0) {
Pike_fatal("Popped out of virtual stack.\n");
}
#endif
}
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | void do_pop(int x)
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | #ifdef PIKE_DEBUG
|
5aad93 | 2002-08-15 | Marcus Comstedt | | if (x < 0) Pike_fatal("Cannot do pop of %d args.\n", x);
|
6c8ada | 2001-01-14 | Martin Stjernholm | | #endif
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | switch(x)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | case 0: return;
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | case 1: emit0(F_POP_VALUE); break;
default: emit1(F_POP_N_ELEMS,x); break;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | current_stack_depth -= x;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
66d51c | 1997-03-04 | Fredrik Hübinette (Hubbe) | |
|
57ed3f | 2012-12-30 | Jonas Walldén | | static void do_pop_mark(void *UNUSED(ignored))
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | emit0(F_POP_MARK);
}
|
57ed3f | 2012-12-30 | Jonas Walldén | | static void do_pop_to_mark(void *UNUSED(ignored))
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | emit0(F_POP_TO_MARK);
}
|
1d6ca2 | 2008-06-30 | Martin Stjernholm | | #ifdef PIKE_DEBUG
|
8b6256 | 2006-02-25 | Martin Stjernholm | | static void do_cleanup_synch_mark(void)
|
1544fd | 2001-01-31 | Martin Stjernholm | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
1544fd | 2001-01-31 | Martin Stjernholm | | if (d_flag > 2)
emit0(F_CLEANUP_SYNCH_MARK);
}
|
1d6ca2 | 2008-06-30 | Martin Stjernholm | | #endif
|
1544fd | 2001-01-31 | Martin Stjernholm | |
|
8b6256 | 2006-02-25 | Martin Stjernholm | | static void do_escape_catch(void)
|
f181de | 2001-01-11 | Martin Stjernholm | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
f181de | 2001-01-11 | Martin Stjernholm | | emit0(F_ESCAPE_CATCH);
}
|
1544fd | 2001-01-31 | Martin Stjernholm | | #define DO_CODE_BLOCK(X) do_pop(do_docode((X),DO_NOT_COPY | DO_POP ))
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
7e877a | 2003-04-02 | Martin Stjernholm | | int do_docode(node *n, int flags)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
int i;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | int stack_depth_save = current_stack_depth;
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | INT_TYPE save_current_line = c->lex.current_line;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | if(!n) return 0;
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | c->lex.current_line=n->line_number;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | #ifdef PIKE_DEBUG
|
5aad93 | 2002-08-15 | Marcus Comstedt | | if (current_stack_depth == -4711) Pike_fatal("do_docode() used outside docode().\n");
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | #endif
|
0b8458 | 2007-10-06 | Henrik Grubbström (Grubba) | | i=do_docode2(n, flags);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | current_stack_depth = stack_depth_save + i;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | c->lex.current_line=save_current_line;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return i;
}
|
419fab | 1997-03-09 | Fredrik Hübinette (Hubbe) | | static int is_efun(node *n, c_fun fun)
{
return n && n->token == F_CONSTANT &&
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | SUBTYPEOF(n->u.sval) == FUNCTION_BUILTIN &&
|
419fab | 1997-03-09 | Fredrik Hübinette (Hubbe) | | n->u.sval.u.efun->function == fun;
}
|
7e877a | 2003-04-02 | Martin Stjernholm | | static void code_expression(node *n, int flags, char *err)
|
c64e8a | 1997-04-17 | Fredrik Hübinette (Hubbe) | | {
|
0b8458 | 2007-10-06 | Henrik Grubbström (Grubba) | | switch(do_docode(n, flags & ~DO_POP))
|
c64e8a | 1997-04-17 | Fredrik Hübinette (Hubbe) | | {
case 0: my_yyerror("Void expression for %s",err);
case 1: return;
case 2:
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Internal compiler error (%s), line %ld, file %s\n",
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | err,
(long)THIS_COMPILATION->lex.current_line,
THIS_COMPILATION->lex.current_file->str);
|
c64e8a | 1997-04-17 | Fredrik Hübinette (Hubbe) | | }
}
|
97410c | 2014-05-08 | Per Hedbor | | static void do_cond_jump(node *n, int label, int iftrue, int flags)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | iftrue=!!iftrue;
if((flags & DO_POP) && node_is_tossable(n))
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | int t,f;
t=!!node_is_true(n);
f=!!node_is_false(n);
if(t || f)
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | {
|
f181de | 2001-01-11 | Martin Stjernholm | | if(t == iftrue) do_branch( label);
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | return;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | switch(n->token)
{
|
419fab | 1997-03-09 | Fredrik Hübinette (Hubbe) | | case F_LAND:
case F_LOR:
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | if(iftrue == (n->token==F_LAND))
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | {
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | int tmp=alloc_label();
do_cond_jump(CAR(n), tmp, !iftrue, flags | DO_POP);
do_cond_jump(CDR(n), label, iftrue, flags);
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | low_insert_label(tmp);
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | }else{
do_cond_jump(CAR(n), label, iftrue, flags);
do_cond_jump(CDR(n), label, iftrue, flags);
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | }
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | return;
|
419fab | 1997-03-09 | Fredrik Hübinette (Hubbe) | | case F_APPLY:
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | if(!is_efun(CAR(n), f_not)) break;
|
419fab | 1997-03-09 | Fredrik Hübinette (Hubbe) | |
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | case F_NOT:
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | if(!(flags & DO_POP)) break;
do_cond_jump(CDR(n), label , !iftrue, flags | DO_NOT_COPY);
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | return;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
7e877a | 2003-04-02 | Martin Stjernholm | | code_expression(n, flags | DO_NOT_COPY, "condition");
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | |
if(flags & DO_POP)
{
if(iftrue)
do_jump(F_BRANCH_WHEN_NON_ZERO, label);
else
do_jump(F_BRANCH_WHEN_ZERO, label);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | current_stack_depth--;
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | }else{
if(iftrue)
do_jump(F_LOR, label);
else
do_jump(F_LAND, label);
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | #define do_jump_when_zero(N,L) do_cond_jump(N,L,0,DO_POP|DO_NOT_COPY)
#define do_jump_when_non_zero(N,L) do_cond_jump(N,L,1,DO_POP|DO_NOT_COPY)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | static INT32 count_cases(node *n)
{
INT32 ret;
if(!n) return 0;
switch(n->token)
{
case F_DO:
case F_FOR:
case F_FOREACH:
|
cb76e8 | 2001-01-14 | Henrik Grubbström (Grubba) | | case F_LOOP:
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | case F_INC_LOOP:
case F_DEC_LOOP:
case F_INC_NEQ_LOOP:
case F_DEC_NEQ_LOOP:
case F_SWITCH:
case '?':
return 0;
case F_CASE:
|
9abda4 | 2002-03-02 | Martin Stjernholm | | return 1;
case F_CASE_RANGE:
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return !!CAR(n)+!!CDR(n);
default:
ret=0;
if(car_is_node(n)) ret += count_cases(CAR(n));
if(cdr_is_node(n)) ret += count_cases(CDR(n));
return ret;
}
}
|
4f20e9 | 2001-01-25 | Fredrik Hübinette (Hubbe) | |
int generate_call_function(node *n)
{
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
4f20e9 | 2001-01-25 | Fredrik Hübinette (Hubbe) | | emit0(F_MARK);
PUSH_CLEANUP_FRAME(do_pop_mark, 0);
do_docode(CDR(n),DO_NOT_COPY);
emit0(F_CALL_FUNCTION);
POP_AND_DONT_CLEANUP;
return 1;
}
|
97410c | 2014-05-08 | Per Hedbor | | static struct compiler_frame *find_local_frame(INT32 depth)
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | struct compiler_frame *f=Pike_compiler->compiler_frame;
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | while(--depth>=0) f=f->previous;
return f;
}
|
5e5a59 | 2002-11-14 | Henrik Grubbström (Grubba) | |
|
8b6256 | 2006-02-25 | Martin Stjernholm | | static int do_lfun_call(int id, node *args)
|
6fd517 | 2000-04-25 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
5e5a59 | 2002-11-14 | Henrik Grubbström (Grubba) | | struct reference *ref =
Pike_compiler->new_program->identifier_references + id;
|
cd7384 | 2014-08-07 | Per Hedbor | | if((Pike_compiler->compiler_frame->current_function_number >= 0) &&
((id == Pike_compiler->compiler_frame->current_function_number) ||
((!ref->inherit_offset) &&
(ref->identifier_offset ==
Pike_compiler->new_program->
identifier_references[Pike_compiler->compiler_frame->
current_function_number].identifier_offset))) &&
!(Pike_compiler->new_program->
identifiers[ref->identifier_offset].identifier_flags &
(IDENTIFIER_VARARGS|IDENTIFIER_SCOPE_USED)) &&
!(Pike_compiler->compiler_frame->lexical_scope & SCOPE_SCOPE_USED))
{
PUSH_CLEANUP_FRAME(do_pop_mark, 0);
emit0(F_MARK);
do_docode(args,0);
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | |
|
191854 | 2002-11-22 | Henrik Grubbström (Grubba) | | |
f5cfc3 | 2002-11-23 | Martin Stjernholm | | *
|
2bc170 | 2008-07-14 | Henrik Grubbström (Grubba) | | * * Check that the function isn't varargs or contains scoped functions.
*
* * Check that the current function doesn't contain scoped functions.
|
191854 | 2002-11-22 | Henrik Grubbström (Grubba) | | */
|
cd7384 | 2014-08-07 | Per Hedbor | | if(Pike_compiler->compiler_frame->is_inline || (ref->id_flags & (ID_INLINE|ID_PRIVATE)))
|
6fd517 | 2000-04-25 | Fredrik Hübinette (Hubbe) | | {
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | |
|
cd7384 | 2014-08-07 | Per Hedbor | | if ((ref->id_flags & (ID_INLINE|ID_PRIVATE)) &&
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | | (!Pike_compiler->compiler_frame->is_inline)) {
|
5e5a59 | 2002-11-14 | Henrik Grubbström (Grubba) | | */
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | | do_jump(F_RECUR, 0);
|
5e5a59 | 2002-11-14 | Henrik Grubbström (Grubba) | | } else {
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | | Pike_compiler->compiler_frame->recur_label =
do_jump(F_RECUR, Pike_compiler->compiler_frame->recur_label);
|
6fd517 | 2000-04-25 | Fredrik Hübinette (Hubbe) | | }
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | | } else {
emit1(F_COND_RECUR,id);
Pike_compiler->compiler_frame->recur_label =
do_jump(F_POINTER, Pike_compiler->compiler_frame->recur_label);
|
6fd517 | 2000-04-25 | Fredrik Hübinette (Hubbe) | | }
|
cd7384 | 2014-08-07 | Per Hedbor | | POP_AND_DONT_CLEANUP;
return 1;
}
else {
#ifdef USE_APPLY_N
int nargs = count_args(args);
if( nargs == -1 )
{
#endif
PUSH_CLEANUP_FRAME(do_pop_mark, 0);
emit0(F_MARK);
do_docode(args,0);
emit1(F_CALL_LFUN, id);
POP_AND_DONT_CLEANUP;
return 1;
#ifdef USE_APPLY_N
}
else
{
do_docode(args,0);
emit2(F_CALL_LFUN_N, id, nargs);
}
#endif
|
6fd517 | 2000-04-25 | Fredrik Hübinette (Hubbe) | | }
return 1;
}
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | |
static void emit_apply_builtin(char *func)
{
INT32 tmp1;
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | struct pike_string *n1=make_shared_string(func);
node *n=find_module_identifier(n1,0);
free_string(n1);
switch(n?n->token:0)
{
case F_CONSTANT:
tmp1=store_constant(&n->u.sval,
|
515bcf | 2002-07-02 | Henrik Grubbström (Grubba) | | !(n->tree_info & OPT_EXTERNAL_DEPEND),
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | n->name);
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if(TYPEOF(n->u.sval) == T_FUNCTION &&
SUBTYPEOF(n->u.sval) == FUNCTION_BUILTIN)
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | emit1(F_CALL_BUILTIN, DO_NOT_WARN((INT32)tmp1));
else
emit1(F_APPLY, DO_NOT_WARN((INT32)tmp1));
break;
default:
my_yyerror("docode: Failed to make call to %s",func);
}
free_node(n);
}
static int do_encode_automap_arg_list(node *n,
|
7e877a | 2003-04-02 | Martin Stjernholm | | int flags)
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | int stack_depth_save = current_stack_depth;
if(!n) return 0;
switch(n->token)
{
default:
return do_docode(n, flags);
case F_ARG_LIST:
{
int ret;
ret=do_encode_automap_arg_list(CAR(n), flags);
current_stack_depth=stack_depth_save + ret;
ret+=do_encode_automap_arg_list(CDR(n), flags);
current_stack_depth=stack_depth_save + ret;
return ret;
}
case F_AUTO_MAP_MARKER:
{
int depth=0;
while(n->token == F_AUTO_MAP_MARKER)
{
n=CAR(n);
depth++;
}
emit0(F_MARK);
code_expression(n, 0, "[*]");
emit1(F_NUMBER, depth);
emit_apply_builtin("__builtin.automap_marker");
return 1;
}
}
}
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | static void emit_builtin_svalue(char *func)
{
INT32 tmp1;
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | struct pike_string *n1=make_shared_string(func);
node *n=find_module_identifier(n1,0);
free_string(n1);
switch(n?n->token:0)
{
case F_CONSTANT:
tmp1=store_constant(&n->u.sval,
|
515bcf | 2002-07-02 | Henrik Grubbström (Grubba) | | (!(n->tree_info & OPT_EXTERNAL_DEPEND)) &&
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | (TYPEOF(n->u.sval) != T_TYPE),
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | n->name);
emit1(F_CONSTANT, DO_NOT_WARN((INT32)tmp1));
break;
default:
my_yyerror("docode: Failed to make svalue for builtin %s",func);
}
free_node(n);
}
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | |
|
408a1e | 2004-10-30 | Martin Stjernholm | | static void emit_range (node *n DO_IF_DEBUG (COMMA int num_args))
{
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
408a1e | 2004-10-30 | Martin Stjernholm | | node *low = CADR (n), *high = CDDR (n);
|
5c390e | 2013-02-06 | Henrik Grubbström (Grubba) | | int bound_types = 0;
|
408a1e | 2004-10-30 | Martin Stjernholm | |
switch (low->token) {
case F_RANGE_FROM_BEG: bound_types = RANGE_LOW_FROM_BEG; break;
case F_RANGE_FROM_END: bound_types = RANGE_LOW_FROM_END; break;
case F_RANGE_OPEN: bound_types = RANGE_LOW_OPEN; break;
#ifdef PIKE_DEBUG
default:
Pike_fatal ("Unexpected node %d as range lower bound.\n", low->token);
#endif
}
switch (high->token) {
case F_RANGE_FROM_BEG: bound_types |= RANGE_HIGH_FROM_BEG; break;
case F_RANGE_FROM_END: bound_types |= RANGE_HIGH_FROM_END; break;
case F_RANGE_OPEN: bound_types |= RANGE_HIGH_OPEN; break;
#ifdef PIKE_DEBUG
default:
Pike_fatal ("Unexpected node %d as range upper bound.\n", high->token);
#endif
}
#ifdef PIKE_DEBUG
{
|
0b8458 | 2007-10-06 | Henrik Grubbström (Grubba) | | int expected_args = 0;
|
408a1e | 2004-10-30 | Martin Stjernholm | | switch (bound_types & (RANGE_LOW_OPEN|RANGE_HIGH_OPEN)) {
case 0:
expected_args = 2; break;
case RANGE_LOW_OPEN:
case RANGE_HIGH_OPEN:
expected_args = 1; break;
case RANGE_LOW_OPEN|RANGE_HIGH_OPEN:
expected_args = 0; break;
}
if (num_args != expected_args)
Pike_fatal ("Wrong number of args to o_range opcode. Expected %d, got %d.\n",
expected_args, num_args);
}
#endif
emit1 (F_RANGE, bound_types);
}
|
b63e28 | 2014-08-07 | Per Hedbor | | static void emit_global( int n )
{
struct compilation *c = THIS_COMPILATION;
struct reference *ref = PTR_FROM_INT(Pike_compiler->new_program, n);
struct identifier *id = ID_FROM_PTR(Pike_compiler->new_program, ref);
if( (ref->id_flags & (ID_PRIVATE|ID_FINAL))
&& !(id->identifier_flags & IDENTIFIER_NO_THIS_REF)
&& IDENTIFIER_IS_VARIABLE(id->identifier_flags)
&& !ref->inherit_offset
&& id->run_time_type == PIKE_T_MIXED )
{
emit1(F_PRIVATE_GLOBAL, id->func.offset);
}
else
emit1(F_GLOBAL, n);
}
static void emit_assign_global( int n, int and_pop )
{
struct compilation *c = THIS_COMPILATION;
struct reference *ref = PTR_FROM_INT(Pike_compiler->new_program, n);
struct identifier *id = ID_FROM_PTR(Pike_compiler->new_program, ref);
if( (ref->id_flags & (ID_PRIVATE|ID_FINAL))
&& !(id->identifier_flags & IDENTIFIER_NO_THIS_REF)
&& !ref->inherit_offset
&& id->run_time_type == PIKE_T_MIXED )
{
emit1((and_pop?F_ASSIGN_PRIVATE_GLOBAL_AND_POP:F_ASSIGN_PRIVATE_GLOBAL),
id->func.offset);
}
else
{
emit1((and_pop?F_ASSIGN_GLOBAL_AND_POP:F_ASSIGN_GLOBAL), n);
}
}
|
13cdf2 | 2008-01-28 | Henrik Grubbström (Grubba) | | static void emit_multi_assign(node *vals, node *vars, int no)
{
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
13cdf2 | 2008-01-28 | Henrik Grubbström (Grubba) | | node *var;
node *val;
node **valp = my_get_arg(&vals, no);
if (!vars && (!valp || !*valp)) return;
if (!(vars && valp && (val = *valp))) {
yyerror("Argument count mismatch for multi-assignment.\n");
return;
}
if (vars->token == F_LVALUE_LIST) {
var = CAR(vars);
vars = CDR(vars);
} else {
var = vars;
vars = NULL;
}
switch(var->token) {
case F_LOCAL:
if(var->u.integer.a >=
|
27404b | 2008-01-29 | Henrik Grubbström (Grubba) | | find_local_frame(var->u.integer.b)->max_number_of_locals)
|
13cdf2 | 2008-01-28 | Henrik Grubbström (Grubba) | | yyerror("Illegal to use local variable here.");
if(var->u.integer.b) goto normal_assign;
if (var->node_info & OPT_ASSIGNMENT) {
emit0(F_CONST0);
emit1(F_ASSIGN_LOCAL_AND_POP, var->u.integer.a);
}
code_expression(val, 0, "RHS");
emit_multi_assign(vals, vars, no+1);
emit1(F_ASSIGN_LOCAL_AND_POP, var->u.integer.a );
break;
case F_IDENTIFIER:
if(!IDENTIFIER_IS_VARIABLE( ID_FROM_INT(Pike_compiler->new_program,
var->u.id.number)->identifier_flags))
{
yyerror("Cannot assign functions or constants.\n");
}else{
code_expression(val, 0, "RHS");
emit_multi_assign(vals, vars, no+1);
|
b63e28 | 2014-08-07 | Per Hedbor | | emit_assign_global( var->u.id.number, 1 );
|
13cdf2 | 2008-01-28 | Henrik Grubbström (Grubba) | | }
break;
case F_GET_SET:
{
struct program_state *state = Pike_compiler;
int program_id = var->u.integer.a;
int level = 0;
while (state && (state->new_program->id != program_id)) {
state = state->previous;
level++;
}
if (!state) {
yyerror("Lost parent.");
} else {
struct reference *ref =
PTR_FROM_INT(state->new_program, var->u.integer.b);
struct identifier *id =
ID_FROM_PTR(state->new_program, ref);
struct inherit *inh =
INHERIT_FROM_PTR(state->new_program, ref);
int f;
#ifdef PIKE_DEBUG
if (!IDENTIFIER_IS_VARIABLE(id->identifier_flags) ||
(id->run_time_type != PIKE_T_GET_SET)) {
Pike_fatal("Not a getter/setter in a F_GET_SET node!\n"
" identifier_flags: 0x%08x\n"
" run_time_type; %s (%d)\n",
id->identifier_flags,
get_name_of_type(id->run_time_type),
id->run_time_type);
}
#endif /* PIKE_DEBUG */
|
85e455 | 2008-05-13 | Henrik Grubbström (Grubba) | | f = id->func.gs_info.setter;
|
13cdf2 | 2008-01-28 | Henrik Grubbström (Grubba) | | if (f == -1) {
yywarning("Variable %S lacks a setter.", id->name);
} else if (!level) {
f += inh->identifier_level;
emit0(F_MARK);
code_expression(val, 0, "RHS");
emit_multi_assign(vals, vars, no+1);
emit1(F_CALL_LFUN, f);
emit0(F_POP_VALUE);
}
}
}
case F_EXTERNAL:
if(Pike_compiler ->new_program->id == var->u.integer.a)
{
if(var->u.integer.b != IDREF_MAGIC_THIS &&
IDENTIFIER_IS_VARIABLE( ID_FROM_INT(Pike_compiler->new_program, var->u.integer.b)->identifier_flags))
{
code_expression(val, 0, "RHS");
emit_multi_assign(vals, vars, no+1);
|
b63e28 | 2014-08-07 | Per Hedbor | | emit_assign_global( var->u.integer.b, 1 );
|
13cdf2 | 2008-01-28 | Henrik Grubbström (Grubba) | | break;
}
}
default:
normal_assign:
do_docode(var, DO_LVALUE);
if(do_docode(val, 0) != 1) yyerror("RHS is void!");
emit_multi_assign(vals, vars, no+1);
emit0(F_ASSIGN_AND_POP);
break;
}
}
|
7e877a | 2003-04-02 | Martin Stjernholm | | static int do_docode2(node *n, int flags)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
e0755c | 2000-08-15 | Henrik Grubbström (Grubba) | | ptrdiff_t tmp1,tmp2,tmp3;
|
57c287 | 2003-09-19 | Henrik Grubbström (Grubba) | | int ret;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
if(!n) return 0;
if(flags & DO_LVALUE)
{
switch(n->token)
{
|
2a3269 | 1998-01-31 | Fredrik Hübinette (Hubbe) | | default:
yyerror("Illegal lvalue.");
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit1(F_NUMBER,0);
emit1(F_NUMBER,0);
|
fb05b6 | 1998-02-27 | Fredrik Hübinette (Hubbe) | | return 2;
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | |
|
2a3269 | 1998-01-31 | Fredrik Hübinette (Hubbe) | | case F_ARRAY_LVALUE:
case F_LVALUE_LIST:
case F_LOCAL:
case F_GLOBAL:
case F_IDENTIFIER:
case F_INDEX:
case F_ARROW:
case F_ARG_LIST:
|
3d7882 | 1999-11-06 | Henrik Grubbström (Grubba) | | case F_COMMA_EXPR:
|
2a3269 | 1998-01-31 | Fredrik Hübinette (Hubbe) | | case F_EXTERNAL:
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | case F_GET_SET:
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | case F_AUTO_MAP_MARKER:
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | | break;
}
}
if(flags & DO_LVALUE_IF_POSSIBLE)
{
flags|=DO_INDIRECT;
flags &=~DO_LVALUE_IF_POSSIBLE;
}else{
flags &=~DO_INDIRECT;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
f9abcf | 1999-09-16 | Fredrik Hübinette (Hubbe) | |
{
|
c7241b | 2000-08-10 | Henrik Grubbström (Grubba) | | ptrdiff_t x_= ((char *)&x_) + STACK_DIRECTION * (32768) -
Pike_interpreter.stack_top ;
|
f9abcf | 1999-09-16 | Fredrik Hübinette (Hubbe) | | x_*=STACK_DIRECTION;
if(x_>0)
{
|
d0844b | 1999-09-19 | Henrik Grubbström (Grubba) | | yyerror("Too deep recursion in compiler. (please report this)");
|
f9abcf | 1999-09-16 | Fredrik Hübinette (Hubbe) | |
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit1(F_NUMBER,0);
|
f9abcf | 1999-09-16 | Fredrik Hübinette (Hubbe) | | if(flags & DO_LVALUE)
{
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit1(F_NUMBER,0);
|
f9abcf | 1999-09-16 | Fredrik Hübinette (Hubbe) | | return 2;
}
return 1;
}
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | switch(n->token)
{
|
624f57 | 1999-03-11 | Fredrik Hübinette (Hubbe) | | case F_MAGIC_INDEX:
case F_MAGIC_SET_INDEX:
|
cbe113 | 2001-12-16 | Martin Stjernholm | | case F_MAGIC_INDICES:
case F_MAGIC_VALUES:
|
7195af | 2011-01-15 | Henrik Grubbström (Grubba) | | case F_MAGIC_TYPES:
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit2(n->token,
n->u.node.b->u.sval.u.integer,
n->u.node.a->u.sval.u.integer);
|
624f57 | 1999-03-11 | Fredrik Hübinette (Hubbe) | | return 1;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | case F_EXTERNAL:
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | case F_GET_SET:
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | {
|
ff88db | 2000-07-12 | Henrik Grubbström (Grubba) | | int level = 0;
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | struct program_state *state = Pike_compiler;
|
ff88db | 2000-07-12 | Henrik Grubbström (Grubba) | | while (state && (state->new_program->id != n->u.integer.a)) {
|
afb16a | 2010-11-11 | Henrik Grubbström (Grubba) | | if ((flags & WANT_LVALUE) ||
(n->node_info & (OPT_EXTERNAL_DEPEND|OPT_NOT_CONST))) {
state->new_program->flags |=
PROGRAM_USES_PARENT | PROGRAM_NEEDS_PARENT;
}
|
ff88db | 2000-07-12 | Henrik Grubbström (Grubba) | | state = state->previous;
level++;
}
if (!state) {
my_yyerror("Program parent %d lost during compiling.", n->u.integer.a);
emit1(F_NUMBER,0);
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | } else if (flags & WANT_LVALUE) {
if (n->u.integer.b == IDREF_MAGIC_THIS) {
my_yyerror("this is not an lvalue.");
}
if (level) {
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | emit2(F_EXTERNAL_LVALUE, n->u.integer.b, level);
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | } else {
emit1(F_GLOBAL_LVALUE, n->u.integer.b);
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | }
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | return 2;
} else {
struct reference *ref =
PTR_FROM_INT(state->new_program, n->u.integer.b);
struct identifier *id =
ID_FROM_PTR(state->new_program, ref);
if (n->token == F_GET_SET) {
struct inherit *inh =
INHERIT_FROM_PTR(state->new_program, ref);
int f;
#ifdef PIKE_DEBUG
if (!IDENTIFIER_IS_VARIABLE(id->identifier_flags) ||
(id->run_time_type != PIKE_T_GET_SET)) {
Pike_fatal("Not a getter/setter in a F_GET_SET node!\n"
" identifier_flags: 0x%08x\n"
" run_time_type; %s (%d)\n",
id->identifier_flags,
get_name_of_type(id->run_time_type),
id->run_time_type);
|
57306e | 2004-12-18 | Henrik Grubbström (Grubba) | | }
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | #endif /* PIKE_DEBUG */
|
85e455 | 2008-05-13 | Henrik Grubbström (Grubba) | | f = id->func.gs_info.getter;
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | if (f == -1) {
yywarning("Variable %S lacks a getter.", id->name);
} else if (!level) {
return do_lfun_call(f + inh->identifier_level, NULL);
} else {
emit2(F_EXTERNAL, n->u.integer.b, level);
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | }
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | } else if (level) {
|
83128f | 2010-07-01 | Henrik Grubbström (Grubba) | | if (IDENTIFIER_IS_CONSTANT(id->identifier_flags) &&
|
717401 | 2013-11-10 | Henrik Grubbström (Grubba) | | (ref->id_flags & ID_INLINE) &&
|
89378b | 2010-11-23 | Henrik Grubbström (Grubba) | | (id->func.const_info.offset >= 0)) {
|
83128f | 2010-07-01 | Henrik Grubbström (Grubba) | |
|
05c373 | 2010-07-04 | Henrik Grubbström (Grubba) | | struct svalue *s = &state->new_program->
|
717401 | 2013-11-10 | Henrik Grubbström (Grubba) | | inherits[ref->inherit_offset].prog->
|
89378b | 2010-11-23 | Henrik Grubbström (Grubba) | | constants[id->func.const_info.offset].sval;
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if (TYPEOF(*s) == T_PROGRAM &&
|
05c373 | 2010-07-04 | Henrik Grubbström (Grubba) | | s->u.program->flags & PROGRAM_USES_PARENT) {
emit2(F_EXTERNAL, n->u.integer.b, level);
} else {
int tmp1 = store_constant(s, 1, NULL);
emit1(F_CONSTANT, tmp1);
}
|
83128f | 2010-07-01 | Henrik Grubbström (Grubba) | | } else {
|
717401 | 2013-11-10 | Henrik Grubbström (Grubba) | | struct program_state *state = Pike_compiler;
int e;
for (e = level; e; e--) {
state->new_program->flags |=
PROGRAM_USES_PARENT|PROGRAM_NEEDS_PARENT;
state = state->previous;
}
|
83128f | 2010-07-01 | Henrik Grubbström (Grubba) | | emit2(F_EXTERNAL, n->u.integer.b, level);
}
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | } else if (n->u.integer.b == IDREF_MAGIC_THIS) {
emit1(F_THIS_OBJECT, 0);
} else if(IDENTIFIER_IS_FUNCTION(id->identifier_flags) &&
id->identifier_flags & IDENTIFIER_HAS_BODY)
{
emit1(F_LFUN, n->u.integer.b);
|
83128f | 2010-07-01 | Henrik Grubbström (Grubba) | | } else if (IDENTIFIER_IS_CONSTANT(id->identifier_flags) &&
|
cd7384 | 2014-08-07 | Per Hedbor | | (ref->id_flags & (ID_INLINE|ID_PRIVATE)) && !ref->inherit_offset &&
|
89378b | 2010-11-23 | Henrik Grubbström (Grubba) | | (id->func.const_info.offset >= 0)) {
|
83128f | 2010-07-01 | Henrik Grubbström (Grubba) | |
|
05c373 | 2010-07-04 | Henrik Grubbström (Grubba) | | struct svalue *s = &state->new_program->
|
89378b | 2010-11-23 | Henrik Grubbström (Grubba) | | constants[id->func.const_info.offset].sval;
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if (TYPEOF(*s) == T_PROGRAM &&
|
05c373 | 2010-07-04 | Henrik Grubbström (Grubba) | | s->u.program->flags & PROGRAM_USES_PARENT) {
emit1(F_LFUN, n->u.integer.b);
} else {
|
89378b | 2010-11-23 | Henrik Grubbström (Grubba) | | emit1(F_CONSTANT, id->func.const_info.offset);
|
05c373 | 2010-07-04 | Henrik Grubbström (Grubba) | | }
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | }else{
|
b63e28 | 2014-08-07 | Per Hedbor | | emit_global( n->u.integer.b );
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | }
|
ff88db | 2000-07-12 | Henrik Grubbström (Grubba) | | }
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | }
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | return 1;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
57306e | 2004-12-18 | Henrik Grubbström (Grubba) | | case F_THIS:
{
int level = 0;
struct program_state *state = Pike_compiler;
int inh = n->u.integer.b;
while (state && (state->new_program->id != n->u.integer.a)) {
state = state->previous;
level++;
}
if (!state) {
my_yyerror("Program parent %d lost during compiling.", n->u.integer.a);
emit1(F_NUMBER,0);
|
388e5d | 2008-05-30 | Henrik Grubbström (Grubba) | | } else if (!level && (inh < 0)) {
|
57306e | 2004-12-18 | Henrik Grubbström (Grubba) | | emit1(F_THIS_OBJECT, 0);
} else {
emit2(F_THIS, level, inh);
}
return 1;
}
break;
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | case F_UNDEFINED:
yyerror("Undefined identifier");
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit1(F_NUMBER,0);
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | return 1;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | case F_PUSH_ARRAY: {
if (current_label != &top_statement_label_dummy || current_label->cleanups) {
#ifdef PIKE_DEBUG
if (!current_label->cleanups ||
(current_label->cleanups->cleanup != do_pop_mark &&
current_label->cleanups->cleanup != do_pop_to_mark))
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("F_PUSH_ARRAY unexpected in this context.\n");
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | #endif
current_label->cleanups->cleanup = do_pop_to_mark;
}
|
c64e8a | 1997-04-17 | Fredrik Hübinette (Hubbe) | | code_expression(CAR(n), 0, "`@");
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_PUSH_ARRAY);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | return 0;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
02f17a | 2007-12-17 | Henrik Grubbström (Grubba) | | case F_APPEND_ARRAY: {
emit0(F_MARK);
PUSH_CLEANUP_FRAME(do_pop_mark, 0);
do_docode(CAR(n),DO_LVALUE);
emit0(F_CONST0);
do_docode(CDR(n),0);
emit0(F_APPEND_ARRAY);
POP_AND_DONT_CLEANUP;
return 1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | case '?':
{
|
9abda4 | 2002-03-02 | Martin Stjernholm | | INT32 *prev_switch_jumptable = current_switch.jumptable;
|
9d6152 | 1996-08-03 | Fredrik Hübinette (Hubbe) | | int adroppings , bdroppings;
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable=0;
|
2e4e45 | 1997-02-13 | Fredrik Hübinette (Hubbe) | |
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | if(!CDDR(n))
{
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | tmp1=alloc_label();
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | do_jump_when_zero(CAR(n), DO_NOT_WARN((INT32)tmp1));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | DO_CODE_BLOCK(CADR(n));
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | low_insert_label( DO_NOT_WARN((INT32)tmp1));
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable = prev_switch_jumptable;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
}
if(!CADR(n))
{
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | tmp1=alloc_label();
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | do_jump_when_non_zero(CAR(n), DO_NOT_WARN((INT32)tmp1));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | DO_CODE_BLOCK(CDDR(n));
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | low_insert_label( DO_NOT_WARN((INT32)tmp1));
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable = prev_switch_jumptable;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
}
|
a7622c | 1996-08-06 | Fredrik Hübinette (Hubbe) | | tmp1=alloc_label();
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | do_jump_when_zero(CAR(n), DO_NOT_WARN((INT32)tmp1));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9d6152 | 1996-08-03 | Fredrik Hübinette (Hubbe) | | adroppings=do_docode(CADR(n), flags);
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | tmp3=emit1(F_POP_N_ELEMS,0);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9d6152 | 1996-08-03 | Fredrik Hübinette (Hubbe) | |
|
f181de | 2001-01-11 | Martin Stjernholm | | tmp2=do_branch(-1);
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | low_insert_label( DO_NOT_WARN((INT32)tmp1));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9d6152 | 1996-08-03 | Fredrik Hübinette (Hubbe) | | bdroppings=do_docode(CDDR(n), flags);
if(adroppings < bdroppings)
{
do_pop(bdroppings - adroppings);
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9d6152 | 1996-08-03 | Fredrik Hübinette (Hubbe) | | if(adroppings > bdroppings)
{
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | update_arg(DO_NOT_WARN((INT32)tmp3),
adroppings - bdroppings);
|
9d6152 | 1996-08-03 | Fredrik Hübinette (Hubbe) | | adroppings=bdroppings;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | low_insert_label( DO_NOT_WARN((INT32)tmp2));
|
2e4e45 | 1997-02-13 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable = prev_switch_jumptable;
|
9d6152 | 1996-08-03 | Fredrik Hübinette (Hubbe) | | return adroppings;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
case F_AND_EQ:
case F_OR_EQ:
case F_XOR_EQ:
case F_LSH_EQ:
case F_RSH_EQ:
case F_ADD_EQ:
case F_SUB_EQ:
case F_MULT_EQ:
case F_MOD_EQ:
case F_DIV_EQ:
|
90739c | 2011-02-08 | Henrik Grubbström (Grubba) | | if((CAR(n) && CAR(n)->token == F_AUTO_MAP_MARKER) ||
(CDR(n) && CDR(n)->token == F_AUTO_MAP_MARKER))
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | char *opname;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | if(CAR(n)->token == F_AUTO_MAP_MARKER)
{
int depth=0;
node *tmp=CAR(n);
while(tmp->token == F_AUTO_MAP_MARKER)
|
a2b70a | 2000-04-30 | Fredrik Hübinette (Hubbe) | | {
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | depth++;
tmp=CAR(tmp);
|
a2b70a | 2000-04-30 | Fredrik Hübinette (Hubbe) | | }
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | tmp1=do_docode(tmp,DO_LVALUE);
emit0(F_MARK);
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | emit0(F_MARK);
emit0(F_LTOSVAL);
emit1(F_NUMBER,depth);
emit_apply_builtin("__builtin.automap_marker");
}else{
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | tmp1=do_docode(CAR(n),DO_LVALUE);
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | emit0(F_LTOSVAL);
}
switch(n->token)
{
case F_ADD_EQ: opname="`+"; break;
case F_AND_EQ: opname="`&"; break;
case F_OR_EQ: opname="`|"; break;
case F_XOR_EQ: opname="`^"; break;
case F_LSH_EQ: opname="`<<"; break;
case F_RSH_EQ: opname="`>>"; break;
case F_SUB_EQ: opname="`-"; break;
case F_MULT_EQ:opname="`*"; break;
case F_MOD_EQ: opname="`%"; break;
case F_DIV_EQ: opname="`/"; break;
default:
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Really???\n");
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | opname="`make gcc happy";
}
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | emit_builtin_svalue(opname);
emit2(F_REARRANGE,1,1);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | if(CDR(n)->token == F_AUTO_MAP)
{
do_encode_automap_arg_list(CDR(n), 0);
}else{
code_expression(CDR(n), 0, "assignment");
}
emit_apply_builtin("__automap__");
}else{
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | tmp1=do_docode(CAR(n),DO_LVALUE);
#ifdef PIKE_DEBUG
if(tmp1 != 2)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("HELP! FATAL INTERNAL COMPILER ERROR (7)\n");
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | #endif
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | if(n->token == F_ADD_EQ && (flags & DO_POP))
{
code_expression(CDR(n), 0, "assignment");
emit0(F_ADD_TO_AND_POP);
return 0;
}
if(CAR(n)->token != F_AUTO_MAP &&
(match_types(CAR(n)->type, array_type_string) ||
match_types(CAR(n)->type, string_type_string) ||
match_types(CAR(n)->type, mapping_type_string) ||
match_types(CAR(n)->type, object_type_string)))
{
code_expression(CDR(n), 0, "assignment");
|
403a53 | 2010-10-01 | Martin Stjernholm | | emit0(F_LTOSVAL2_AND_FREE);
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | | }else{
emit0(F_LTOSVAL);
code_expression(CDR(n), 0, "assignment");
}
switch(n->token)
{
case F_ADD_EQ:
if(CAR(n)->type == int_type_string &&
CDR(n)->type == int_type_string)
{
emit0(F_ADD_INTS);
}
else if(CAR(n)->type == float_type_string &&
CDR(n)->type == float_type_string)
{
emit0(F_ADD_FLOATS);
}else{
emit0(F_ADD);
}
break;
case F_AND_EQ: emit0(F_AND); break;
case F_OR_EQ: emit0(F_OR); break;
case F_XOR_EQ: emit0(F_XOR); break;
case F_LSH_EQ: emit0(F_LSH); break;
case F_RSH_EQ: emit0(F_RSH); break;
case F_SUB_EQ: emit0(F_SUBTRACT); break;
case F_MULT_EQ:emit0(F_MULTIPLY);break;
case F_MOD_EQ: emit0(F_MOD); break;
case F_DIV_EQ: emit0(F_DIVIDE); break;
}
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | if(flags & DO_POP)
{
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_ASSIGN_AND_POP);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
}else{
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_ASSIGN);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 1;
}
|
13cdf2 | 2008-01-28 | Henrik Grubbström (Grubba) | | case F_MULTI_ASSIGN:
if (flags & DO_POP) {
emit_multi_assign(CAR(n), CDR(n), 0);
return 0;
} else {
tmp1=do_docode(CDR(n),DO_LVALUE);
#ifdef PIKE_DEBUG
if(tmp1 & 1)
Pike_fatal("Very internal compiler error.\n");
#endif
emit1(F_ARRAY_LVALUE, DO_NOT_WARN((INT32)(tmp1>>1)));
emit0(F_MARK);
PUSH_CLEANUP_FRAME(do_pop_mark, 0);
do_docode(CAR(n), 0);
emit_apply_builtin("aggregate");
POP_AND_DONT_CLEANUP;
emit0(F_ASSIGN);
return 1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | case F_ASSIGN:
switch(CAR(n)->token)
{
|
b99ff8 | 2001-06-07 | Fredrik Hübinette (Hubbe) | | case F_RANGE:
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | case F_AND:
case F_OR:
case F_XOR:
case F_LSH:
case F_RSH:
case F_ADD:
case F_MOD:
case F_SUBTRACT:
case F_DIVIDE:
case F_MULTIPLY:
if(node_is_eq(CDR(n),CAAR(n)))
{
|
b63e28 | 2014-08-07 | Per Hedbor | | int num_args;
|
babd87 | 2001-02-23 | Henrik Grubbström (Grubba) | | if(match_types(CDR(n)->type, array_type_string) ||
|
c87cfa | 2001-06-07 | Fredrik Hübinette (Hubbe) | | match_types(CDR(n)->type, string_type_string) ||
|
ab952d | 2001-06-07 | Fredrik Hübinette (Hubbe) | | match_types(CDR(n)->type, object_type_string) ||
|
c87cfa | 2001-06-07 | Fredrik Hübinette (Hubbe) | | match_types(CDR(n)->type, multiset_type_string) ||
match_types(CDR(n)->type, mapping_type_string))
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
b63e28 | 2014-08-07 | Per Hedbor | | do_docode(CDR(n),DO_LVALUE);
|
0b8458 | 2007-10-06 | Henrik Grubbström (Grubba) | | num_args = do_docode(CDAR(n), 0);
|
408a1e | 2004-10-30 | Martin Stjernholm | | switch (num_args)
|
b99ff8 | 2001-06-07 | Fredrik Hübinette (Hubbe) | | {
|
403a53 | 2010-10-01 | Martin Stjernholm | | case 0: emit0(F_LTOSVAL_AND_FREE); break;
case 1: emit0(F_LTOSVAL2_AND_FREE); break;
case 2: emit0(F_LTOSVAL3_AND_FREE); break;
|
b99ff8 | 2001-06-07 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
default:
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Arglebargle glop-glyf?\n");
|
b99ff8 | 2001-06-07 | Fredrik Hübinette (Hubbe) | | #endif
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }else{
|
b63e28 | 2014-08-07 | Per Hedbor | | goto do_not_suboptimize_assign;
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_LTOSVAL);
|
0b8458 | 2007-10-06 | Henrik Grubbström (Grubba) | | num_args = do_docode(CDAR(n), 0);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
408a1e | 2004-10-30 | Martin Stjernholm | | if (CAR (n)->token == F_RANGE)
emit_range (CAR (n) DO_IF_DEBUG (COMMA num_args));
else
emit0(CAR(n)->token);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(n->token);
|
403a53 | 2010-10-01 | Martin Stjernholm | | return n->token==F_ASSIGN;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
27404b | 2008-01-29 | Henrik Grubbström (Grubba) | | case F_APPLY:
if ((CAAR(n)->token == F_CONSTANT) &&
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | (TYPEOF(CAAR(n)->u.sval) == T_FUNCTION) &&
(SUBTYPEOF(CAAR(n)->u.sval) == FUNCTION_BUILTIN) &&
|
dcbf33 | 2008-01-29 | Henrik Grubbström (Grubba) | | (CAAR(n)->u.sval.u.efun->function != f_map) &&
(CAAR(n)->u.sval.u.efun->function != f_filter)) {
|
27404b | 2008-01-29 | Henrik Grubbström (Grubba) | |
node *args = CDAR(n);
|
7d8f64 | 2014-08-08 | Per Hedbor | | if (args && count_args(args) > 1)
{
|
dcbf33 | 2008-01-29 | Henrik Grubbström (Grubba) | | node **arg = my_get_arg(&args, 0);
|
47c898 | 2008-03-22 | Henrik Grubbström (Grubba) | | if (arg && node_is_eq(CDR(n), *arg) &&
!(args->tree_info & OPT_ASSIGNMENT)) {
|
b63e28 | 2014-08-07 | Per Hedbor | | if(match_types(CDR(n)->type, array_type_string) ||
match_types(CDR(n)->type, string_type_string) ||
match_types(CDR(n)->type, object_type_string) ||
match_types(CDR(n)->type, multiset_type_string) ||
match_types(CDR(n)->type, mapping_type_string))
{
int no = 0;
tmp1 = do_docode(CDR(n), DO_LVALUE);
emit0(F_MARK_AND_CONST0);
PUSH_CLEANUP_FRAME(do_pop_mark, 0);
while ((arg = my_get_arg(&args, ++no)) && *arg) {
do_docode(*arg, 0);
}
tmp1=store_constant(&CAAR(n)->u.sval,
!(CAAR(n)->tree_info & OPT_EXTERNAL_DEPEND),
CAAR(n)->name);
emit1(F_LTOSVAL_CALL_BUILTIN_AND_ASSIGN, DO_NOT_WARN((INT32)tmp1));
POP_AND_DONT_CLEANUP;
return 1;
}
}
|
27404b | 2008-01-29 | Henrik Grubbström (Grubba) | | }
}
|
85e455 | 2008-05-13 | Henrik Grubbström (Grubba) | |
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | default:
|
b63e28 | 2014-08-07 | Per Hedbor | | do_not_suboptimize_assign:
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | switch(CDR(n)->token)
{
|
b63e28 | 2014-08-07 | Per Hedbor | | case F_GLOBAL:
if(CDR(n)->u.integer.b) goto normal_assign;
code_expression(CAR(n), 0, "RHS");
emit_assign_global( CDR(n)->u.integer.a, flags & DO_POP );
break;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | case F_LOCAL:
|
b63e28 | 2014-08-07 | Per Hedbor | | if(CDR(n)->u.integer.a >=
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | find_local_frame(CDR(n)->u.integer.b)->max_number_of_locals)
|
a8ef6e | 1996-12-03 | Fredrik Hübinette (Hubbe) | | yyerror("Illegal to use local variable here.");
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | if(CDR(n)->u.integer.b) goto normal_assign;
|
c98166 | 2006-03-02 | Henrik Grubbström (Grubba) | | if (CDR(n)->node_info & OPT_ASSIGNMENT) {
emit0(F_CONST0);
emit1(F_ASSIGN_LOCAL_AND_POP, CDR(n)->u.integer.a);
}
|
c64e8a | 1997-04-17 | Fredrik Hübinette (Hubbe) | | code_expression(CAR(n), 0, "RHS");
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit1(flags & DO_POP ? F_ASSIGN_LOCAL_AND_POP:F_ASSIGN_LOCAL,
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | CDR(n)->u.integer.a );
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | break;
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | |
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | case F_IDENTIFIER:
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(!IDENTIFIER_IS_VARIABLE( ID_FROM_INT(Pike_compiler->new_program, CDR(n)->u.id.number)->identifier_flags))
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | {
|
d2c608 | 1996-11-07 | Fredrik Hübinette (Hubbe) | | yyerror("Cannot assign functions or constants.\n");
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | }else{
|
c64e8a | 1997-04-17 | Fredrik Hübinette (Hubbe) | | code_expression(CAR(n), 0, "RHS");
|
b63e28 | 2014-08-07 | Per Hedbor | | emit_assign_global( CDR(n)->u.id.number, flags & DO_POP );
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | break;
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | case F_GET_SET:
{
struct program_state *state = Pike_compiler;
int program_id = CDR(n)->u.integer.a;
int level = 0;
while (state && (state->new_program->id != program_id)) {
state = state->previous;
level++;
}
if (!state) {
yyerror("Lost parent.");
} else {
struct reference *ref =
PTR_FROM_INT(state->new_program, CDR(n)->u.integer.b);
struct identifier *id =
ID_FROM_PTR(state->new_program, ref);
struct inherit *inh =
INHERIT_FROM_PTR(state->new_program, ref);
int f;
#ifdef PIKE_DEBUG
if (!IDENTIFIER_IS_VARIABLE(id->identifier_flags) ||
(id->run_time_type != PIKE_T_GET_SET)) {
Pike_fatal("Not a getter/setter in a F_GET_SET node!\n"
" identifier_flags: 0x%08x\n"
" run_time_type; %s (%d)\n",
id->identifier_flags,
get_name_of_type(id->run_time_type),
id->run_time_type);
}
#endif /* PIKE_DEBUG */
|
85e455 | 2008-05-13 | Henrik Grubbström (Grubba) | | f = id->func.gs_info.setter;
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | if (f == -1) {
yywarning("Variable %S lacks a setter.", id->name);
} else if (!level) {
f += inh->identifier_level;
if (flags & DO_POP) {
|
cd7384 | 2014-08-07 | Per Hedbor | | #ifndef USE_APPLY_N
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | emit0(F_MARK);
|
cd7384 | 2014-08-07 | Per Hedbor | | #endif
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | code_expression(CAR(n), 0, "RHS");
} else {
code_expression(CAR(n), 0, "RHS");
|
cd7384 | 2014-08-07 | Per Hedbor | | #ifndef USE_APPLY_N
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | emit0(F_MARK);
|
cd7384 | 2014-08-07 | Per Hedbor | | #endif
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | emit0(F_DUP);
}
|
cd7384 | 2014-08-07 | Per Hedbor | | #ifdef USE_APPLY_N
emit2(F_CALL_LFUN_N, f, 1);
#else
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | emit1(F_CALL_LFUN, f);
|
cd7384 | 2014-08-07 | Per Hedbor | | #endif
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | emit0(F_POP_VALUE);
return !(flags & DO_POP);
}
}
}
|
57f316 | 2001-06-29 | Fredrik Hübinette (Hubbe) | | case F_EXTERNAL:
if(Pike_compiler ->new_program->id == CDR(n)->u.integer.a)
{
|
5d642e | 2003-08-03 | Martin Stjernholm | | if(CDR(n)->u.integer.b != IDREF_MAGIC_THIS &&
IDENTIFIER_IS_VARIABLE( ID_FROM_INT(Pike_compiler->new_program, CDR(n)->u.integer.b)->identifier_flags))
|
57f316 | 2001-06-29 | Fredrik Hübinette (Hubbe) | | {
code_expression(CAR(n), 0, "RHS");
|
b63e28 | 2014-08-07 | Per Hedbor | | emit_assign_global(CDR(n)->u.integer.b, flags & DO_POP );
|
57f316 | 2001-06-29 | Fredrik Hübinette (Hubbe) | | break;
}
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | default:
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | normal_assign:
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | tmp1=do_docode(CDR(n),DO_LVALUE);
if(do_docode(CAR(n),0)!=1) yyerror("RHS is void!");
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(flags & DO_POP ? F_ASSIGN_AND_POP:F_ASSIGN);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | break;
}
return flags & DO_POP ? 0 : 1;
}
case F_LAND:
case F_LOR:
|
2d1234 | 1997-03-10 | Fredrik Hübinette (Hubbe) | | tmp1=alloc_label();
|
081147 | 2001-07-02 | Fredrik Hübinette (Hubbe) | | if(flags & DO_POP)
{
do_cond_jump(CAR(n), DO_NOT_WARN((INT32)tmp1), n->token == F_LOR, DO_POP);
DO_CODE_BLOCK(CDR(n));
low_insert_label( DO_NOT_WARN((INT32)tmp1));
return 0;
}else{
do_cond_jump(CAR(n), DO_NOT_WARN((INT32)tmp1), n->token == F_LOR, 0);
code_expression(CDR(n), flags, n->token == F_LOR ? "||" : "&&");
low_insert_label( DO_NOT_WARN((INT32)tmp1));
return 1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
case F_EQ:
case F_NE:
case F_ADD:
case F_LT:
case F_LE:
case F_GT:
case F_GE:
case F_SUBTRACT:
case F_MULTIPLY:
case F_DIVIDE:
case F_MOD:
case F_LSH:
case F_RSH:
case F_XOR:
case F_OR:
case F_AND:
|
693018 | 1996-02-25 | Fredrik Hübinette (Hubbe) | | case F_NOT:
case F_COMPL:
case F_NEGATE:
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Optimizer error.\n");
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
case F_RANGE:
|
5e4442 | 2001-02-25 | Fredrik Hübinette (Hubbe) | | tmp1=do_docode(CAR(n),DO_NOT_COPY_TOPLEVEL);
|
408a1e | 2004-10-30 | Martin Stjernholm | | {
#ifdef PIKE_DEBUG
int num_args =
#endif
do_docode (CDR (n), DO_NOT_COPY);
emit_range (n DO_IF_DEBUG (COMMA num_args));
return DO_NOT_WARN((INT32)tmp1);
}
case F_RANGE_FROM_BEG:
case F_RANGE_FROM_END:
return do_docode (CAR (n), flags);
case F_RANGE_OPEN:
return 0;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
case F_INC:
case F_POST_INC:
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | if(CAR(n)->token == F_AUTO_MAP_MARKER)
{
int depth=0;
int ret=0;
node *tmp=CAR(n);
while(tmp->token == F_AUTO_MAP_MARKER)
{
depth++;
tmp=CAR(tmp);
}
tmp1=do_docode(tmp,DO_LVALUE);
if(n->token == F_POST_INC)
{
emit0(F_LTOSVAL);
emit2(F_REARRANGE,1,2);
ret++;
flags|=DO_POP;
}
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | if(tmp1 != 2)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n");
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #endif
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | emit0(F_MARK);
emit0(F_MARK);
emit0(F_LTOSVAL);
emit1(F_NUMBER, depth);
emit_apply_builtin("__builtin.automap_marker");
emit_builtin_svalue("`+");
emit2(F_REARRANGE,1,1);
emit1(F_NUMBER, 1);
emit_apply_builtin("__automap__");
if(flags & DO_POP)
{
emit0(F_ASSIGN_AND_POP);
}else{
emit0(F_ASSIGN);
ret++;
}
return ret;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }else{
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | tmp1=do_docode(CAR(n),DO_LVALUE);
#ifdef PIKE_DEBUG
if(tmp1 != 2)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n");
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | #endif
if(flags & DO_POP)
{
emit0(F_INC_AND_POP);
return 0;
}else{
emit0(n->token);
return 1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
case F_DEC:
case F_POST_DEC:
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | if(CAR(n)->token == F_AUTO_MAP_MARKER)
{
int depth=0;
int ret=0;
node *tmp=CAR(n);
while(tmp->token == F_AUTO_MAP_MARKER)
{
depth++;
tmp=CAR(tmp);
}
tmp1=do_docode(tmp,DO_LVALUE);
if(n->token == F_POST_DEC)
{
emit0(F_LTOSVAL);
emit2(F_REARRANGE,1,2);
ret++;
flags|=DO_POP;
}
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | if(tmp1 != 2)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n");
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | #endif
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | |
emit0(F_MARK);
emit0(F_MARK);
emit0(F_LTOSVAL);
emit1(F_NUMBER, depth);
emit_apply_builtin("__builtin.automap_marker");
emit_builtin_svalue("`-");
emit2(F_REARRANGE,1,1);
emit1(F_NUMBER, 1);
emit_apply_builtin("__automap__");
if(flags & DO_POP)
{
emit0(F_ASSIGN_AND_POP);
}else{
emit0(F_ASSIGN);
ret++;
}
return ret;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }else{
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | tmp1=do_docode(CAR(n),DO_LVALUE);
#ifdef PIKE_DEBUG
if(tmp1 != 2)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("HELP! FATAL INTERNAL COMPILER ERROR (2)\n");
|
005bf4 | 2001-09-29 | Fredrik Hübinette (Hubbe) | | #endif
if(flags & DO_POP)
{
emit0(F_DEC_AND_POP);
return 0;
}else{
emit0(n->token);
return 1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
case F_FOR:
{
|
9abda4 | 2002-03-02 | Martin Stjernholm | | INT32 *prev_switch_jumptable = current_switch.jumptable;
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_BEGIN;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | PUSH_STATEMENT_LABEL;
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable=0;
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | current_label->break_label=alloc_label();
current_label->continue_label=alloc_label();
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
if(CDR(n))
{
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | do_jump_when_zero(CAR(n),current_label->break_label);
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | tmp2=ins_label(-1);
|
9d6152 | 1996-08-03 | Fredrik Hübinette (Hubbe) | | DO_CODE_BLOCK(CADR(n));
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | ins_label(current_label->continue_label);
|
9d6152 | 1996-08-03 | Fredrik Hübinette (Hubbe) | | DO_CODE_BLOCK(CDDR(n));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }else{
|
9d6152 | 1996-08-03 | Fredrik Hübinette (Hubbe) | | tmp2=ins_label(-1);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | do_jump_when_non_zero(CAR(n), DO_NOT_WARN((INT32)tmp2));
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | ins_label(current_label->break_label);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable = prev_switch_jumptable;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | POP_STATEMENT_LABEL;
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_END;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
}
case ' ':
|
57c287 | 2003-09-19 | Henrik Grubbström (Grubba) | | ret = do_docode(CAR(n),0);
return ret + do_docode(CDR(n),DO_LVALUE);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
case F_FOREACH:
{
|
a98230 | 1999-04-30 | Fredrik Hübinette (Hubbe) | | node *arr;
|
9abda4 | 2002-03-02 | Martin Stjernholm | | INT32 *prev_switch_jumptable = current_switch.jumptable;
|
a98230 | 1999-04-30 | Fredrik Hübinette (Hubbe) | | arr=CAR(n);
|
4cdb80 | 2001-02-23 | Fredrik Hübinette (Hubbe) | |
if(CDR(arr) && CDR(arr)->token == ':')
{
BLOCK_BEGIN;
|
5e4442 | 2001-02-25 | Fredrik Hübinette (Hubbe) | | tmp1=do_docode(CAR(arr), DO_NOT_COPY_TOPLEVEL);
|
4cdb80 | 2001-02-23 | Fredrik Hübinette (Hubbe) | | emit0(F_MAKE_ITERATOR);
if(CADR(arr))
{
do_docode(CADR(arr), DO_LVALUE);
}else{
emit0(F_CONST0);
emit0(F_CONST0);
current_stack_depth+=2;
}
if(CDDR(arr))
{
do_docode(CDDR(arr), DO_LVALUE);
}else{
emit0(F_CONST0);
emit0(F_CONST0);
current_stack_depth+=2;
}
PUSH_CLEANUP_FRAME(do_pop, 5);
PUSH_STATEMENT_LABEL;
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable=0;
|
4cdb80 | 2001-02-23 | Fredrik Hübinette (Hubbe) | | current_label->break_label=alloc_label();
current_label->continue_label=alloc_label();
|
f13918 | 2003-09-05 | Martin Stjernholm | |
tmp3 = alloc_label();
do_jump(F_FOREACH_START, DO_NOT_WARN((INT32) tmp3));
|
4cdb80 | 2001-02-23 | Fredrik Hübinette (Hubbe) | | tmp1=ins_label(-1);
DO_CODE_BLOCK(CDR(n));
ins_label(current_label->continue_label);
|
f13918 | 2003-09-05 | Martin Stjernholm | | do_jump(F_FOREACH_LOOP, DO_NOT_WARN((INT32)tmp1));
|
4cdb80 | 2001-02-23 | Fredrik Hübinette (Hubbe) | | ins_label(current_label->break_label);
|
f13918 | 2003-09-05 | Martin Stjernholm | | low_insert_label( DO_NOT_WARN((INT32)tmp3));
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable = prev_switch_jumptable;
|
4cdb80 | 2001-02-23 | Fredrik Hübinette (Hubbe) | | POP_STATEMENT_LABEL;
POP_AND_DO_CLEANUP;
BLOCK_END;
return 0;
}
|
a98230 | 1999-04-30 | Fredrik Hübinette (Hubbe) | |
|
4cdb80 | 2001-02-23 | Fredrik Hübinette (Hubbe) | |
BLOCK_BEGIN;
if(CAR(arr) && CAR(arr)->token==F_RANGE)
|
a98230 | 1999-04-30 | Fredrik Hübinette (Hubbe) | | {
|
2d74b4 | 2004-10-28 | Martin Stjernholm | | node *range = CAR(arr);
|
408a1e | 2004-10-30 | Martin Stjernholm | | node *low = CADR(range);
node *high = CDDR(range);
if(high->token == F_RANGE_OPEN &&
low->token == F_RANGE_FROM_BEG &&
match_types (low->type, int_type_string))
|
a98230 | 1999-04-30 | Fredrik Hübinette (Hubbe) | | {
|
85f372 | 2003-09-05 | Henrik Grubbström (Grubba) | |
|
2d74b4 | 2004-10-28 | Martin Stjernholm | | do_docode (CAR(range), DO_NOT_COPY_TOPLEVEL);
do_docode (CDR(arr), DO_NOT_COPY|DO_LVALUE);
|
70b137 | 2014-07-15 | Henrik Grubbström (Grubba) | | if ((low->token == F_CONSTANT) && (TYPEOF(low->u.sval) == PIKE_T_INT)) {
if (low->u.sval.u.integer < 0) {
emit0(F_CONST0);
goto foreach_arg_pushed;
}
do_docode (CAR(low), DO_NOT_COPY);
goto foreach_arg_pushed;
}
|
408a1e | 2004-10-30 | Martin Stjernholm | | do_docode (CAR(low), DO_NOT_COPY);
|
70b137 | 2014-07-15 | Henrik Grubbström (Grubba) | | tmp1 = alloc_label();
emit0(F_DUP);
emit0(F_CONST0);
do_jump(F_BRANCH_WHEN_GE, tmp1);
emit0(F_POP_VALUE);
emit0(F_CONST0);
low_insert_label(DO_NOT_WARN((INT32)tmp1));
|
a98230 | 1999-04-30 | Fredrik Hübinette (Hubbe) | | goto foreach_arg_pushed;
}
}
|
2d74b4 | 2004-10-28 | Martin Stjernholm | | do_docode(arr,DO_NOT_COPY);
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_CONST0);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | current_stack_depth++;
|
a98230 | 1999-04-30 | Fredrik Hübinette (Hubbe) | | foreach_arg_pushed:
|
1544fd | 2001-01-31 | Martin Stjernholm | | PUSH_CLEANUP_FRAME(do_pop, 4);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | |
PUSH_STATEMENT_LABEL;
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable=0;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | current_label->break_label=alloc_label();
current_label->continue_label=alloc_label();
|
f181de | 2001-01-11 | Martin Stjernholm | | tmp3=do_branch(-1);
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | tmp1=ins_label(-1);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | DO_CODE_BLOCK(CDR(n));
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | ins_label(current_label->continue_label);
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | low_insert_label( DO_NOT_WARN((INT32)tmp3));
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | do_jump(n->token, DO_NOT_WARN((INT32)tmp1));
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | ins_label(current_label->break_label);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable = prev_switch_jumptable;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | POP_STATEMENT_LABEL;
POP_AND_DO_CLEANUP;
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_END;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
}
case F_INC_NEQ_LOOP:
case F_DEC_NEQ_LOOP:
case F_INC_LOOP:
case F_DEC_LOOP:
{
|
9abda4 | 2002-03-02 | Martin Stjernholm | | INT32 *prev_switch_jumptable = current_switch.jumptable;
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_BEGIN;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
1544fd | 2001-01-31 | Martin Stjernholm | | do_docode(CAR(n),0);
PUSH_CLEANUP_FRAME(do_pop, 3);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | |
PUSH_STATEMENT_LABEL;
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable=0;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | current_label->break_label=alloc_label();
current_label->continue_label=alloc_label();
|
f181de | 2001-01-11 | Martin Stjernholm | | tmp3=do_branch(-1);
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | tmp1=ins_label(-1);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | DO_CODE_BLOCK(CDR(n));
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | ins_label(current_label->continue_label);
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | low_insert_label( DO_NOT_WARN((INT32)tmp3));
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | do_jump(n->token, DO_NOT_WARN((INT32)tmp1));
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | ins_label(current_label->break_label);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable = prev_switch_jumptable;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | POP_STATEMENT_LABEL;
POP_AND_DO_CLEANUP;
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_END;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
}
|
cb76e8 | 2001-01-14 | Henrik Grubbström (Grubba) | | case F_LOOP:
{
PUSH_STATEMENT_LABEL;
|
f70c40 | 2001-01-14 | Henrik Grubbström (Grubba) | | tmp1 = do_docode(CAR(n), 0);
|
cb76e8 | 2001-01-14 | Henrik Grubbström (Grubba) | | if (tmp1 > 0) {
do_pop(tmp1-1);
tmp2 = do_branch(-1);
tmp3 = ins_label(-1);
|
f70c40 | 2001-01-14 | Henrik Grubbström (Grubba) | | DO_CODE_BLOCK(CDR(n));
|
cb76e8 | 2001-01-14 | Henrik Grubbström (Grubba) | | ins_label(tmp2);
emit1(F_LOOP, tmp3);
}
POP_STATEMENT_LABEL;
return 0;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | case F_DO:
{
|
9abda4 | 2002-03-02 | Martin Stjernholm | | INT32 *prev_switch_jumptable = current_switch.jumptable;
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_BEGIN;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | PUSH_STATEMENT_LABEL;
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable=0;
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | current_label->break_label=alloc_label();
current_label->continue_label=alloc_label();
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | tmp2=ins_label(-1);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | DO_CODE_BLOCK(CAR(n));
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | ins_label(current_label->continue_label);
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | do_jump_when_non_zero(CDR(n), DO_NOT_WARN((INT32)tmp2));
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | ins_label(current_label->break_label);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable = prev_switch_jumptable;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | POP_STATEMENT_LABEL;
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_END;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
}
|
176d62 | 1999-11-18 | Henrik Grubbström (Grubba) | | case F_POP_VALUE:
{
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_BEGIN;
|
176d62 | 1999-11-18 | Henrik Grubbström (Grubba) | | DO_CODE_BLOCK(CAR(n));
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_END;
|
176d62 | 1999-11-18 | Henrik Grubbström (Grubba) | | return 0;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | case F_CAST:
|
193248 | 2007-03-03 | Henrik Grubbström (Grubba) | | switch(n->type->type) {
case T_VOID:
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | DO_CODE_BLOCK(CAR(n));
return 0;
|
193248 | 2007-03-03 | Henrik Grubbström (Grubba) | | case T_INT:
|
0232d2 | 2001-06-17 | Henrik Grubbström (Grubba) | | tmp1 = do_docode(CAR(n), 0);
|
7f94c2 | 2001-06-17 | Henrik Grubbström (Grubba) | | if(!tmp1)
emit0(F_CONST0);
|
0232d2 | 2001-06-17 | Henrik Grubbström (Grubba) | | else {
|
7f94c2 | 2001-06-17 | Henrik Grubbström (Grubba) | | if(tmp1>1)
do_pop(DO_NOT_WARN((INT32)(tmp1-1)));
|
0232d2 | 2001-06-17 | Henrik Grubbström (Grubba) | | emit0(F_CAST_TO_INT);
}
return 1;
|
193248 | 2007-03-03 | Henrik Grubbström (Grubba) | | case T_STRING:
|
7f94c2 | 2001-06-17 | Henrik Grubbström (Grubba) | | tmp1 = do_docode(CAR(n), 0);
if(!tmp1)
emit0(F_CONST0);
else if(tmp1>1)
do_pop(DO_NOT_WARN((INT32)(tmp1-1)));
emit0(F_CAST_TO_STRING);
return 1;
|
193248 | 2007-03-03 | Henrik Grubbström (Grubba) | | default:
if (compile_type_to_runtime_type(n->type) == PIKE_T_MIXED) {
tmp1 = do_docode(CAR(n), 0);
if(!tmp1)
emit0(F_CONST0);
else if(tmp1>1)
do_pop(DO_NOT_WARN((INT32)(tmp1-1)));
return 1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
d68a07 | 2001-02-20 | Henrik Grubbström (Grubba) | | {
struct svalue sv;
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | SET_SVAL(sv, T_TYPE, 0, type, n->type);
|
515bcf | 2002-07-02 | Henrik Grubbström (Grubba) | | tmp1 = store_constant(&sv, 0, n->name);
|
d68a07 | 2001-02-20 | Henrik Grubbström (Grubba) | | emit1(F_CONSTANT, DO_NOT_WARN((INT32)tmp1));
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
tmp1=do_docode(CAR(n),0);
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | if(!tmp1) { emit0(F_CONST0); tmp1=1; }
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | if(tmp1>1) do_pop(DO_NOT_WARN((INT32)(tmp1-1)));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_CAST);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 1;
|
1d480f | 1999-11-23 | Henrik Grubbström (Grubba) | | case F_SOFT_CAST:
|
7d955e | 1999-12-13 | Henrik Grubbström (Grubba) | | if (runtime_options & RUNTIME_CHECK_TYPES) {
|
d68a07 | 2001-02-20 | Henrik Grubbström (Grubba) | | {
struct svalue sv;
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | SET_SVAL(sv, T_TYPE, 0, type, n->type);
|
515bcf | 2002-07-02 | Henrik Grubbström (Grubba) | | tmp1 = store_constant(&sv, 0, n->name);
|
d68a07 | 2001-02-20 | Henrik Grubbström (Grubba) | | emit1(F_CONSTANT, DO_NOT_WARN((INT32)tmp1));
}
|
dad12d | 1999-11-25 | Henrik Grubbström (Grubba) | | tmp1 = do_docode(CAR(n), 0);
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | if (!tmp1) { emit0(F_CONST0); tmp1 = 1; }
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | if (tmp1 > 1) do_pop(DO_NOT_WARN((INT32)(tmp1 - 1)));
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_SOFT_CAST);
|
dad12d | 1999-11-25 | Henrik Grubbström (Grubba) | | return 1;
}
tmp1 = do_docode(CAR(n), flags);
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | if (tmp1 > 1) do_pop(DO_NOT_WARN((INT32)(tmp1 - 1)));
|
dad12d | 1999-11-25 | Henrik Grubbström (Grubba) | | return !!tmp1;
|
1d480f | 1999-11-23 | Henrik Grubbström (Grubba) | |
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | case F_APPLY:
if(CAR(n)->token == F_CONSTANT)
{
|
cf3be6 | 2014-07-15 | Per Hedbor | | int args = count_args(CDR(n));
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if(TYPEOF(CAR(n)->u.sval) == T_FUNCTION)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if(SUBTYPEOF(CAR(n)->u.sval) == FUNCTION_BUILTIN)
|
7bd0ea | 1996-02-19 | Fredrik Hübinette (Hubbe) | | {
if(!CAR(n)->u.sval.u.efun->docode ||
!CAR(n)->u.sval.u.efun->docode(n))
{
|
cf3be6 | 2014-07-15 | Per Hedbor | | if(args==1)
|
d9a93b | 2001-07-01 | Fredrik Hübinette (Hubbe) | | {
do_docode(CDR(n),0);
tmp1=store_constant(& CAR(n)->u.sval,
!(CAR(n)->tree_info & OPT_EXTERNAL_DEPEND),
CAR(n)->name);
emit1(F_CALL_BUILTIN1, DO_NOT_WARN((INT32)tmp1));
|
cf3be6 | 2014-07-15 | Per Hedbor | | #ifdef USE_APPLY_N
}else if(args>0){
do_docode(CDR(n),0);
tmp1=store_constant(& CAR(n)->u.sval,
!(CAR(n)->tree_info & OPT_EXTERNAL_DEPEND),
CAR(n)->name);
emit2(F_CALL_BUILTIN_N, DO_NOT_WARN((INT32)tmp1), args);
#endif
|
d9a93b | 2001-07-01 | Fredrik Hübinette (Hubbe) | | }else{
emit0(F_MARK);
PUSH_CLEANUP_FRAME(do_pop_mark, 0);
do_docode(CDR(n),0);
tmp1=store_constant(& CAR(n)->u.sval,
!(CAR(n)->tree_info & OPT_EXTERNAL_DEPEND),
CAR(n)->name);
emit1(F_CALL_BUILTIN, DO_NOT_WARN((INT32)tmp1));
POP_AND_DONT_CLEANUP;
}
|
7bd0ea | 1996-02-19 | Fredrik Hübinette (Hubbe) | | }
|
044c62 | 1999-04-14 | Fredrik Hübinette (Hubbe) | | if(n->type == void_type_string)
return 0;
|
7bd0ea | 1996-02-19 | Fredrik Hübinette (Hubbe) | | return 1;
}else{
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(CAR(n)->u.sval.u.object == Pike_compiler->fake_object)
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | return do_lfun_call(SUBTYPEOF(CAR(n)->u.sval), CDR(n));
|
7bd0ea | 1996-02-19 | Fredrik Hübinette (Hubbe) | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
cf3be6 | 2014-07-15 | Per Hedbor | | #ifdef USE_APPLY_N
if( args <= 1 )
#endif
{
emit0(F_MARK);
PUSH_CLEANUP_FRAME(do_pop_mark, 0);
do_docode(CDR(n),0);
tmp1=store_constant(& CAR(n)->u.sval,
!(CAR(n)->tree_info & OPT_EXTERNAL_DEPEND),
CAR(n)->name);
emit1(F_APPLY, DO_NOT_WARN((INT32)tmp1));
POP_AND_DONT_CLEANUP;
}
#ifdef USE_APPLY_N
else
{
do_docode(CDR(n),0);
tmp1=store_constant(& CAR(n)->u.sval,
!(CAR(n)->tree_info & OPT_EXTERNAL_DEPEND),
CAR(n)->name);
emit2(F_APPLY_N, DO_NOT_WARN((INT32)tmp1), args);
}
#endif
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 1;
}
|
741130 | 2001-08-30 | Fredrik Hübinette (Hubbe) | | else if(CAR(n)->token == F_IDENTIFIER)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
5e5a59 | 2002-11-14 | Henrik Grubbström (Grubba) | | return do_lfun_call(CAR(n)->u.id.number, CDR(n));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | else if(CAR(n)->token == F_EXTERNAL &&
|
5d642e | 2003-08-03 | Martin Stjernholm | | CAR(n)->u.integer.a == Pike_compiler->new_program->id &&
CAR(n)->u.integer.b != IDREF_MAGIC_THIS)
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | {
|
5e5a59 | 2002-11-14 | Henrik Grubbström (Grubba) | | return do_lfun_call(CAR(n)->u.integer.b, CDR(n));
|
342fef | 2000-08-23 | Fredrik Hübinette (Hubbe) | | }
|
0e757b | 2006-10-28 | Henrik Grubbström (Grubba) | | else if(CAR(n)->token == F_GET_SET &&
CAR(n)->u.integer.a == Pike_compiler->new_program->id &&
CAR(n)->u.integer.b != IDREF_MAGIC_THIS)
{
return do_lfun_call(CAR(n)->u.integer.b, CDR(n));
}
|
a8aed2 | 2001-08-15 | Fredrik Hübinette (Hubbe) | | else if(CAR(n)->token == F_ARROW)
{
emit0(F_MARK);
PUSH_CLEANUP_FRAME(do_pop_mark, 0);
do_docode(CAAR(n),0);
do_docode(CDR(n),0);
emit1(F_CALL_OTHER, store_prog_string(CDAR(n)->u.sval.u.string));
POP_AND_DONT_CLEANUP;
return 1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | else
{
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | struct pike_string *tmp;
|
f53bab | 1997-01-26 | Fredrik Hübinette (Hubbe) | | node *foo;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_MARK);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | PUSH_CLEANUP_FRAME(do_pop_mark, 0);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | do_docode(CAR(n),0);
do_docode(CDR(n),0);
|
f53bab | 1997-01-26 | Fredrik Hübinette (Hubbe) | |
tmp=findstring("call_function");
if(!tmp) yyerror("No call_function efun.");
|
281605 | 2000-03-30 | Fredrik Hübinette (Hubbe) | | foo=find_module_identifier(tmp,0);
|
e95029 | 2009-11-10 | Peter Bortas | | if(!foo || foo->token!=F_CONSTANT)
|
f53bab | 1997-01-26 | Fredrik Hübinette (Hubbe) | | {
yyerror("No call_function efun.");
}else{
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if(TYPEOF(foo->u.sval) == T_FUNCTION &&
SUBTYPEOF(foo->u.sval) == FUNCTION_BUILTIN &&
|
d103cb | 1998-01-30 | Fredrik Hübinette (Hubbe) | | foo->u.sval.u.efun->function == f_call_function)
{
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_CALL_FUNCTION);
|
d103cb | 1998-01-30 | Fredrik Hübinette (Hubbe) | | }else{
|
454d54 | 1999-09-18 | Fredrik Hübinette (Hubbe) | |
tmp1=store_constant(& foo->u.sval, 1, foo->name);
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | emit1(F_APPLY, DO_NOT_WARN((INT32)tmp1));
|
d103cb | 1998-01-30 | Fredrik Hübinette (Hubbe) | | }
|
f53bab | 1997-01-26 | Fredrik Hübinette (Hubbe) | | }
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | | free_node(foo);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | POP_AND_DONT_CLEANUP;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 1;
}
case F_ARG_LIST:
|
bdf5eb | 2000-03-07 | Fredrik Hübinette (Hubbe) | | case F_COMMA_EXPR:
|
408a1e | 2004-10-30 | Martin Stjernholm | | case ':':
|
83c60c | 2001-06-13 | Henrik Grubbström (Grubba) | | {
node *root = n;
node *parent = n->parent;
n->parent = NULL;
tmp1 = 0;
next_car:
while (CAR(n) &&
((CAR(n)->token == F_ARG_LIST) ||
(CAR(n)->token == F_COMMA_EXPR))) {
CAR(n)->parent = n;
n = CAR(n);
}
|
7e877a | 2003-04-02 | Martin Stjernholm | | tmp1 += do_docode(CAR(n), flags & ~WANT_LVALUE);
|
83c60c | 2001-06-13 | Henrik Grubbström (Grubba) | |
do {
if (CDR(n)) {
if ((CDR(n)->token == F_ARG_LIST) ||
(CDR(n)->token == F_COMMA_EXPR)) {
CDR(n)->parent = n->parent;
n = CDR(n);
goto next_car;
}
if (n->parent) {
|
7e877a | 2003-04-02 | Martin Stjernholm | | tmp1 += do_docode(CDR(n), flags & ~WANT_LVALUE);
|
83c60c | 2001-06-13 | Henrik Grubbström (Grubba) | | } else {
tmp1 += do_docode(CDR(n), flags);
}
}
n = n->parent;
} while (n);
root->parent = parent;
}
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | return DO_NOT_WARN((INT32)tmp1);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
case F_SWITCH:
{
INT32 e,cases,*order;
INT32 *jumptable;
|
9abda4 | 2002-03-02 | Martin Stjernholm | | struct switch_data prev_switch = current_switch;
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
fc26f6 | 2000-07-06 | Fredrik Hübinette (Hubbe) | | struct svalue *save_sp=Pike_sp;
|
7af7d2 | 1997-08-03 | Fredrik Hübinette (Hubbe) | | #endif
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_BEGIN;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | PUSH_STATEMENT_LABEL;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
if(do_docode(CAR(n),0)!=1)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Internal compiler error, time to panic\n");
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | if (!(CAR(n) && (current_switch.type = CAR(n)->type))) {
current_switch.type = mixed_type_string;
|
767090 | 2000-01-04 | Henrik Grubbström (Grubba) | | }
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | current_label->break_label=alloc_label();
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
cases=count_cases(CDR(n));
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | tmp1=emit1(F_SWITCH,0);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | current_stack_depth--;
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit1(F_ALIGN,sizeof(INT32));
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.values_on_stack=0;
current_switch.index=2;
current_switch.less_label=-1;
current_switch.greater_label=-1;
current_switch.default_label=-1;
|
b81a1d | 2014-04-27 | Martin Nilsson | | current_switch.jumptable=xalloc(sizeof(INT32)*(cases*2+2));
jumptable=xalloc(sizeof(INT32)*(cases*2+2));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
52fcc8 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | for(e=1; e<cases*2+2; e++)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
e0755c | 2000-08-15 | Henrik Grubbström (Grubba) | | jumptable[e] = DO_NOT_WARN((INT32)emit1(F_POINTER, 0));
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable[e]=-1;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
928f95 | 2000-11-30 | Fredrik Hübinette (Hubbe) | | emit0(F_NOTREACHED);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
DO_CODE_BLOCK(CDR(n));
|
1544fd | 2001-01-31 | Martin Stjernholm | |
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
fc26f6 | 2000-07-06 | Fredrik Hübinette (Hubbe) | | if(Pike_sp-save_sp != cases)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Count cases is wrong!\n");
|
7af7d2 | 1997-08-03 | Fredrik Hübinette (Hubbe) | | #endif
|
b1f4eb | 1998-01-13 | Fredrik Hübinette (Hubbe) | |
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | f_aggregate(cases);
|
49398c | 2000-11-08 | Fredrik Hübinette (Hubbe) | |
|
fc26f6 | 2000-07-06 | Fredrik Hübinette (Hubbe) | | order=get_switch_order(Pike_sp[-1].u.array);
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if (!Pike_compiler->num_parse_error) {
|
7c95f1 | 2000-01-04 | Henrik Grubbström (Grubba) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | if (cases &&
((current_switch.less_label >= 0 &&
current_switch.jumptable[order[0]*2+2] !=
current_switch.less_label) ||
(current_switch.greater_label >= 0 &&
current_switch.jumptable[order[cases-1]*2+2] !=
current_switch.greater_label)))
yyerror("Case inside range.");
|
7c95f1 | 2000-01-04 | Henrik Grubbström (Grubba) | | for(e=0; e<cases-1; e++)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
7c95f1 | 2000-01-04 | Henrik Grubbström (Grubba) | | if(order[e] < cases-1)
|
ba62cf | 1997-09-18 | Fredrik Hübinette (Hubbe) | | {
|
7c95f1 | 2000-01-04 | Henrik Grubbström (Grubba) | | int o1=order[e]*2+2;
|
9abda4 | 2002-03-02 | Martin Stjernholm | | if(current_switch.jumptable[o1]==current_switch.jumptable[o1+1] &&
current_switch.jumptable[o1]==current_switch.jumptable[o1+2])
|
7c95f1 | 2000-01-04 | Henrik Grubbström (Grubba) | | {
if(order[e]+1 != order[e+1])
yyerror("Case inside range.");
e++;
}
|
ba62cf | 1997-09-18 | Fredrik Hübinette (Hubbe) | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
}
|
fc26f6 | 2000-07-06 | Fredrik Hübinette (Hubbe) | | order_array(Pike_sp[-1].u.array,order);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | reorder((void *)(current_switch.jumptable+2),cases,sizeof(INT32)*2,order);
|
26bb95 | 2014-04-27 | Martin Nilsson | | free(order);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable[1] = current_switch.less_label;
current_switch.jumptable[current_switch.index - 1] = current_switch.greater_label;
if(current_switch.default_label < 0)
current_switch.default_label = ins_label(-1);
for(e=1;e<cases*2+2;e++)
if(current_switch.jumptable[e]==-1)
current_switch.jumptable[e]=current_switch.default_label;
|
52fcc8 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | for(e=1; e<cases*2+2; e++)
|
9abda4 | 2002-03-02 | Martin Stjernholm | | update_arg(jumptable[e], current_switch.jumptable[e]);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | update_arg(DO_NOT_WARN((INT32)tmp1),
store_constant(Pike_sp-1,1,0));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
pop_stack();
|
26bb95 | 2014-04-27 | Martin Nilsson | | free(jumptable);
free(current_switch.jumptable);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch = prev_switch;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | low_insert_label( current_label->break_label);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
6c8ada | 2001-01-14 | Martin Stjernholm | | POP_STATEMENT_LABEL;
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_END;
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
fc26f6 | 2000-07-06 | Fredrik Hübinette (Hubbe) | | if(Pike_interpreter.recoveries && Pike_sp-Pike_interpreter.evaluator_stack < Pike_interpreter.recoveries->stack_pointer)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Stack error after F_SWITCH (underflow)\n");
|
7af7d2 | 1997-08-03 | Fredrik Hübinette (Hubbe) | | #endif
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
}
case F_CASE:
|
9abda4 | 2002-03-02 | Martin Stjernholm | | case F_CASE_RANGE:
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
9abda4 | 2002-03-02 | Martin Stjernholm | | if(!current_switch.jumptable)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
yyerror("Case outside switch.");
}else{
|
9abda4 | 2002-03-02 | Martin Stjernholm | | INT32 label = ins_label(-1);
int i;
|
767090 | 2000-01-04 | Henrik Grubbström (Grubba) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | for (i = 0; i < 2; i++) {
node *case_val = i == 0 ? CAR(n) : CDR(n);
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | |
|
9abda4 | 2002-03-02 | Martin Stjernholm | | if (case_val) {
if(!is_const(case_val))
|
271a6b | 2000-01-04 | Henrik Grubbström (Grubba) | | yyerror("Case label isn't constant.");
|
9abda4 | 2002-03-02 | Martin Stjernholm | |
|
acf187 | 2014-08-10 | Martin Nilsson | | if (case_val->type) {
|
9abda4 | 2002-03-02 | Martin Stjernholm | | if (!pike_types_le(case_val->type, current_switch.type)) {
if (!match_types(case_val->type, current_switch.type)) {
yytype_error("Type mismatch in case.",
current_switch.type, case_val->type, 0);
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | } else if (c->lex.pragmas & ID_STRICT_TYPES) {
|
9abda4 | 2002-03-02 | Martin Stjernholm | | yytype_error("Type mismatch in case.",
current_switch.type, case_val->type, YYTE_IS_WARNING);
}
}
}
|
ba62cf | 1997-09-18 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if (!Pike_compiler->num_parse_error) {
|
9f85c3 | 2002-10-25 | Marcus Comstedt | | tmp1=eval_low(case_val,1);
|
271a6b | 2000-01-04 | Henrik Grubbström (Grubba) | | if(tmp1<1)
{
|
9abda4 | 2002-03-02 | Martin Stjernholm | | yyerror("Error in case label.");
|
271a6b | 2000-01-04 | Henrik Grubbström (Grubba) | | push_int(0);
tmp1=1;
|
b1bfe2 | 2000-01-04 | Henrik Grubbström (Grubba) | | }
|
271a6b | 2000-01-04 | Henrik Grubbström (Grubba) | | pop_n_elems(tmp1-1);
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.values_on_stack++;
for(tmp1=current_switch.values_on_stack; tmp1 > 1; tmp1--)
|
fc26f6 | 2000-07-06 | Fredrik Hübinette (Hubbe) | | if(is_equal(Pike_sp-tmp1, Pike_sp-1))
|
9abda4 | 2002-03-02 | Martin Stjernholm | | yyerror("Duplicate case label.");
|
271a6b | 2000-01-04 | Henrik Grubbström (Grubba) | | } else {
push_int(0);
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.values_on_stack++;
|
ba62cf | 1997-09-18 | Fredrik Hübinette (Hubbe) | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
9abda4 | 2002-03-02 | Martin Stjernholm | | }
if (n->token == F_CASE) {
current_switch.jumptable[current_switch.index++] = label;
current_switch.jumptable[current_switch.index++] = -1;
}
else {
if (!CAR(n)) current_switch.less_label = label;
if (!CDR(n)) current_switch.greater_label = label;
if (CAR(n) && CDR(n)) {
current_switch.jumptable[current_switch.index++] = label;
current_switch.jumptable[current_switch.index++] = label;
current_switch.jumptable[current_switch.index++] = label;
current_switch.jumptable[current_switch.index++] = -1;
}
else {
current_switch.jumptable[current_switch.index++] = label;
current_switch.jumptable[current_switch.index++] = -1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
}
return 0;
}
case F_DEFAULT:
|
9abda4 | 2002-03-02 | Martin Stjernholm | | if(!current_switch.jumptable)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
yyerror("Default outside switch.");
|
9abda4 | 2002-03-02 | Martin Stjernholm | | }else if(current_switch.default_label!=-1){
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | yyerror("Duplicate switch default.");
}else{
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.default_label = ins_label(-1);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
return 0;
case F_BREAK:
|
f181de | 2001-01-11 | Martin Stjernholm | | case F_CONTINUE: {
struct statement_label *label, *p;
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | if (CAR(n)) {
struct pike_string *name = CAR(n)->u.sval.u.string;
struct statement_label_name *lbl_name;
for (label = current_label; label; label = label->prev)
for (lbl_name = label->name; lbl_name; lbl_name = lbl_name->next)
if (lbl_name->str == name)
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | goto label_found_1;
|
ce060e | 2004-06-30 | Martin Nilsson | | my_yyerror("No surrounding statement labeled %S.", name);
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | return 0;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | label_found_1:
|
f181de | 2001-01-11 | Martin Stjernholm | | if (n->token == F_CONTINUE && label->continue_label < 0) {
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | my_yyerror("Cannot continue the non-loop statement on line %ld.",
(long)lbl_name->line_number);
|
f181de | 2001-01-11 | Martin Stjernholm | | return 0;
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | |
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | else {
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | if (n->token == F_BREAK) {
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | for (label = current_label; label; label = label->prev)
|
e9ebb7 | 2001-01-15 | Martin Stjernholm | | if (label->break_label >= 0 && !label->emit_break_label)
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | goto label_found_2;
yyerror("Break outside loop or switch.");
return 0;
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | }
else {
for (label = current_label; label; label = label->prev)
|
f181de | 2001-01-11 | Martin Stjernholm | | if (label->continue_label >= 0)
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | goto label_found_2;
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | yyerror("Continue outside loop.");
|
f181de | 2001-01-11 | Martin Stjernholm | | return 0;
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | }
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | label_found_2: ;
}
|
f181de | 2001-01-11 | Martin Stjernholm | |
|
6c8ada | 2001-01-14 | Martin Stjernholm | | for (p = current_label; 1; p = p->prev) {
struct cleanup_frame *q;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | for (q = p->cleanups; q; q = q->prev) {
do_pop(current_stack_depth - q->stack_depth);
|
6c8ada | 2001-01-14 | Martin Stjernholm | | q->cleanup(q->cleanup_arg);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | }
do_pop(current_stack_depth - p->stack_depth);
|
6c8ada | 2001-01-14 | Martin Stjernholm | | if (p == label) break;
}
|
f181de | 2001-01-11 | Martin Stjernholm | |
if (n->token == F_BREAK) {
if (label->break_label < 0) label->emit_break_label = 1;
label->break_label = do_branch(label->break_label);
}
else
do_branch(label->continue_label);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
|
f181de | 2001-01-11 | Martin Stjernholm | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | case F_NORMAL_STMT_LABEL:
|
6c8ada | 2001-01-14 | Martin Stjernholm | | case F_CUSTOM_STMT_LABEL: {
struct statement_label *label;
struct statement_label_name name;
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_BEGIN;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | PUSH_STATEMENT_LABEL;
name.str = CAR(n)->u.sval.u.string;
name.line_number = n->line_number;
for (label = current_label; label; label = label->prev) {
struct statement_label_name *lbl_name;
for (lbl_name = label->name; lbl_name; lbl_name = lbl_name->next)
if (lbl_name->str == name.str) {
|
ef24a8 | 2012-01-12 | Henrik Grubbström (Grubba) | | INT_TYPE save_line = c->lex.current_line;
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | c->lex.current_line = name.line_number;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | my_yyerror("Duplicate nested labels, previous one on line %d.",
lbl_name->line_number);
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | c->lex.current_line = save_line;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | goto label_check_done;
}
}
label_check_done:
name.next = current_label->name;
current_label->name = &name;
if (!name.next) {
if (n->token == F_CUSTOM_STMT_LABEL)
current_label->break_label = -2;
else
current_label->break_label = -1;
}
DO_CODE_BLOCK(CDR(n));
if (!name.next && current_label->emit_break_label)
low_insert_label(current_label->break_label);
POP_STATEMENT_LABEL;
|
1544fd | 2001-01-31 | Martin Stjernholm | | BLOCK_END;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
ca176b | 2006-02-27 | Martin Stjernholm | | case F_RETURN: {
struct statement_label *p;
int in_catch = 0;
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | do_docode(CAR(n),0);
|
ca176b | 2006-02-27 | Martin Stjernholm | |
for (p = current_label; p; p = p->prev) {
struct cleanup_frame *q;
|
1d6ca2 | 2008-06-30 | Martin Stjernholm | | for (q = p->cleanups; q; q = q->prev) {
|
ca176b | 2006-02-27 | Martin Stjernholm | | if (q->cleanup == (cleanup_func) do_escape_catch) {
in_catch = 1;
do_escape_catch();
}
|
1d6ca2 | 2008-06-30 | Martin Stjernholm | | #ifdef PIKE_DEBUG
else if (d_flag > 2 &&
q->cleanup == (cleanup_func) do_cleanup_synch_mark) {
do_pop_mark (NULL);
}
#endif
}
|
ca176b | 2006-02-27 | Martin Stjernholm | | }
|
395899 | 2001-06-23 | Fredrik Hübinette (Hubbe) | | emit0(in_catch ? F_VOLATILE_RETURN : F_RETURN);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
|
ca176b | 2006-02-27 | Martin Stjernholm | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
case F_SSCANF:
|
3ac3bc | 2008-05-15 | Henrik Grubbström (Grubba) | | tmp1=do_docode(CDAR(n),DO_NOT_COPY);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | tmp2=do_docode(CDR(n),DO_NOT_COPY | DO_LVALUE);
|
3ac3bc | 2008-05-15 | Henrik Grubbström (Grubba) | | emit2(F_SSCANF, DO_NOT_WARN((INT32)(tmp1+tmp2)), CAAR(n)->u.sval.u.integer);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 1;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | case F_CATCH: {
|
9abda4 | 2002-03-02 | Martin Stjernholm | | INT32 *prev_switch_jumptable = current_switch.jumptable;
|
1544fd | 2001-01-31 | Martin Stjernholm | |
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | tmp1=do_jump(F_CATCH,-1);
PUSH_CLEANUP_FRAME(do_escape_catch, 0);
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | |
|
ca176b | 2006-02-27 | Martin Stjernholm | |
|
461e0a | 2002-11-06 | Henrik Grubbström (Grubba) | | emit0(F_ENTRY);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | PUSH_STATEMENT_LABEL;
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable=0;
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | | current_label->break_label=alloc_label();
if (TEST_COMPAT(7,0))
|
1544fd | 2001-01-31 | Martin Stjernholm | | current_label->continue_label = current_label->break_label;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
DO_CODE_BLOCK(CAR(n));
|
5a0fd5 | 2001-01-10 | Martin Stjernholm | |
ins_label(current_label->break_label);
|
9307b4 | 2002-09-23 | Martin Stjernholm | | emit0(F_EXIT_CATCH);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | POP_STATEMENT_LABEL;
|
9abda4 | 2002-03-02 | Martin Stjernholm | | current_switch.jumptable = prev_switch_jumptable;
|
a38a22 | 2006-03-15 | Henrik Grubbström (Grubba) | | do_branch (tmp1);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | |
current_stack_depth++;
|
ca176b | 2006-02-27 | Martin Stjernholm | | |
a38a22 | 2006-03-15 | Henrik Grubbström (Grubba) | | * catching an error.
*
* NB: This is reached by subtracting ENTRY_PROLOGUE_SIZE
* from the label below.
* NB: The label must be after the entry, since it may expand to code
* that requires the entry code to have run.
*/
|
ca176b | 2006-02-27 | Martin Stjernholm | | emit0(F_ENTRY);
|
a38a22 | 2006-03-15 | Henrik Grubbström (Grubba) | | ins_label(DO_NOT_WARN((INT32)tmp1));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
6c8ada | 2001-01-14 | Martin Stjernholm | | POP_AND_DONT_CLEANUP;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 1;
|
6c8ada | 2001-01-14 | Martin Stjernholm | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
case F_LVALUE_LIST:
|
57c287 | 2003-09-19 | Henrik Grubbström (Grubba) | | ret = do_docode(CAR(n),DO_LVALUE);
return ret + do_docode(CDR(n),DO_LVALUE);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
|
2a3269 | 1998-01-31 | Fredrik Hübinette (Hubbe) | | case F_ARRAY_LVALUE:
tmp1=do_docode(CAR(n),DO_LVALUE);
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
2a3269 | 1998-01-31 | Fredrik Hübinette (Hubbe) | | if(tmp1 & 1)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Very internal compiler error.\n");
|
2a3269 | 1998-01-31 | Fredrik Hübinette (Hubbe) | | #endif
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | emit1(F_ARRAY_LVALUE, DO_NOT_WARN((INT32)(tmp1>>1)));
|
2a3269 | 1998-01-31 | Fredrik Hübinette (Hubbe) | | return 2;
|
dffa01 | 1997-01-15 | Fredrik Hübinette (Hubbe) | | case F_ARROW:
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if(CDR(n)->token != F_CONSTANT || TYPEOF(CDR(n)->u.sval) != T_STRING)
|
6de085 | 2004-01-23 | Martin Nilsson | | Pike_fatal("Bugg in F_ARROW, index not string.\n");
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | | if(flags & WANT_LVALUE)
|
dffa01 | 1997-01-15 | Fredrik Hübinette (Hubbe) | | {
|
9b08a2 | 1998-03-31 | Fredrik Hübinette (Hubbe) | |
|
dffa01 | 1997-01-15 | Fredrik Hübinette (Hubbe) | | tmp1=do_docode(CAR(n), 0);
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit1(F_ARROW_STRING, store_prog_string(CDR(n)->u.sval.u.string));
|
dffa01 | 1997-01-15 | Fredrik Hübinette (Hubbe) | | return 2;
}else{
|
286afb | 2001-02-05 | Henrik Grubbström (Grubba) | | tmp1 = do_docode(CAR(n), DO_NOT_COPY);
|
7de8e3 | 2014-02-25 | Per Hedbor | | if ((tmp2 = lfun_lookup_id(CDR(n)->u.sval.u.string)) != -1 ) {
|
286afb | 2001-02-05 | Henrik Grubbström (Grubba) | | emit1(F_LOOKUP_LFUN, tmp2);
} else {
emit1(F_ARROW, store_prog_string(CDR(n)->u.sval.u.string));
}
|
dffa01 | 1997-01-15 | Fredrik Hübinette (Hubbe) | | if(!(flags & DO_NOT_COPY))
{
while(n && (n->token==F_INDEX || n->token==F_ARROW)) n=CAR(n);
if(n->token==F_CONSTANT && !(n->node_info & OPT_EXTERNAL_DEPEND))
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_COPY_VALUE);
|
dffa01 | 1997-01-15 | Fredrik Hübinette (Hubbe) | | }
}
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | return DO_NOT_WARN((INT32)tmp1);
|
dffa01 | 1997-01-15 | Fredrik Hübinette (Hubbe) | |
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | case F_INDEX:
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | | if(flags & WANT_LVALUE)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | | int mklval=CAR(n) && match_types(CAR(n)->type, string_type_string);
|
a30921 | 2000-09-11 | Henrik Grubbström (Grubba) | | tmp1 = do_docode(CAR(n),
|
7e877a | 2003-04-02 | Martin Stjernholm | | mklval ? DO_LVALUE_IF_POSSIBLE : 0);
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | | if(tmp1==2)
{
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | | if(!mklval)
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Unwanted lvalue!\n");
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | | #endif
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_INDIRECT);
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | if(do_docode(CDR(n),0) != 1)
|
6de085 | 2004-01-23 | Martin Nilsson | | Pike_fatal("Internal compiler error, please report this (1).\n");
|
e82b30 | 1997-01-29 | Fredrik Hübinette (Hubbe) | | if(CDR(n)->token != F_CONSTANT &&
match_types(CDR(n)->type, string_type_string))
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_CLEAR_STRING_SUBTYPE);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 2;
}else{
tmp1=do_docode(CAR(n), DO_NOT_COPY);
|
99761f | 1998-10-09 | Fredrik Hübinette (Hubbe) | |
|
c64e8a | 1997-04-17 | Fredrik Hübinette (Hubbe) | | code_expression(CDR(n), DO_NOT_COPY, "index");
|
99761f | 1998-10-09 | Fredrik Hübinette (Hubbe) | | if(CDR(n)->token != F_CONSTANT &&
match_types(CDR(n)->type, string_type_string))
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_CLEAR_STRING_SUBTYPE);
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | |
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_INDEX);
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | |
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | if(!(flags & DO_NOT_COPY))
{
|
dffa01 | 1997-01-15 | Fredrik Hübinette (Hubbe) | | while(n && (n->token==F_INDEX || n->token==F_ARROW)) n=CAR(n);
|
2e67b3 | 2014-04-19 | Henrik Grubbström (Grubba) | | if(n && (n->token==F_CONSTANT) && !(n->node_info & OPT_EXTERNAL_DEPEND))
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_COPY_VALUE);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
}
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | return DO_NOT_WARN((INT32)tmp1);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
case F_CONSTANT:
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | switch(TYPEOF(n->u.sval))
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
case T_INT:
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if(!n->u.sval.u.integer && SUBTYPEOF(n->u.sval) == NUMBER_UNDEFINED)
|
ece320 | 1999-08-02 | Fredrik Hübinette (Hubbe) | | {
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit0(F_UNDEFINED);
|
ece320 | 1999-08-02 | Fredrik Hübinette (Hubbe) | | }else{
|
648a8c | 2003-01-26 | Mirar (Pontus Hagland) | | #if SIZEOF_INT_TYPE > 4
INT_TYPE i=n->u.sval.u.integer;
if (i != (INT32)i)
{
|
cf8438 | 2003-01-26 | Mirar (Pontus Hagland) | | unsigned INT_TYPE ip=(unsigned INT_TYPE)i;
|
648a8c | 2003-01-26 | Mirar (Pontus Hagland) | | INT32 a,b;
a=(INT32)(ip>>32);
b=(INT32)(ip&0xffffffff);
emit2(F_NUMBER64,a,b);
}
else
emit1(F_NUMBER,i);
#else
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit1(F_NUMBER,n->u.sval.u.integer);
|
648a8c | 2003-01-26 | Mirar (Pontus Hagland) | | #endif
|
ece320 | 1999-08-02 | Fredrik Hübinette (Hubbe) | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 1;
case T_STRING:
tmp1=store_prog_string(n->u.sval.u.string);
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | emit1(F_STRING, DO_NOT_WARN((INT32)tmp1));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 1;
case T_FUNCTION:
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if(SUBTYPEOF(n->u.sval) != FUNCTION_BUILTIN)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(n->u.sval.u.object == Pike_compiler->fake_object)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
98cf2a | 2003-02-24 | Martin Stjernholm | |
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | emit1(F_GLOBAL, SUBTYPEOF(n->u.sval));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 1;
}
|
6d2254 | 1998-01-28 | Fredrik Hübinette (Hubbe) | |
if(n->u.sval.u.object->next == n->u.sval.u.object)
{
int x=0;
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | #if 0
|
6d2254 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | struct object *o;
|
ff88db | 2000-07-12 | Henrik Grubbström (Grubba) | |
|
7c3fe0 | 2009-11-20 | Henrik Grubbström (Grubba) | | for(o=Pike_compiler->fake_object;o!=n->u.sval.u.object;o=o->parent) {
state->new_program->flags |=
PROGRAM_USES_PARENT | PROGRAM_NEEDS_PARENT;
|
6d2254 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | x++;
|
7c3fe0 | 2009-11-20 | Henrik Grubbström (Grubba) | | }
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | #else
struct program_state *state=Pike_compiler;
|
7c3fe0 | 2009-11-20 | Henrik Grubbström (Grubba) | | for(;state->fake_object!=n->u.sval.u.object;state=state->previous) {
state->new_program->flags |=
PROGRAM_USES_PARENT | PROGRAM_NEEDS_PARENT;
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | x++;
|
7c3fe0 | 2009-11-20 | Henrik Grubbström (Grubba) | | }
|
f3c715 | 2001-04-14 | Fredrik Hübinette (Hubbe) | | #endif
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | emit2(F_EXTERNAL, SUBTYPEOF(n->u.sval), x);
|
22d799 | 2001-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->new_program->flags |=
PROGRAM_USES_PARENT | PROGRAM_NEEDS_PARENT;
|
6d2254 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | return 1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
515bcf | 2002-07-02 | Henrik Grubbström (Grubba) | |
|
fb5b3f | 2002-11-18 | Henrik Grubbström (Grubba) | | default:
|
71f3a2 | 1998-11-22 | Fredrik Hübinette (Hubbe) | | #ifdef PIKE_DEBUG
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | if((TYPEOF(n->u.sval) == T_OBJECT) &&
|
fb5b3f | 2002-11-18 | Henrik Grubbström (Grubba) | | (n->u.sval.u.object->next == n->u.sval.u.object))
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Internal error: Pointer to parent cannot be a compile time constant!\n");
|
6d2254 | 1998-01-28 | Fredrik Hübinette (Hubbe) | | #endif
|
454d54 | 1999-09-18 | Fredrik Hübinette (Hubbe) | | tmp1=store_constant(&(n->u.sval),
!(n->tree_info & OPT_EXTERNAL_DEPEND),
n->name);
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | emit1(F_CONSTANT, DO_NOT_WARN((INT32)tmp1));
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 1;
|
515bcf | 2002-07-02 | Henrik Grubbström (Grubba) | | case T_TYPE:
tmp1 = store_constant(&(n->u.sval), 0, n->name);
emit1(F_CONSTANT, DO_NOT_WARN((INT32)tmp1));
return 1;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | case T_ARRAY:
case T_MAPPING:
|
06983f | 1996-09-22 | Fredrik Hübinette (Hubbe) | | case T_MULTISET:
|
454d54 | 1999-09-18 | Fredrik Hübinette (Hubbe) | | tmp1=store_constant(&(n->u.sval),
!(n->tree_info & OPT_EXTERNAL_DEPEND),
n->name);
|
393a59 | 2000-08-16 | Henrik Grubbström (Grubba) | | emit1(F_CONSTANT, DO_NOT_WARN((INT32)tmp1));
|
5683de | 1995-11-06 | Fredrik Hübinette (Hubbe) | |
if(!(flags & DO_NOT_COPY) && !(n->tree_info & OPT_EXTERNAL_DEPEND))
|
5e4442 | 2001-02-25 | Fredrik Hübinette (Hubbe) | | {
if(flags & DO_NOT_COPY_TOPLEVEL)
{
|
017b57 | 2011-10-28 | Henrik Grubbström (Grubba) | | switch(TYPEOF(n->u.sval))
|
5e4442 | 2001-02-25 | Fredrik Hübinette (Hubbe) | | {
case T_ARRAY:
|
257524 | 2004-05-14 | Martin Nilsson | | if(array_fix_type_field(n->u.sval.u.array) & BIT_COMPLEX)
|
5e4442 | 2001-02-25 | Fredrik Hübinette (Hubbe) | | emit0(F_COPY_VALUE);
break;
case T_MAPPING:
mapping_fix_type_field(n->u.sval.u.mapping);
if((n->u.sval.u.mapping->data->ind_types |
n->u.sval.u.mapping->data->val_types) & BIT_COMPLEX)
emit0(F_COPY_VALUE);
break;
case T_MULTISET:
|
5b15bb | 2001-12-10 | Martin Stjernholm | | multiset_fix_type_field(n->u.sval.u.multiset);
if(multiset_ind_types(n->u.sval.u.multiset) & BIT_COMPLEX)
|
5e4442 | 2001-02-25 | Fredrik Hübinette (Hubbe) | | emit0(F_COPY_VALUE);
break;
}
}else{
emit0(F_COPY_VALUE);
}
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 1;
}
case F_LOCAL:
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | if(n->u.integer.a >=
find_local_frame(n->u.integer.b)->max_number_of_locals)
|
a8ef6e | 1996-12-03 | Fredrik Hübinette (Hubbe) | | yyerror("Illegal to use local variable here.");
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | |
if(n->u.integer.b)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | if(flags & WANT_LVALUE)
{
|
c98166 | 2006-03-02 | Henrik Grubbström (Grubba) | | emit2(F_LEXICAL_LOCAL_LVALUE, n->u.integer.a, n->u.integer.b);
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | return 2;
}else{
|
c98166 | 2006-03-02 | Henrik Grubbström (Grubba) | | emit2(F_LEXICAL_LOCAL, n->u.integer.a, n->u.integer.b);
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | return 1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }else{
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | if(flags & WANT_LVALUE)
{
|
c98166 | 2006-03-02 | Henrik Grubbström (Grubba) | | if (n->node_info & OPT_ASSIGNMENT) {
emit0(F_CONST0);
emit1(F_ASSIGN_LOCAL_AND_POP, n->u.integer.a);
}
emit1(F_LOCAL_LVALUE, n->u.integer.a);
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | return 2;
}else{
|
c98166 | 2006-03-02 | Henrik Grubbström (Grubba) | | if (n->node_info & OPT_ASSIGNMENT) {
emit0(F_CONST0);
emit1(F_ASSIGN_LOCAL, n->u.integer.a);
} else {
emit1(F_LOCAL, n->u.integer.a);
}
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | return 1;
}
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | case F_TRAMPOLINE:
|
8c70ba | 2001-09-28 | Fredrik Hübinette (Hubbe) | | {
struct compiler_frame *f;
int depth=0;
for(f=Pike_compiler->compiler_frame;
f!=n->u.trampoline.frame;f=f->previous)
depth++;
emit2(F_TRAMPOLINE,n->u.trampoline.ident,depth);
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | | return 1;
|
8c70ba | 2001-09-28 | Fredrik Hübinette (Hubbe) | | }
|
421801 | 1999-01-31 | Fredrik Hübinette (Hubbe) | |
|
98cf2a | 2003-02-24 | Martin Stjernholm | | case F_IDENTIFIER: {
struct identifier *id = ID_FROM_INT(Pike_compiler->new_program, n->u.id.number);
if(IDENTIFIER_IS_FUNCTION(id->identifier_flags))
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | | if(flags & WANT_LVALUE)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
yyerror("Cannot assign functions.\n");
}else{
|
98cf2a | 2003-02-24 | Martin Stjernholm | | if (id->identifier_flags & IDENTIFIER_HAS_BODY)
emit1(F_LFUN,n->u.id.number);
else
|
b63e28 | 2014-08-07 | Per Hedbor | | emit_global(n->u.id.number);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
}else{
|
19aaeb | 1998-05-25 | Fredrik Hübinette (Hubbe) | | if(flags & WANT_LVALUE)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
a96ce9 | 2000-04-19 | Fredrik Hübinette (Hubbe) | | emit1(F_GLOBAL_LVALUE,n->u.id.number);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 2;
}else{
|
b63e28 | 2014-08-07 | Per Hedbor | | emit_global(n->u.id.number);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
}
return 1;
|
98cf2a | 2003-02-24 | Martin Stjernholm | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | |
case F_VAL_LVAL:
|
c3823f | 2003-09-19 | Henrik Grubbström (Grubba) | | ret = do_docode(CAR(n),flags);
return ret + do_docode(CDR(n), flags | DO_LVALUE);
|
8bef1b | 2001-09-27 | Fredrik Hübinette (Hubbe) | |
case F_AUTO_MAP:
emit0(F_MARK);
code_expression(CAR(n), 0, "automap function");
do_encode_automap_arg_list(CDR(n),0);
emit_apply_builtin("__automap__");
return 1;
case F_AUTO_MAP_MARKER:
yyerror("[*] not supported here.\n");
emit0(F_CONST0);
return 1;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | default:
|
5aad93 | 2002-08-15 | Marcus Comstedt | | Pike_fatal("Infernal compiler error (unknown parse-tree-token %d).\n", n->token);
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | return 0;
}
}
|
ee6a78 | 2003-11-19 | Henrik Grubbström (Grubba) | |
|
852c15 | 2001-07-23 | Fredrik Hübinette (Hubbe) | | INT32 do_code_block(node *n)
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | {
|
e021fe | 2008-04-14 | Henrik Grubbström (Grubba) | | struct compilation *c = THIS_COMPILATION;
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | | struct reference *id = NULL;
struct identifier *i = NULL;
|
ee6a78 | 2003-11-19 | Henrik Grubbström (Grubba) | | INT32 entry_point;
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | | int aggregate_cnum = -1;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | #ifdef PIKE_DEBUG
|
5aad93 | 2002-08-15 | Marcus Comstedt | | if (current_stack_depth != -4711) Pike_fatal("Reentrance in do_code_block().\n");
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | current_stack_depth = 0;
#endif
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | | if (Pike_compiler->compiler_frame->current_function_number >= 0) {
id = Pike_compiler->new_program->identifier_references +
Pike_compiler->compiler_frame->current_function_number;
i = ID_FROM_PTR(Pike_compiler->new_program, id);
}
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | init_bytecode();
|
6fd517 | 2000-04-25 | Fredrik Hübinette (Hubbe) | | label_no=1;
|
873ceb | 2000-04-30 | Fredrik Hübinette (Hubbe) | |
|
5e5a59 | 2002-11-14 | Henrik Grubbström (Grubba) | |
low_insert_label(0);
|
a468a0 | 2001-07-24 | Henrik Grubbström (Grubba) | | emit0(F_ENTRY);
|
873ceb | 2000-04-30 | Fredrik Hübinette (Hubbe) | | emit0(F_START_FUNCTION);
|
b1aa47 | 2001-10-05 | Fredrik Hübinette (Hubbe) | |
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | | if (Pike_compiler->compiler_frame->num_args) {
emit2(F_FILL_STACK, Pike_compiler->compiler_frame->num_args, 1);
}
emit1(F_MARK_AT, Pike_compiler->compiler_frame->num_args);
if (i && i->identifier_flags & IDENTIFIER_VARARGS) {
struct svalue *sval =
simple_mapping_string_lookup(get_builtin_constants(), "aggregate");
if (!sval) {
yyerror("predef::aggregate() is missing.\n");
Pike_fatal("No aggregate!\n");
return 0;
}
aggregate_cnum = store_constant(sval, 0, NULL);
emit1(F_CALL_BUILTIN, aggregate_cnum);
if (Pike_compiler->compiler_frame->max_number_of_locals !=
Pike_compiler->compiler_frame->num_args+1) {
emit2(F_FILL_STACK,
Pike_compiler->compiler_frame->max_number_of_locals, 0);
}
} else {
emit0(F_POP_TO_MARK);
if (Pike_compiler->compiler_frame->max_number_of_locals !=
Pike_compiler->compiler_frame->num_args) {
emit2(F_FILL_STACK,
Pike_compiler->compiler_frame->max_number_of_locals, 0);
}
}
|
7dcd1a | 2012-06-25 | Per Hedbor | | emit2(F_INIT_FRAME, Pike_compiler->compiler_frame->num_args,
Pike_compiler->compiler_frame->max_number_of_locals);
|
4a2665 | 2012-06-19 | Henrik Grubbström (Grubba) | | if (Pike_compiler->compiler_frame->lexical_scope & SCOPE_SCOPE_USED) {
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | | emit1(F_PROTECT_STACK, Pike_compiler->compiler_frame->max_number_of_locals);
}
if(id && (id->id_flags & ID_INLINE))
|
873ceb | 2000-04-30 | Fredrik Hübinette (Hubbe) | | {
|
ec1d4d | 2002-11-14 | Henrik Grubbström (Grubba) | | Pike_compiler->compiler_frame->recur_label=0;
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->compiler_frame->is_inline=1;
|
873ceb | 2000-04-30 | Fredrik Hübinette (Hubbe) | | }
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | DO_CODE_BLOCK(n);
|
873ceb | 2000-04-30 | Fredrik Hübinette (Hubbe) | |
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | if(Pike_compiler->compiler_frame->recur_label > 0)
|
873ceb | 2000-04-30 | Fredrik Hübinette (Hubbe) | | {
#ifdef PIKE_DEBUG
if(l_flag)
{
fprintf(stderr,"Generating inline recursive function.\n");
}
#endif
|
bad516 | 2000-06-23 | Fredrik Hübinette (Hubbe) | | Pike_compiler->compiler_frame->is_inline=1;
|
873ceb | 2000-04-30 | Fredrik Hübinette (Hubbe) | |
|
4686dd | 2002-11-12 | Henrik Grubbström (Grubba) | |
low_insert_label(Pike_compiler->compiler_frame->recur_label);
emit0(F_ENTRY);
|
873ceb | 2000-04-30 | Fredrik Hübinette (Hubbe) | | emit0(F_START_FUNCTION);
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | |
if (Pike_compiler->compiler_frame->num_args) {
emit2(F_FILL_STACK, Pike_compiler->compiler_frame->num_args, 1);
}
emit1(F_MARK_AT, Pike_compiler->compiler_frame->num_args);
if (i && i->identifier_flags & IDENTIFIER_VARARGS) {
emit1(F_CALL_BUILTIN, aggregate_cnum);
if (Pike_compiler->compiler_frame->max_number_of_locals !=
Pike_compiler->compiler_frame->num_args+1) {
emit2(F_FILL_STACK,
Pike_compiler->compiler_frame->max_number_of_locals, 0);
}
emit2(F_INIT_FRAME, Pike_compiler->compiler_frame->num_args+1,
Pike_compiler->compiler_frame->max_number_of_locals);
} else {
emit0(F_POP_TO_MARK);
if (Pike_compiler->compiler_frame->max_number_of_locals !=
Pike_compiler->compiler_frame->num_args) {
emit2(F_FILL_STACK,
Pike_compiler->compiler_frame->max_number_of_locals, 0);
}
emit2(F_INIT_FRAME, Pike_compiler->compiler_frame->num_args,
Pike_compiler->compiler_frame->max_number_of_locals);
}
|
4a2665 | 2012-06-19 | Henrik Grubbström (Grubba) | | if (Pike_compiler->compiler_frame->lexical_scope & SCOPE_SCOPE_USED) {
|
45dda9 | 2012-06-10 | Henrik Grubbström (Grubba) | | emit1(F_PROTECT_STACK,
Pike_compiler->compiler_frame->max_number_of_locals);
}
|
873ceb | 2000-04-30 | Fredrik Hübinette (Hubbe) | | DO_CODE_BLOCK(n);
}
|
ee6a78 | 2003-11-19 | Henrik Grubbström (Grubba) | | entry_point = assemble(1);
|
7acaf1 | 2001-01-15 | Martin Stjernholm | |
#ifdef PIKE_DEBUG
current_stack_depth = -4711;
#endif
|
ee6a78 | 2003-11-19 | Henrik Grubbström (Grubba) | | return entry_point;
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | }
|
ee6a78 | 2003-11-19 | Henrik Grubbström (Grubba) | |
INT32 docode(node *n)
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | {
|
ee6a78 | 2003-11-19 | Henrik Grubbström (Grubba) | | INT32 entry_point;
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | int label_no_save = label_no;
dynamic_buffer instrbuf_save = instrbuf;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | int stack_depth_save = current_stack_depth;
struct statement_label *label_save = current_label;
struct cleanup_frame *top_cleanups_save = top_statement_label_dummy.cleanups;
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | |
instrbuf.s.str=0;
|
6fd517 | 2000-04-25 | Fredrik Hübinette (Hubbe) | | label_no=1;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | current_stack_depth = 0;
current_label = &top_statement_label_dummy;
top_statement_label_dummy.cleanups = 0;
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | | init_bytecode();
|
ee6a78 | 2003-11-19 | Henrik Grubbström (Grubba) | | insert_opcode0(F_ENTRY, n->line_number, n->current_file);
do_docode(n,0);
insert_opcode0(F_DUMB_RETURN, n->line_number, n->current_file);
entry_point = assemble(0);
|
7a82f9 | 1996-04-13 | Fredrik Hübinette (Hubbe) | |
instrbuf=instrbuf_save;
label_no = label_no_save;
|
7acaf1 | 2001-01-15 | Martin Stjernholm | | current_stack_depth = stack_depth_save;
current_label = label_save;
top_statement_label_dummy.cleanups = top_cleanups_save;
|
ee6a78 | 2003-11-19 | Henrik Grubbström (Grubba) | | return entry_point;
|
5267b7 | 1995-08-09 | Fredrik Hübinette (Hubbe) | | }
|