Branch: Tag:

1998-01-13

1998-01-13 23:01:47 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

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

8:      #include <stdarg.h>   #include "global.h" + #include "pike_types.h" + #include "svalue.h"      #define LFUN___INIT 0   #define LFUN_CREATE 1
57:   struct svalue;   #endif    + #ifndef STRUCT_NODE_S_DECLARED + #define STRUCT_NODE_S_DECLARED + struct node_s; + #endif +    #ifndef STRUCT_OBJECT_DECLARED   #define STRUCT_OBJECT_DECLARED   struct object;
133:   {    unsigned INT16 inherit_offset;    unsigned INT16 identifier_offset; -  INT16 id_flags; /* ID_* static, private etc.. */ +  INT16 id_flags; /* static, private etc.. */   };    -  +    struct inherit   { -  struct program *prog; +     INT16 inherit_level; /* really needed? */    INT16 identifier_level; -  +  INT16 parent_identifier;    INT32 storage_offset; -  +  struct object *parent; +  struct program *prog; +  struct pike_string *name;   };    - #define PROG_DESTRUCT_IMMEDIATE 1 + /* program parts have been realloced into one block */ + #define PROGRAM_OPTIMIZED 1    -  + /* program has gone through pass 1 of compiler, prototypes etc. will +  * not change from now on +  */ + #define PROGRAM_FIXED 2 +  + /* Program is done and can be cloned */ + #define PROGRAM_FINISHED 4 +  + /* Program has gone through first compiler pass */ + #define PROGRAM_PASS_1_DONE 8 +  + /* Program will be destructed as soon at it runs out of references. */ + #define PROGRAM_DESTRUCT_IMMEDIATE 15 +    struct program   {    INT32 refs;    INT32 id; /* used to identify program in caches */ -  +  INT32 flags;    INT32 storage_needed; /* storage needed in the object struct */       struct program *next;    struct program *prev; -  unsigned char *program; -  struct pike_string **strings; -  struct inherit *inherits; -  struct reference *identifier_references; -  struct identifier *identifiers; -  unsigned INT16 *identifier_index; -  struct svalue *constants; -  char *linenumbers; +     void (*init)(struct object *);    void (*exit)(struct object *);    void (*gc_marked)(struct object *);
173:   #endif /* PROFILING */       SIZE_T total_size; -  SIZE_T num_linenumbers; -  SIZE_T program_size; -  unsigned INT16 flags; -  unsigned INT16 num_constants; -  unsigned INT16 num_strings; -  unsigned INT16 num_identifiers; -  unsigned INT16 num_identifier_references; -  unsigned INT16 num_identifier_indexes; -  unsigned INT16 num_inherits; +  + #define FOO(NUMTYPE,TYPE,NAME) TYPE * NAME ; + #include "program_areas.h" +  + #define FOO(NUMTYPE,TYPE,NAME) NUMTYPE PIKE_CONCAT(num_,NAME) ; + #include "program_areas.h" +     INT16 lfuns[NUM_LFUNS];   };   
192:   #define PROG_FROM_INT(P,X) PROG_FROM_PTR(P,(P)->identifier_references+(X))   #define ID_FROM_INT(P,X) ID_FROM_PTR(P,(P)->identifier_references+(X))    + #define FIND_LFUN(P,N) ((P)->flags & PROGRAM_FIXED?(P)->lfuns[(N)]:find_identifier(lfun_names[(N)],(P))) +    #define free_program(p) do{ struct program *_=(p); if(!--_->refs) really_free_program(_); }while(0)      extern struct object fake_object; - extern struct program fake_program; + extern struct program *new_program;   extern struct program *first_program; -  + extern int compiler_pass;    -  + #define FOO(NUMTYPE,TYPE,NAME) void PIKE_CONCAT(add_to_,NAME(TYPE ARG)); + #include "program_areas.h" +    /* Prototypes begin here */ -  + void ins_int(INT32 i, void (*func)(char tmp)); + void ins_short(INT16 i, void (*func)(char tmp));   void use_module(struct svalue *s); - int find_module_identifier(struct pike_string *ident); + struct node_s *find_module_identifier(struct pike_string *ident); + struct program *parent_compilation(int level);   struct program *id_to_program(INT32 id); - void setup_fake_program(void); + void optimize_program(struct program *p); + void fixate_program(void); + void low_start_new_program(struct program *p, +  struct pike_string *name, +  int flags);   void start_new_program(void);   void really_free_program(struct program *p);   void dump_program_desc(struct program *p); - void toss_current_program(void); +    void check_program(struct program *p); -  + struct program *end_first_pass(int finish);   struct program *end_program(void);   SIZE_T add_storage(SIZE_T size);   void set_init_callback(void (*init)(struct object *));   void set_exit_callback(void (*exit)(struct object *));   void set_gc_mark_callback(void (*m)(struct object *)); - int low_reference_inherited_identifier(int e,struct pike_string *name); + int low_reference_inherited_identifier(int e, +  struct pike_string *name);   int reference_inherited_identifier(struct pike_string *super_name,    struct pike_string *function_name);   void rename_last_inherit(struct pike_string *n); - void do_inherit(struct program *p,INT32 flags, struct pike_string *name); - void simple_do_inherit(struct pike_string *s, INT32 flags,struct pike_string *name); + void do_inherit(struct svalue *prog, +  INT32 flags, +  struct pike_string *name); + void simple_do_inherit(struct pike_string *s, +  INT32 flags, +  struct pike_string *name);   int isidentifier(struct pike_string *s);   int low_define_variable(struct pike_string *name,    struct pike_string *type,
261:    INT16 flags,    INT8 function_flags,    union idptr *func); + int low_find_shared_string_identifier(struct pike_string *name, +  struct program *prog);   struct ff_hash;   int find_shared_string_identifier(struct pike_string *name,    struct program *prog);
270:   void start_line_numbering(void);   void store_linenumber(INT32 current_line, struct pike_string *current_file);   char *get_line(unsigned char *pc,struct program *prog,INT32 *linep); - void my_yyerror(char *fmt,...); - void compile(void); - struct program *compile_file(struct pike_string *file_name); - struct program *compile_string(struct pike_string *prog, -  struct pike_string *name); + void my_yyerror(char *fmt,...) ATTRIBUTE((format(printf,1,2))); + struct program *compile(struct pike_string *prog);   void add_function(char *name,void (*cfun)(INT32),char *type,INT16 flags);   void check_all_programs(void);   void cleanup_program(void);
283:   void gc_mark_all_programs(void);   void gc_free_all_unreferenced_programs(void);   void count_memory_in_programs(INT32 *num_, INT32 *size_); - void push_locals(void); - void pop_locals(void); + void push_compiler_frame(void); + void pop_local_variables(int level); + void pop_compiler_frame(void);   char *get_storage(struct object *o, struct program *p); -  + struct program *low_program_from_function(struct program *p, +  INT32 i); + struct program *program_from_function(struct svalue *f); + struct program *program_from_svalue(struct svalue *s); + struct find_child_cache_s; + int find_child(struct program *parent, struct program *child); + void yywarning(char *fmt, ...) ATTRIBUTE((format(printf,1,2)));   /* Prototypes end here */       - void my_yyerror(char *fmt,...) ATTRIBUTE((format (printf, 1, 2))); -  +    #endif -  -  -  -  +