History

refactor post_type() to be explicit about its recursion

Joe Soroka committed 15 years ago

Commit 89059f91 parent 772b3021 file · +20 −5Browse files

Unified · Split

tccgen.c+20−5
@@ -3048,7 +3048,9 @@ static void asm_label_instr(CString *astr) · 3047 unmodified lines
3048#endif3048#endif
3049}3049}
3050 3050
3051static void post_type(CType *type, AttributeDef *ad)3051static void post_type_array(CType *type, AttributeDef *ad);
3052
3053static void post_type_args(CType *type, AttributeDef *ad)
3052{3054{
3053 int n, l, t1, arg_size, align;3055 int n, l, t1, arg_size, align;
3054 Sym **plast, *s, *first;3056 Sym **plast, *s, *first;
@@ -3114,14 +3116,23 @@ static void post_type(CType *type, AttributeDef *ad) · 59 unmodified lines
3114 /* some ancient pre-K&R C allows a function to return an array3116 /* some ancient pre-K&R C allows a function to return an array
3115 and the array brackets to be put after the arguments, such 3117 and the array brackets to be put after the arguments, such
3116 that "int c()[]" means the same as "int[] c()" */3118 that "int c()[]" means the same as "int[] c()" */
3117 post_type(type, ad);3119 if (tok == '[')
3120 post_type_array(type, ad);
3118 /* we push a anonymous symbol which will contain the function prototype */3121 /* we push a anonymous symbol which will contain the function prototype */
3119 ad->func_args = arg_size;3122 ad->func_args = arg_size;
3120 s = sym_push(SYM_FIELD, type, INT_ATTR(ad), l);3123 s = sym_push(SYM_FIELD, type, INT_ATTR(ad), l);
3121 s->next = first;3124 s->next = first;
3122 type->t = t1 | VT_FUNC;3125 type->t = t1 | VT_FUNC;
3123 type->ref = s;3126 type->ref = s;
3124 } else if (tok == '[') {3127 }
3128}
3129
3130static void post_type_array(CType *type, AttributeDef *ad)
3131{
3132 int n, t1;
3133 Sym *s;
3134
3135 if (tok == '[') {
3125 /* array definition */3136 /* array definition */
3126 next();3137 next();
3127 if (tok == TOK_RESTRICT1)3138 if (tok == TOK_RESTRICT1)
@@ -3136,7 +3147,8 @@ static void post_type(CType *type, AttributeDef *ad) · 8 unmodified lines
3136 /* parse next post type */3147 /* parse next post type */
3137 t1 = type->t & VT_STORAGE;3148 t1 = type->t & VT_STORAGE;
3138 type->t &= ~VT_STORAGE;3149 type->t &= ~VT_STORAGE;
3139 post_type(type, ad);3150 if (tok == '[')
3151 post_type_array(type, ad);
3140 3152
3141 /* we push a anonymous symbol which will contain the array3153 /* we push a anonymous symbol which will contain the array
3142 element type */3154 element type */
@@ -3210,7 +3222,10 @@ static void type_decl(CType *type, AttributeDef *ad, int *v, int td) · 67 unmodified lines
3210 *v = 0;3222 *v = 0;
3211 }3223 }
3212 }3224 }
3213 post_type(type, ad);3225 if (tok == '(')
3226 post_type_args(type, ad);
3227 else if (tok == '[')
3228 post_type_array(type, ad);
3214 if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)3229 if (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2)
3215 parse_attribute(ad);3230 parse_attribute(ad);
3216 3231

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t