1998-01-13
1998-01-13 23:01:47 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>
-
b1f4eb39528f16bb6a6f876e2458255e588283a1
(102 lines)
(+44/-58)
[
Show
| Annotate
]
Branch: 7.9
Compiler update to use two pass
Rev: src/acconfig.h:1.14
Rev: src/builtin_functions.c:1.59
Rev: src/builtin_functions.h:1.5
Rev: src/compilation.h:1.4
Rev: src/configure.in:1.149
Rev: src/cpp.c:1.3
Rev: src/docode.c:1.24
Rev: src/docode.h:1.4
Rev: src/gc.c:1.24
Rev: src/interpret.c:1.57
Rev: src/interpret.h:1.16
Rev: src/language.yacc:1.51
Rev: src/las.c:1.40
Rev: src/las.h:1.9
Rev: src/lex.c:1.37
Rev: src/lex.h:1.7
Rev: src/main.c:1.32
Rev: src/modules/Image/blit.c:1.26
Rev: src/modules/Image/colortable.c:1.33
Rev: src/modules/Image/dct.c:1.11
Rev: src/modules/Image/image.c:1.73
Rev: src/modules/Image/matrix.c:1.13
Rev: src/modules/Image/operator.c:1.11
Rev: src/modules/Image/pattern.c:1.11
Rev: src/modules/Image/pnm.c:1.9
Rev: src/modules/Image/polyfill.c:1.18
Rev: src/modules/Image/togif.c:1.29
Rev: src/modules/Image/x.c:1.17
Rev: src/modules/Pipe/pipe.c:1.15
Rev: src/modules/Regexp/glue.c:1.9
Rev: src/modules/_Crypto/cbc.c:1.10
Rev: src/modules/_Crypto/crypto.c:1.24
Rev: src/modules/_Crypto/des.c:1.11
Rev: src/modules/_Crypto/pipe.c:1.11
Rev: src/modules/_Crypto/sha.c:1.9
Rev: src/modules/files/socktest.pike:1.6
Rev: src/modules/system/system.c:1.37
Rev: src/object.c:1.31
Rev: src/object.h:1.13
Rev: src/opcodes.c:1.10
Rev: src/operators.c:1.22
Rev: src/peep.c:1.16
Rev: src/peep.in:1.9
Rev: src/pike_types.c:1.27
Rev: src/pike_types.h:1.6
Rev: src/program.c:1.48
Rev: src/program.h:1.24
Rev: src/program_areas.h:1.2
Rev: src/stralloc.c:1.21
Rev: src/stralloc.h:1.10
Rev: src/svalue.c:1.18
Rev: src/testsuite.in:1.64
Rev: src/threads.c:1.51
Rev: src/threads.h:1.26
4:
||| See the files COPYING and DISCLAIMER for more information.
\*/
#include "global.h"
- RCSID("$Id: docode.c,v 1.23 1997/09/22 01:01:15 hubbe Exp $");
+ RCSID("$Id: docode.c,v 1.24 1998/01/13 22:56:42 hubbe Exp $");
#include "las.h"
#include "program.h"
#include "language.h"
15:
#include "array.h"
#include "pike_macros.h"
#include "error.h"
- #include "pike_memory.h"
+ #include "memory.h"
#include "svalue.h"
#include "main.h"
#include "lex.h"
32:
static INT32 current_switch_values_on_stack;
static INT32 *current_switch_jumptable =0;
- void ins_byte(unsigned char b,int area)
- {
- add_to_mem_block(area, (char *)&b, 1);
- }
-
- void ins_signed_byte(char b,int area)
- {
- add_to_mem_block(area, (char *)&b, 1);
- }
-
- void ins_short(INT16 l,int area)
- {
- add_to_mem_block(area, (char *)&l, sizeof(INT16));
- }
-
- /*
- * Store an INT32.
- */
- void ins_int(INT32 l,int area)
- {
- add_to_mem_block(area, (char *)&l+0, sizeof(INT32));
- }
-
+
void upd_int(int offset, INT32 tmp)
{
- #ifdef HANDLES_UNALIGNED_MEMORY_ACCESS
- *((int *)(areas[A_PROGRAM].s.str+offset))=tmp;
- #else
- MEMCPY(areas[A_PROGRAM].s.str+offset, (char *)&tmp,sizeof(tmp));
- #endif
+ MEMCPY(new_program->program+offset, (char *)&tmp,sizeof(tmp));
}
INT32 read_int(int offset)
{
- INT32 tmp;
- #ifdef HANDLES_UNALIGNED_MEMORY_ACCESS
- tmp=*((int *)(areas[A_PROGRAM].s.str+offset));
- #else
- MEMCPY((char *)&tmp, areas[A_PROGRAM].s.str+offset,sizeof(tmp));
- #endif
- return tmp;
+ return EXTRACT_INT(new_program->program+offset);
}
int store_linenumbers=1;
148:
int do_docode(node *n,INT16 flags)
{
int i;
- int save_current_line=current_line;
+ int save_current_line=lex.current_line;
if(!n) return 0;
- current_line=n->line_number;
+ lex.current_line=n->line_number;
i=do_docode2(n, flags);
- current_line=save_current_line;
+ lex.current_line=save_current_line;
return i;
}
174:
case 2:
fatal("Internal compiler error (%s), line %ld, file %s\n",
err,
- (long)current_line,
- current_file?current_file->str:"Unknown");
+ (long)lex.current_line,
+ lex.current_file?lex.current_file->str:"Unknown");
}
}
279:
default:
yyerror("Illegal lvalue.");
emit(F_NUMBER,0);
- emit(F_NUMBER,0);
- return 2;
+ return 1;
case F_LVALUE_LIST:
case F_LOCAL:
289:
case F_INDEX:
case F_ARROW:
case F_ARG_LIST:
+ case F_EXTERNAL:
break;
}
}
switch(n->token)
{
-
+ case F_EXTERNAL:
+ emit(F_LDA, n->u.integer.a);
+ if(flags & DO_LVALUE)
+ {
+ emit(F_EXTERNAL_LVALUE, n->u.integer.b);
+ return 2;
+ }else{
+ emit(F_EXTERNAL, n->u.integer.b);
+ return 1;
+ }
+ break;
+
+ case F_UNDEFINED:
+ yyerror("Undefined identifier");
+ emit(F_NUMBER,0);
+ return 1;
+
case F_PUSH_ARRAY:
code_expression(CAR(n), 0, "`@");
emit2(F_PUSH_ARRAY);
368: Inside #if defined(DEBUG)
tmp1=do_docode(CAR(n),DO_LVALUE);
#ifdef DEBUG
if(tmp1 != 2)
- fatal("HELP! FATAL INTERNAL COMPILER ERROR\n");
+ fatal("HELP! FATAL INTERNAL COMPILER ERROR (7)\n");
#endif
if(match_types(CAR(n)->type,array_type_string) ||
441:
switch(CDR(n)->token)
{
case F_LOCAL:
- if(CDR(n)->u.number >= local_variables->max_number_of_locals)
+ if(CDR(n)->u.number >= compiler_frame->max_number_of_locals)
yyerror("Illegal to use local variable here.");
code_expression(CAR(n), 0, "RHS");
450:
break;
case F_IDENTIFIER:
- if(!IDENTIFIER_IS_VARIABLE( ID_FROM_INT(& fake_program, CDR(n)->u.number)->identifier_flags))
+ if(!IDENTIFIER_IS_VARIABLE( ID_FROM_INT(new_program, CDR(n)->u.number)->identifier_flags))
{
yyerror("Cannot assign functions or constants.\n");
}else{
501:
case F_RANGE:
tmp1=do_docode(CAR(n),DO_NOT_COPY);
if(do_docode(CDR(n),DO_NOT_COPY)!=2)
- fatal("Compiler internal error (at %ld).\n",(long)current_line);
+ fatal("Compiler internal error (at %ld).\n",(long)lex.current_line);
emit2(n->token);
return tmp1;
510: Inside #if defined(DEBUG)
tmp1=do_docode(CAR(n),DO_LVALUE);
#ifdef DEBUG
if(tmp1 != 2)
- fatal("HELP! FATAL INTERNAL COMPILER ERROR (again)\n");
+ fatal("HELP! FATAL INTERNAL COMPILER ERROR (1)\n");
#endif
if(flags & DO_POP)
527: Inside #if defined(DEBUG)
tmp1=do_docode(CAR(n),DO_LVALUE);
#ifdef DEBUG
if(tmp1 != 2)
- fatal("HELP! FATAL INTERNAL COMPILER ERROR (yet again)\n");
+ fatal("HELP! FATAL INTERNAL COMPILER ERROR (2)\n");
#endif
if(flags & DO_POP)
{
703:
return 1;
}
else if(CAR(n)->token == F_IDENTIFIER &&
- IDENTIFIER_IS_FUNCTION(ID_FROM_INT(& fake_program, CAR(n)->u.number)->identifier_flags))
+ IDENTIFIER_IS_FUNCTION(ID_FROM_INT(new_program, CAR(n)->u.number)->identifier_flags))
{
emit2(F_MARK);
do_docode(CDR(n),0);
722:
tmp=findstring("call_function");
if(!tmp) yyerror("No call_function efun.");
- if(!find_module_identifier(tmp))
+ foo=find_module_identifier(tmp);
+ if(!foo || !foo->token==F_CONSTANT)
{
yyerror("No call_function efun.");
}else{
- tmp1=store_constant(sp-1, 1);
- pop_stack();
+ tmp1=store_constant(& foo->u.sval, 1);
emit(F_APPLY, tmp1);
}
-
+ free_node(foo);
return 1;
}
1065:
}
case F_LOCAL:
- if(n->u.number >= local_variables->max_number_of_locals)
+ if(n->u.number >= compiler_frame->max_number_of_locals)
yyerror("Illegal to use local variable here.");
if(flags & DO_LVALUE)
{
1077:
}
case F_IDENTIFIER:
- if(IDENTIFIER_IS_FUNCTION(ID_FROM_INT(& fake_program, n->u.number)->identifier_flags))
+ if(IDENTIFIER_IS_FUNCTION(ID_FROM_INT(new_program, n->u.number)->identifier_flags))
{
if(flags & DO_LVALUE)
{