1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
/* 
|| This file is part of Pike. For copyright information see COPYRIGHT. 
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING 
|| for more information. 
*/ 
 
#ifndef LAS_H 
#define LAS_H 
 
#include "global.h" 
#include "svalue.h" 
#include "dynamic_buffer.h" 
#include "block_allocator.h" 
 
#define MAX_GLOBAL_VARIABLES 1000 
typedef void (*c_fun)(INT32); 
 
 
/* Flags used by yytype_error() */ 
#define YYTE_IS_WARNING       1 
 
struct compiler_frame;              /* Avoid gcc warning. */ 
 
int islocal(struct pike_string *str); 
int low_add_local_name(struct compiler_frame *frame, 
                       struct pike_string *str, 
                       struct pike_type *type, 
                       node *def); 
int add_local_name(struct pike_string *str, 
                   struct pike_type *type, 
                   node *def); 
int verify_declared(struct pike_string *str); 
void cleanup_compiler(void); 
 
 
extern int cumulative_parse_error; 
 
 
#ifndef STRUCT_NODE_S_DECLARED 
#define STRUCT_NODE_S_DECLARED 
struct node_s; 
typedef struct node_s node; 
#endif 
 
/* local variable flags */ 
#define LOCAL_VAR_IS_USED             1 
 
struct local_variable 
{ 
  struct pike_string *name; 
  struct pike_type *type; 
  node *def; 
  /* FIXME: Consider moving these two to the def node above? */ 
  struct pike_string *file; 
  int line; 
  unsigned int flags; 
}; 
 
struct compiler_frame 
{ 
  struct compiler_frame *previous; 
 
  struct pike_type *current_type; 
  struct pike_type *current_return_type; 
  int current_number_of_locals; 
  int max_number_of_locals; 
  int min_number_of_locals; 
  int last_block_level; /* used to detect variables declared in same block */ 
  int num_args; 
  int lexical_scope; 
  int current_function_number; 
  int recur_label; 
  int is_inline; 
  unsigned int opt_flags; 
  struct local_variable variable[MAX_LOCAL]; 
}; 
 
/* Also used in struct node_identifier */ 
union node_data 
{ 
  struct 
  { 
    int number; 
    struct program *prog; 
  } id; 
  struct 
  { 
    int ident; 
    struct compiler_frame *frame; 
#ifdef SHARED_NODES 
    struct program *prog; 
#endif 
  } trampoline; 
  struct svalue sval; 
  struct 
  { 
    struct node_s *a, *b; 
  } node; 
  struct 
  { 
    struct node_identifier *a, *b; 
  } node_id; 
  struct 
  { 
    int a, b; 
  } integer; 
}; 
 
struct node_s 
{ 
  unsigned INT32 refs; 
  struct pike_string *current_file; 
  struct pike_type *type; 
  struct pike_string *name; 
  struct node_s *parent; 
  INT_TYPE line_number; 
  unsigned INT16 node_info; 
  unsigned INT16 tree_info; 
  unsigned INT16 pad; 
  /* The stuff from this point on is hashed. */ 
  unsigned INT16 token; 
  union node_data u; 
}; 
 
#define OPT_OPTIMIZED       0x1    /* has been processed by optimize(), 
                                  * only used in node_info 
                                    */ 
#define OPT_NOT_CONST       0x2    /* isn't constant */ 
#define OPT_SIDE_EFFECT     0x4    /* has side effects */ 
#define OPT_ASSIGNMENT      0x8    /* does assignments */ 
#define OPT_TRY_OPTIMIZE    0x10   /* might be worth optimizing */ 
#define OPT_EXTERNAL_DEPEND 0x20   /* the value depends on external 
                                  * influences (such as read_file or so) 
                                    */ 
#define OPT_CASE            0x40   /* contains case(s) */ 
#define OPT_CONTINUE        0x80   /* contains continue(s) */ 
#define OPT_BREAK           0x100  /* contains break(s) */ 
#define OPT_RETURN          0x200  /* contains return(s) */ 
#define OPT_TYPE_NOT_FIXED  0x400  /* type-field might be wrong */ 
#define OPT_WEAK_TYPE           0x800  /* don't warn even if strict types */ 
#define OPT_APPLY           0x1000 /* contains apply */ 
#define OPT_FLAG_NODE           0x2000 /* don't optimize away unless the 
                                  * parent also is optimized away */ 
#define OPT_SAFE            0x4000 /* Known to not throw error (which normally 
                                  * isn