00001
00002
00003
00004
00005
00006
00007
00008 #ifndef PROGRAM_H
00009 #define PROGRAM_H
00010
00011 #include <stdarg.h>
00012 #include "global.h"
00013 #include "pike_macros.h"
00014 #include "pike_error.h"
00015 #include "svalue.h"
00016 #include "dmalloc.h"
00017 #include "time_stuff.h"
00018 #include "program_id.h"
00019 #include "pike_rusage.h"
00020 #include "block_alloc_h.h"
00021
00022
00023 PMOD_PROTO extern struct program_state * Pike_compiler;
00024
00025
00026 #define COMPILATION_CHECK_FINAL 0x01
00027
00028
00029 #define COMPILATION_FORCE_RESOLVE 0x02
00030
00031
00032
00033 #ifdef FORCE_RESOLVE_DEBUG
00034 #define DO_IF_FRD(X) X
00035 #else
00036 #define DO_IF_FRD(X)
00037 #endif
00038 #define SET_FORCE_RESOLVE(OLD) do { \
00039 int tmp_ = (OLD) = Pike_compiler->flags; \
00040 Pike_compiler->flags |= COMPILATION_FORCE_RESOLVE; \
00041 DO_IF_FRD(fprintf(stderr, \
00042 "Force resolve on. Flags:0x%04x (0x%04x)\n", \
00043 Pike_compiler->flags, tmp_)); \
00044 } while(0)
00045 #define UNSET_FORCE_RESOLVE(OLD) do { \
00046 int tmp_ = (Pike_compiler->flags & ~COMPILATION_FORCE_RESOLVE) | \
00047 ((OLD) & COMPILATION_FORCE_RESOLVE); \
00048 DO_IF_FRD(fprintf(stderr, \
00049 "Force resolve unset. Flags:0x%04x (0x%04x)\n", \
00050 tmp_, Pike_compiler->flags)); \
00051 Pike_compiler->flags = tmp_; \
00052 } while(0)
00053
00054 extern struct pike_string *this_program_string;
00055
00056 #define LFUN___INIT 0
00057 #define LFUN_CREATE 1
00058 #define LFUN_DESTROY 2
00059 #define LFUN_ADD 3
00060 #define LFUN_SUBTRACT 4
00061 #define LFUN_AND 5
00062 #define LFUN_OR 6
00063 #define LFUN_XOR 7
00064 #define LFUN_LSH 8
00065 #define LFUN_RSH 9
00066 #define LFUN_MULTIPLY 10
00067 #define LFUN_DIVIDE 11
00068 #define LFUN_MOD 12
00069 #define LFUN_COMPL 13
00070 #define LFUN_EQ 14
00071 #define LFUN_LT 15
00072 #define LFUN_GT 16
00073 #define LFUN___HASH 17
00074 #define LFUN_CAST 18
00075 #define LFUN_NOT 19
00076 #define LFUN_INDEX 20
00077 #define LFUN_ASSIGN_INDEX 21
00078 #define LFUN_ARROW 22
00079 #define LFUN_ASSIGN_ARROW 23
00080 #define LFUN__SIZEOF 24
00081 #define LFUN__INDICES 25
00082 #define LFUN__VALUES 26
00083 #define LFUN_CALL 27
00084 #define LFUN_RADD 28
00085 #define LFUN_RSUBTRACT 29
00086 #define LFUN_RAND 30
00087 #define LFUN_ROR 31
00088 #define LFUN_RXOR 32
00089 #define LFUN_RLSH 33
00090 #define LFUN_RRSH 34
00091 #define LFUN_RMULTIPLY 35
00092 #define LFUN_RDIVIDE 36
00093 #define LFUN_RMOD 37
00094 #define LFUN_ADD_EQ 38
00095 #define LFUN__IS_TYPE 39
00096 #define LFUN__SPRINTF 40
00097 #define LFUN__EQUAL 41
00098 #define LFUN__M_DELETE 42
00099 #define LFUN__GET_ITERATOR 43
00100 #define LFUN_RANGE 44
00101
00102 #define NUM_LFUNS 45
00103
00104
00105
00106
00107 #define LFUN__SEARCH 45
00108
00109 extern const char *const lfun_names[];
00110
00111 extern struct pike_string *lfun_strings[];
00112
00113 #ifndef STRUCT_NODE_S_DECLARED
00114 #define STRUCT_NODE_S_DECLARED
00115 struct node_s;
00116 typedef struct node_s node;
00117 #endif
00118
00119 #ifndef STRUCT_OBJECT_DECLARED
00120 #define STRUCT_OBJECT_DECLARED
00121 struct object;
00122 #endif
00123
00124 #define STRUCT
00125 #include "compilation.h"
00126
00127 #define EXTERN
00128 #include "compilation.h"
00129
00130
00131 #define PIKE_BYTECODE_PORTABLE -1
00132 #define PIKE_BYTECODE_DEFAULT 0
00133 #define PIKE_BYTECODE_GOTO 1
00134 #define PIKE_BYTECODE_SPARC 2
00135 #define PIKE_BYTECODE_IA32 3
00136 #define PIKE_BYTECODE_PPC32 4
00137
00138 #if PIKE_BYTECODE_METHOD == PIKE_BYTECODE_IA32
00139 #define PIKE_OPCODE_T unsigned INT8
00140 #elif PIKE_BYTECODE_METHOD == PIKE_BYTECODE_SPARC
00141 #define PIKE_OPCODE_T unsigned INT32
00142 #elif PIKE_BYTECODE_METHOD == PIKE_BYTECODE_PPC32
00143 #define PIKE_OPCODE_T unsigned INT32
00144 #elif PIKE_BYTECODE_METHOD == PIKE_BYTECODE_GOTO
00145 #define PIKE_OPCODE_T void *
00146 #define PIKE_INSTR_T void *
00147 #else
00148 #define PIKE_OPCODE_T unsigned INT8
00149 #endif
00150
00151 #ifndef PIKE_INSTR_T
00152
00153
00154
00155 #define PIKE_INSTR_T unsigned int
00156 #endif
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 union idptr
00181 {
00182
00183 void (*c_fun)(INT32);
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 ptrdiff_t offset;
00200 };
00201
00202 #define IDENTIFIER_VARIABLE 0
00203 #define IDENTIFIER_PIKE_FUNCTION 1
00204 #define IDENTIFIER_C_FUNCTION 2
00205 #define IDENTIFIER_FUNCTION 3
00206 #define IDENTIFIER_CONSTANT 4
00207 #define IDENTIFIER_TYPE_MASK 7
00208
00209 #define IDENTIFIER_VARARGS 8
00210 #define IDENTIFIER_NO_THIS_REF 8
00211 #define IDENTIFIER_HAS_BODY 16
00212 #define IDENTIFIER_SCOPED 32
00213 #define IDENTIFIER_SCOPE_USED 64
00214 #define IDENTIFIER_ALIAS 128
00215
00216 #define IDENTIFIER_IS_FUNCTION(X) ((X) & IDENTIFIER_FUNCTION)
00217 #define IDENTIFIER_IS_PIKE_FUNCTION(X) ((X) & IDENTIFIER_PIKE_FUNCTION)
00218 #define IDENTIFIER_IS_C_FUNCTION(X) ((X) & IDENTIFIER_C_FUNCTION)
00219 #define IDENTIFIER_IS_CONSTANT(X) ((X) & IDENTIFIER_CONSTANT)
00220 #define IDENTIFIER_IS_VARIABLE(X) (!((X) & IDENTIFIER_TYPE_MASK))
00221 #define IDENTIFIER_IS_ALIAS(X) ((X) & IDENTIFIER_ALIAS)
00222
00223 #define IDENTIFIER_MASK 255
00224
00225
00226
00227
00228
00229 struct identifier
00230 {
00231 struct pike_string *name;
00232 struct pike_type *type;
00233 unsigned INT8 identifier_flags;
00234 unsigned INT8 run_time_type;
00235 unsigned INT16 opt_flags;
00236 #ifdef PROFILING
00237 unsigned INT32 num_calls;
00238 cpu_time_t total_time;
00239 cpu_time_t self_time;
00240 #endif
00241 union idptr func;
00242 };
00243
00244
00245
00246
00247
00248
00249 struct program_constant
00250 {
00251 struct svalue sval;
00252 ptrdiff_t offset;
00253 };
00254
00255
00256
00257
00258
00259
00260
00261
00262 #define ID_STATIC 0x01
00263 #define ID_PRIVATE 0x02
00264 #define ID_NOMASK 0x04
00265 #define ID_PUBLIC 0x08
00266 #define ID_PROTECTED 0x10
00267 #define ID_INLINE 0x20
00268 #define ID_HIDDEN 0x40
00269 #define ID_INHERITED 0x80
00270 #define ID_OPTIONAL 0x100
00271 #define ID_EXTERN 0x200
00272 #define ID_VARIANT 0x400
00273 #define ID_ALIAS 0x800
00274
00275 #define ID_MODIFIER_MASK 0x0fff
00276
00277 #define ID_STRICT_TYPES 0x8000
00278 #define ID_SAVE_PARENT 0x10000
00279 #define ID_DONT_SAVE_PARENT 0x20000
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293 struct reference
00294 {
00295
00296
00297
00298 unsigned INT16 inherit_offset;
00299
00300
00301
00302
00303 unsigned INT16 identifier_offset;
00304
00305
00306 INT16 id_flags;
00307 };
00308
00309
00310 #define IDREF_MAGIC_THIS -1
00311
00312
00313 #define OBJECT_PARENT -18
00314 #define INHERIT_PARENT -17
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325 struct inherit
00326 {
00327
00328
00329
00330
00331
00332
00333
00334
00335 INT16 inherit_level;
00336
00337
00338
00339 INT16 identifier_level;
00340
00341
00342
00343
00344
00345 INT16 parent_identifier;
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390 INT16 parent_offset;
00391
00392
00393
00394
00395
00396
00397
00398
00399 size_t identifier_ref_offset;
00400
00401
00402
00403 ptrdiff_t storage_offset;
00404
00405
00406
00407 struct object *parent;
00408
00409
00410 struct program *prog;
00411
00412
00413
00414 struct pike_string *name;
00415 };
00416
00417
00418
00419
00420
00421
00422 struct pike_trampoline
00423 {
00424 struct pike_frame *frame;
00425 INT32 func;
00426 };
00427
00428
00429
00430
00431 #define PROGRAM_OPTIMIZED 1
00432
00433
00434
00435
00436 #define PROGRAM_FIXED 2
00437
00438
00439 #define PROGRAM_FINISHED 4
00440
00441
00442 #define PROGRAM_PASS_1_DONE 8
00443
00444
00445
00446
00447 #define PROGRAM_DESTRUCT_IMMEDIATE 0x10
00448
00449
00450 #define PROGRAM_HAS_C_METHODS 0x20
00451
00452
00453 #define PROGRAM_CONSTANT 0x40
00454
00455
00456
00457 #define PROGRAM_USES_PARENT 0x80
00458
00459
00460
00461 #define PROGRAM_NO_WEAK_FREE 0x100
00462
00463
00464 #define PROGRAM_NO_EXPLICIT_DESTRUCT 0x200
00465
00466
00467 #define PROGRAM_AVOID_CHECK 0x400
00468
00469
00470 #define PROGRAM_VIRGIN 0x800
00471
00472
00473
00474 #define PROGRAM_NEEDS_PARENT 0x1000
00475
00476
00477 #define PROGRAM_IS_FACET_CLASS 0x1
00478 #define PROGRAM_IS_PRODUCT_CLASS 0x2
00479
00480
00481 #define PROG_EVENT_INIT 0
00482 #define PROG_EVENT_EXIT 1
00483 #define PROG_EVENT_GC_RECURSE 2
00484 #define PROG_EVENT_GC_CHECK 3
00485 #define NUM_PROG_EVENTS 4
00486
00487
00488
00489
00490 #define LOW_PARENT_INFO(O,P) ((struct parent_info *)(PIKE_OBJ_STORAGE((O)) + (P)->parent_info_storage))
00491 #define PARENT_INFO(O) LOW_PARENT_INFO( (O), (O)->prog)
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501 struct parent_info
00502 {
00503 struct object *parent;
00504 INT16 parent_identifier;
00505 };
00506
00507 struct program
00508 {
00509 PIKE_MEMORY_OBJECT_MEMBERS;
00510
00511 INT32 id;
00512
00513
00514
00515
00516 ptrdiff_t storage_needed;
00517 ptrdiff_t xstorage;
00518 ptrdiff_t parent_info_storage;
00519
00520 INT16 flags;
00521 unsigned INT8 alignment_needed;
00522 struct timeval timestamp;
00523
00524 struct program *next;
00525 struct program *prev;
00526 struct program *parent;
00527
00528 node *(*optimize)(node *n);
00529
00530 void (*event_handler)(int);
00531 #ifdef PIKE_DEBUG
00532 unsigned INT32 checksum;
00533 #endif
00534 #ifdef PROFILING
00535 unsigned INT32 num_clones;
00536 #endif
00537
00538 size_t total_size;
00539
00540 #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) TYPE * NAME ;
00541 #include "program_areas.h"
00542
00543 #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) NUMTYPE PIKE_CONCAT(num_,NAME) ;
00544 #include "program_areas.h"
00545
00546 INT16 lfuns[NUM_LFUNS];
00547
00548
00549 INT16 facet_class;
00550 INT32 facet_index;
00551 struct object *facet_group;
00552 };
00553
00554 #if 0
00555 static INLINE int CHECK_IDREF_RANGE (int x, const struct program *p)
00556 {
00557 if (x < 0 || x >= p->num_identifier_references)
00558 debug_fatal ("Identifier reference index %d out of range 0..%d\n", x,
00559 p->num_identifier_references - 1);
00560 return x;
00561 }
00562 #else
00563 #define CHECK_IDREF_RANGE(X, P) (X)
00564 #endif
00565
00566 #define PTR_FROM_INT(P, X) ((P)->identifier_references + \
00567 CHECK_IDREF_RANGE((X), (P)))
00568
00569 #define INHERIT_FROM_PTR(P,X) (dmalloc_touch(struct program *,(P))->inherits + (X)->inherit_offset)
00570 #define PROG_FROM_PTR(P,X) (dmalloc_touch(struct program *,INHERIT_FROM_PTR(P,X)->prog))
00571 #define ID_FROM_PTR(P,X) (PROG_FROM_PTR(P,X)->identifiers+(X)->identifier_offset)
00572 #define INHERIT_FROM_INT(P,X) INHERIT_FROM_PTR(P, PTR_FROM_INT(P, X))
00573 #define PROG_FROM_INT(P,X) PROG_FROM_PTR(P, PTR_FROM_INT(P, X))
00574 #define ID_FROM_INT(P,X) ID_FROM_PTR(P, PTR_FROM_INT(P, X))
00575
00576 #define FIND_LFUN(P,N) ( dmalloc_touch(struct program *,(P))->flags & PROGRAM_FIXED?((P)->lfuns[(N)]):low_find_lfun((P), (N)) )
00577 #define QUICK_FIND_LFUN(P,N) (dmalloc_touch(struct program *,(P))->lfuns[N])
00578
00579 #ifdef DO_PIKE_CLEANUP
00580 extern int gc_external_refs_zapped;
00581 void gc_check_zapped (void *a, TYPE_T type, const char *file, int line);
00582 #endif
00583
00584 #define free_program(p) do{ \
00585 struct program *_=(p); \
00586 debug_malloc_touch(_); \
00587 DO_IF_DEBUG ( \
00588 DO_IF_PIKE_CLEANUP ( \
00589 if (gc_external_refs_zapped) \
00590 gc_check_zapped (_, PIKE_T_PROGRAM, __FILE__, __LINE__))); \
00591 if(!sub_ref(_)) \
00592 really_free_program(_); \
00593 }while(0)
00594
00595 BLOCK_ALLOC_FILL_PAGES(program, n/a);
00596
00597
00598 extern struct object *error_handler;
00599 extern struct object *compat_handler;
00600
00601 extern struct program *first_program;
00602 extern struct program *null_program;
00603 extern struct program *pike_trampoline_program;
00604 extern struct program *gc_internal_program;
00605 extern struct program *placeholder_program;
00606 extern struct object *placeholder_object;
00607
00608 extern int compilation_depth;
00609
00610
00611 #define SEE_STATIC 1
00612 #define SEE_PRIVATE 2
00613
00614
00615 #define COMPILER_IN_CATCH 1
00616
00617 #define ADD_STORAGE(X) low_add_storage(sizeof(X), ALIGNOF(X),0)
00618
00619 #define STORAGE_NEEDED(X) ((X)->storage_needed - (X)->inherits[0].storage_offset)
00620
00621 #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) void PIKE_CONCAT(add_to_,NAME(ARGTYPE ARG));
00622 #include "program_areas.h"
00623
00624 typedef int supporter_callback (void *, int);
00625 struct Supporter
00626 {
00627 #ifdef PIKE_DEBUG
00628 int magic;
00629 #endif
00630 struct Supporter *previous;
00631 struct Supporter *depends_on;
00632 struct Supporter *dependants;
00633 struct Supporter *next_dependant;
00634 supporter_callback *fun;
00635 void *data;
00636 struct program *prog;
00637 };
00638
00639
00640
00641
00642 void ins_int(INT32 i, void (*func)(char tmp));
00643 void ins_short(int i, void (*func)(char tmp));
00644 void add_relocated_int_to_program(INT32 i);
00645 void use_module(struct svalue *s);
00646 void unuse_modules(INT32 howmany);
00647 node *find_module_identifier(struct pike_string *ident,
00648 int see_inherit);
00649 node *resolve_identifier(struct pike_string *ident);
00650 node *program_magic_identifier (struct program_state *state,
00651 int state_depth, int inherit_num,
00652 struct pike_string *ident,
00653 int colon_colon_ref);
00654 struct program *parent_compilation(int level);
00655 struct program *id_to_program(INT32 id);
00656 void optimize_program(struct program *p);
00657 void fsort_program_identifier_index(unsigned short *start,
00658 unsigned short *end,
00659 struct program *p);
00660 struct pike_string *find_program_name(struct program *p, INT32 *line);
00661 int override_identifier (struct reference *ref, struct pike_string *name);
00662 void fixate_program(void);
00663 struct program *low_allocate_program(void);
00664 void low_start_new_program(struct program *p,
00665 int pass,
00666 struct pike_string *name,
00667 int flags,
00668 int *idp);
00669 PMOD_EXPORT void debug_start_new_program(int line, const char *file);
00670 void dump_program_desc(struct program *p);
00671 int sizeof_variable(int run_time_type);
00672 void dump_program_tables (struct program *p, int indent);
00673 void check_program(struct program *p);
00674 struct program *end_first_pass(int finish);
00675 PMOD_EXPORT struct program *debug_end_program(void);
00676 PMOD_EXPORT size_t low_add_storage(size_t size, size_t alignment,
00677 ptrdiff_t modulo_orig);
00678 PMOD_EXPORT void set_init_callback(void (*init_callback)(struct object *));
00679 PMOD_EXPORT void set_exit_callback(void (*exit_callback)(struct object *));
00680 PMOD_EXPORT void set_gc_recurse_callback(void (*m)(struct object *));
00681 PMOD_EXPORT void set_gc_check_callback(void (*m)(struct object *));
00682 void pike_set_prog_event_callback(void (*cb)(int));
00683 void pike_set_prog_optimize_callback(node *(*opt)(node *));
00684 int really_low_reference_inherited_identifier(struct program_state *q,
00685 int e,
00686 int i);
00687 int low_reference_inherited_identifier(struct program_state *q,
00688 int e,
00689 struct pike_string *name,
00690 int flags);
00691 int find_inherit(struct program *p, struct pike_string *name);
00692 node *reference_inherited_identifier(struct pike_string *super_name,
00693 struct pike_string *function_name);
00694 void rename_last_inherit(struct pike_string *n);
00695 void low_inherit(struct program *p,
00696 struct object *parent,
00697 int parent_identifier,
00698 int parent_offset,
00699 INT32 flags,
00700 struct pike_string *name);
00701 PMOD_EXPORT void do_inherit(struct svalue *s,
00702 INT32 flags,
00703 struct pike_string *name);
00704 void compiler_do_inherit(node *n, INT32 flags, struct pike_string *name);
00705 int call_handle_inherit(struct pike_string *s);
00706 void simple_do_inherit(struct pike_string *s,
00707 INT32 flags,
00708 struct pike_string *name);
00709 int isidentifier(struct pike_string *s);
00710 int low_define_variable(struct pike_string *name,
00711 struct pike_type *type,
00712 INT32 flags,
00713 size_t offset,
00714 INT32 run_time_type);
00715 PMOD_EXPORT int map_variable(const char *name,
00716 const char *type,
00717 INT32 flags,
00718 size_t offset,
00719 INT32 run_time_type);
00720 PMOD_EXPORT int quick_map_variable(const char *name,
00721 int name_length,
00722 size_t offset,
00723 const char *type,
00724 int type_length,
00725 INT32 run_time_type,
00726 INT32 flags);
00727 int define_variable(struct pike_string *name,
00728 struct pike_type *type,
00729 INT32 flags);
00730 PMOD_EXPORT int simple_add_variable(const char *name,
00731 const char *type,
00732 INT32 flags);
00733 PMOD_EXPORT int add_constant(struct pike_string *name,
00734 struct svalue *c,
00735 INT32 flags);
00736 PMOD_EXPORT int simple_add_constant(const char *name,
00737 struct svalue *c,
00738 INT32 flags);
00739 PMOD_EXPORT int add_integer_constant(const char *name,
00740 INT_ARG_TYPE i,
00741 INT32 flags);
00742 PMOD_EXPORT int quick_add_integer_constant(const char *name,
00743 int name_length,
00744 INT_ARG_TYPE i,
00745 INT32 flags);
00746 PMOD_EXPORT int add_float_constant(const char *name,
00747 FLOAT_ARG_TYPE f,
00748 INT32 flags);
00749 PMOD_EXPORT int quick_add_float_constant(const char *name,
00750 int name_length,
00751 FLOAT_ARG_TYPE f,
00752 INT32 flags);
00753 PMOD_EXPORT int add_string_constant(const char *name,
00754 const char *str,
00755 INT32 flags);
00756 PMOD_EXPORT int add_program_constant(const char *name,
00757 struct program *p,
00758 INT32 flags);
00759 PMOD_EXPORT int add_object_constant(const char *name,
00760 struct object *o,
00761 INT32 flags);
00762 PMOD_EXPORT int add_function_constant(const char *name, void (*cfun)(INT32), const char * type, int flags);
00763 PMOD_EXPORT int debug_end_class(const char *name, ptrdiff_t namelen, INT32 flags);
00764 INT32 define_function(struct pike_string *name,
00765 struct pike_type *type,
00766 unsigned flags,
00767 unsigned function_flags,
00768 union idptr *func,
00769 unsigned opt_flags);
00770 int really_low_find_shared_string_identifier(struct pike_string *name,
00771 struct program *prog,
00772 int flags);
00773 int low_find_lfun(struct program *p, ptrdiff_t lfun);
00774 int lfun_lookup_id(struct pike_string *lfun_name);
00775 int low_find_shared_string_identifier(struct pike_string *name,
00776 struct program *prog);
00777 struct ff_hash;
00778 int find_shared_string_identifier(struct pike_string *name,
00779 struct program *prog);
00780 PMOD_EXPORT int find_identifier(const char *name,struct program *prog);
00781 int store_prog_string(struct pike_string *str);
00782 int store_constant(struct svalue *foo,
00783 int equal,
00784 struct pike_string *constant_name);
00785 struct array *program_indices(struct program *p);
00786 struct array *program_values(struct program *p);
00787 void program_index_no_free(struct svalue *to, struct program *p,
00788 struct svalue *ind);
00789 int get_small_number(char **q);
00790 void ext_store_program_line (struct program *prog, INT32 line, struct pike_string *file);
00791 void start_line_numbering(void);
00792 void store_linenumber(INT32 current_line, struct pike_string *current_file);
00793 PMOD_EXPORT struct pike_string *low_get_program_line(struct program *prog,
00794 INT32 *linep);
00795 PMOD_EXPORT struct pike_string *get_program_line(struct program *prog,
00796 INT32 *linep);
00797 PMOD_EXPORT char *low_get_program_line_plain (struct program *prog, INT32 *linep,
00798 int malloced);
00799 PMOD_EXPORT struct pike_string *low_get_line(PIKE_OPCODE_T *pc,
00800 struct program *prog, INT32 *linep);
00801 PMOD_EXPORT char *low_get_line_plain (PIKE_OPCODE_T *pc, struct program *prog,
00802 INT32 *linep, int malloced);
00803 PMOD_EXPORT struct pike_string *get_line(PIKE_OPCODE_T *pc,
00804 struct program *prog, INT32 *linep);
00805 PMOD_EXPORT struct pike_string *low_get_function_line (struct object *o,
00806 int fun, INT32 *linep);
00807 void va_yyerror(const char *fmt, va_list args);
00808 void my_yyerror(const char *fmt,...);
00809 struct pike_string *format_exception_for_error_msg (struct svalue *thrown);
00810 void handle_compile_exception (const char *yyerror_fmt, ...);
00811 struct supporter_marker;
00812 void verify_supporters(void);
00813 void init_supporter(struct Supporter *s,
00814 supporter_callback *fun,
00815 void *data);
00816 int unlink_current_supporter(struct Supporter *c);
00817 int call_dependants(struct Supporter *s, int finish);
00818 int report_compiler_dependency(struct program *p);
00819 struct compilation;
00820 void run_pass2(struct compilation *c);
00821 struct program *compile(struct pike_string *aprog,
00822 struct object *ahandler,
00823 int amajor, int aminor,
00824 struct program *atarget,
00825 struct object *aplaceholder);
00826 PMOD_EXPORT int pike_add_function2(const char *name, void (*cfun)(INT32),
00827 const char *type, unsigned flags,
00828 unsigned opt_flags);
00829 PMOD_EXPORT int quick_add_function(const char *name,
00830 int name_length,
00831 void (*cfun)(INT32),
00832 const char *type,
00833 int type_length,
00834 unsigned flags,
00835 unsigned opt_flags);
00836 void check_all_programs(void);
00837 void placeholder_index(INT32 args);
00838 void init_program(void);
00839 void cleanup_program(void);
00840 void gc_mark_program_as_referenced(struct program *p);
00841 void real_gc_cycle_check_program(struct program *p, int weak);
00842 unsigned gc_touch_all_programs(void);
00843 void gc_check_all_programs(void);
00844 void gc_mark_all_programs(void);
00845 void gc_cycle_check_all_programs(void);
00846 void gc_zap_ext_weak_refs_in_programs(void);
00847 size_t gc_free_all_unreferenced_programs(void);
00848 void push_compiler_frame(int lexical_scope);
00849 void low_pop_local_variables(int level);
00850 void pop_local_variables(int level);
00851 void pop_compiler_frame(void);
00852 ptrdiff_t low_get_storage(struct program *o, struct program *p);
00853 PMOD_EXPORT char *get_storage(struct object *o, struct program *p);
00854 struct program *low_program_from_function(struct program *p,
00855 INT32 i);
00856 PMOD_EXPORT struct program *program_from_function(const struct svalue *f);
00857 PMOD_EXPORT struct program *program_from_svalue(const struct svalue *s);
00858 struct find_child_cache_s;
00859 int find_child(struct program *parent, struct program *child);
00860 void yywarning(char *fmt, ...);
00861 struct implements_cache_s;
00862 PMOD_EXPORT int implements(struct program *a, struct program *b);
00863 PMOD_EXPORT int is_compatible(struct program *a, struct program *b);
00864 void yyexplain_not_compatible(struct program *a, struct program *b, int flags);
00865 void yyexplain_not_implements(struct program *a, struct program *b, int flags);
00866 PMOD_EXPORT void *parent_storage(int depth);
00867 PMOD_EXPORT void change_compiler_compatibility(int major, int minor);
00868 void make_program_executable(struct program *p);
00869
00870
00871 void really_free_program(struct program *);
00872 void count_memory_in_programs(INT32*,INT32*);
00873
00874 #ifndef PIKE_USE_MACHINE_CODE
00875 #define make_program_executable(X)
00876 #endif
00877
00878 #define ADD_FUNCTION(NAME, FUNC, TYPE, FLAGS) \
00879 quick_add_function(NAME, CONSTANT_STRLEN(NAME), FUNC, TYPE,\
00880 CONSTANT_STRLEN(TYPE), FLAGS, \
00881 OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND)
00882
00883 #define ADD_PROTOTYPE(NAME, TYPE, FLAGS) \
00884 ADD_FUNCTION(NAME, 0, TYPE, FLAGS)
00885
00886 #define ADD_FUNCTION2(NAME, FUNC, TYPE, FLAGS, OPT_FLAGS) \
00887 quick_add_function(NAME, CONSTANT_STRLEN(NAME), FUNC, TYPE,\
00888 CONSTANT_STRLEN(TYPE), FLAGS, OPT_FLAGS)
00889
00890 #define ADD_PROTOTYPE2(NAME, TYPE, FLAGS, OPT_FLAGS) \
00891 ADD_FUNCTION2(NAME, 0, TYPE, FLAGS, OPT_FLAGS)
00892
00893 #define ADD_INT_CONSTANT(NAME, CONST, FLAGS) \
00894 quick_add_integer_constant(NAME, CONSTANT_STRLEN(NAME), CONST, FLAGS)
00895
00896 #define ADD_FLOAT_CONSTANT(NAME, CONST, FLAGS) \
00897 quick_add_float_constant(NAME, CONSTANT_STRLEN(NAME), CONST, FLAGS)
00898
00899 #define PIKE_MAP_VARIABLE(NAME, OFFSET, TYPE, RTTYPE, FLAGS) \
00900 quick_map_variable(NAME, CONSTANT_STRLEN(NAME), OFFSET, \
00901 TYPE, CONSTANT_STRLEN(TYPE), RTTYPE, FLAGS)
00902
00903 #define MAP_VARIABLE(NAME, TYPE, FLAGS, OFFSET, RTYPE) \
00904 PIKE_MAP_VARIABLE(NAME, OFFSET, TYPE, RTYPE, FLAGS)
00905
00906 #define ADD_FUNCTION_DTYPE(NAME,FUN,DTYPE,FLAGS) do { \
00907 DTYPE_START; \
00908 {DTYPE} \
00909 { \
00910 struct pike_string *_t; \
00911 DTYPE_END(_t); \
00912 quick_add_function(NAME, CONSTANT_STRLEN(NAME), FUN, \
00913 _t->str, _t->len, FLAGS, \
00914 OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND); \
00915 free_string(_t); \
00916 } \
00917 } while (0)
00918
00919 #define pike_add_function(NAME, CFUN, TYPE, FLAGS) \
00920 pike_add_function2(NAME, CFUN, TYPE, FLAGS, \
00921 OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND)
00922
00923 #ifndef NO_PIKE_SHORTHAND
00924 #define add_function pike_add_function
00925 #endif
00926
00927 #define ADD_INHERIT(PROGRAM, FLAGS) \
00928 low_inherit((PROGRAM), 0, 0, 0, (FLAGS), 0)
00929
00930 #define START_NEW_PROGRAM_ID(ID) do { \
00931 start_new_program(); \
00932 Pike_compiler->new_program->id=PIKE_CONCAT3(PROG_,ID,_ID); \
00933 }while(0)
00934
00935 #ifdef DEBUG_MALLOC
00936 #define end_program() ((struct program *)debug_malloc_pass(debug_end_program()))
00937 #define end_class(NAME, FLAGS) (debug_malloc_touch(Pike_compiler->new_program), debug_end_class(NAME, CONSTANT_STRLEN(NAME), FLAGS))
00938 #else
00939 #define end_class(NAME,FLAGS) debug_end_class(NAME, CONSTANT_STRLEN(NAME), FLAGS)
00940 #define end_program debug_end_program
00941 #endif
00942
00943
00944 #define start_new_program() debug_start_new_program(__LINE__,__FILE__)
00945
00946 #define gc_cycle_check_program(X, WEAK) \
00947 gc_cycle_enqueue((gc_cycle_check_cb *) real_gc_cycle_check_program, (X), (WEAK))
00948
00949
00950
00951
00952
00953 #define Pike_new_program Pike_compiler->new_program
00954
00955
00956
00957 #define TEST_COMPAT(MAJOR,MINOR) \
00958 (Pike_compiler->compat_major < (MAJOR) || \
00959 (Pike_compiler->compat_major == (MAJOR) && \
00960 Pike_compiler->compat_minor <= (MINOR)))
00961
00962 #endif
00963
00964
00965 #ifndef LAS_H
00966
00967
00968
00969 #include "las.h"
00970 #endif