- helper function for computing the file position of an expression
... | ... |
@@ -201,8 +201,6 @@ static struct rvalue* rval_tmp; |
201 | 201 |
|
202 | 202 |
static void warn(char* s); |
203 | 203 |
static void get_cpos(struct cfg_pos* pos); |
204 |
-static void get_rve2_pos(struct cfg_pos* res, |
|
205 |
- struct cfg_pos* pos1, struct cfg_pos* pos2); |
|
206 | 204 |
static struct rval_expr* mk_rve_rval(enum rval_type, void* v); |
207 | 205 |
static struct rval_expr* mk_rve1(enum rval_expr_op op, struct rval_expr* rve1); |
208 | 206 |
static struct rval_expr* mk_rve2(enum rval_expr_op op, struct rval_expr* rve1, |
... | ... |
@@ -2613,25 +2611,6 @@ static void yyerror(char* format, ...) |
2613 | 2611 |
|
2614 | 2612 |
|
2615 | 2613 |
|
2616 |
-static void get_rve2_pos(struct cfg_pos* res, |
|
2617 |
- struct cfg_pos* pos1, struct cfg_pos* pos2) |
|
2618 |
-{ |
|
2619 |
- *res=*pos1; |
|
2620 |
- if ((res->s_line == 0) || (res->s_line > pos2->s_line)){ |
|
2621 |
- res->s_line=pos2->s_line; |
|
2622 |
- res->s_col=pos2->s_col; |
|
2623 |
- }else if ((res->s_line == pos2->s_line) && (res->s_col > pos2->s_col)){ |
|
2624 |
- res->s_col=pos2->s_col; |
|
2625 |
- } |
|
2626 |
- if ((res->e_line == 0) || (res->e_line < pos2->e_line)){ |
|
2627 |
- res->e_line=pos2->e_line; |
|
2628 |
- res->e_col=pos2->e_col; |
|
2629 |
- }else if ((res->e_line == pos2->e_line) && (res->e_col < pos2->e_col)){ |
|
2630 |
- res->e_col=pos2->e_col; |
|
2631 |
- } |
|
2632 |
-} |
|
2633 |
- |
|
2634 |
- |
|
2635 | 2614 |
/** mk_rval_expr_v wrapper. |
2636 | 2615 |
* checks mk_rval_expr_v return value and sets the cfg. pos |
2637 | 2616 |
* (line and column numbers) |
... | ... |
@@ -2688,7 +2667,7 @@ static struct rval_expr* mk_rve2(enum rval_expr_op op, struct rval_expr* rve1, |
2688 | 2667 |
|
2689 | 2668 |
if ((rve1==0) || (rve2==0)) |
2690 | 2669 |
return 0; |
2691 |
- get_rve2_pos(&pos, &rve1->fpos, &rve2->fpos); |
|
2670 |
+ cfg_pos_join(&pos, &rve1->fpos, &rve2->fpos); |
|
2692 | 2671 |
ret=mk_rval_expr2(op, rve1, rve2, &pos); |
2693 | 2672 |
if (ret && (rve_check_type(&type, ret, &bad_rve, &bad_t, &exp_t)!=1)){ |
2694 | 2673 |
yyerror_at(&pos, "bad expression: type mismatch:" |
... | ... |
@@ -52,6 +52,30 @@ |
52 | 52 |
#include "ut.h" /* ZSW() */ |
53 | 53 |
|
54 | 54 |
|
55 |
+ |
|
56 |
+/** joins to cfg file positions into a new one. */ |
|
57 |
+void cfg_pos_join(struct cfg_pos* res, |
|
58 |
+ struct cfg_pos* pos1, struct cfg_pos* pos2) |
|
59 |
+{ |
|
60 |
+ struct cfg_pos ret; |
|
61 |
+ ret=*pos1; |
|
62 |
+ if ((ret.s_line == 0) || (ret.s_line > pos2->s_line)){ |
|
63 |
+ ret.s_line=pos2->s_line; |
|
64 |
+ ret.s_col=pos2->s_col; |
|
65 |
+ }else if ((ret.s_line == pos2->s_line) && (ret.s_col > pos2->s_col)){ |
|
66 |
+ ret.s_col=pos2->s_col; |
|
67 |
+ } |
|
68 |
+ if ((ret.e_line == 0) || (ret.e_line < pos2->e_line)){ |
|
69 |
+ ret.e_line=pos2->e_line; |
|
70 |
+ ret.e_col=pos2->e_col; |
|
71 |
+ }else if ((ret.e_line == pos2->e_line) && (ret.e_col < pos2->e_col)){ |
|
72 |
+ ret.e_col=pos2->e_col; |
|
73 |
+ } |
|
74 |
+ *res=ret; |
|
75 |
+} |
|
76 |
+ |
|
77 |
+ |
|
78 |
+ |
|
55 | 79 |
struct expr* mk_exp(int op, struct expr* left, struct expr* right) |
56 | 80 |
{ |
57 | 81 |
struct expr * e; |
... | ... |
@@ -167,5 +167,8 @@ void print_action(struct action* a); |
167 | 167 |
void print_actions(struct action* a); |
168 | 168 |
void print_expr(struct expr* exp); |
169 | 169 |
|
170 |
+/** joins to cfg file positions into a new one. */ |
|
171 |
+void cfg_pos_join(struct cfg_pos* res, |
|
172 |
+ struct cfg_pos* pos1, struct cfg_pos* pos2); |
|
170 | 173 |
#endif |
171 | 174 |
|