vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | #include "asn1fix_internal.h" |
| 2 | |
| 3 | /* |
| 4 | * Dereference DefinedValues: |
| 5 | */ |
| 6 | int |
| 7 | asn1f_fix_dereference_values(arg_t *arg) { |
| 8 | asn1p_expr_t *expr = arg->expr; |
| 9 | int r_value = 0; |
| 10 | |
| 11 | if(expr->meta_type != AMT_VALUE) |
| 12 | return 0; /* Just ignore it */ |
| 13 | |
| 14 | if(expr->value == NULL) |
| 15 | return 0; /* Just ignore it */ |
| 16 | |
| 17 | if(expr->value && expr->value->type != ATV_REFERENCED) |
| 18 | return 0; /* Not a reference */ |
| 19 | |
| 20 | DEBUG("%s(%s %x ::= %s) for line %d", __func__, |
| 21 | expr->Identifier, expr->expr_type, |
| 22 | asn1f_printable_value(expr->value), expr->_lineno); |
| 23 | |
| 24 | /* |
| 25 | * If this integer has a value, check that this value |
| 26 | * is an integer. If it is a reference, resolve it. |
| 27 | */ |
| 28 | if(expr->value) { |
| 29 | |
| 30 | if(asn1f_value_resolve(arg, expr)) { |
| 31 | /* This function will emit messages */ |
| 32 | r_value = -1; |
| 33 | } |
| 34 | |
| 35 | if(expr->value->type != ATV_INTEGER) { |
| 36 | FATAL( |
| 37 | "INTEGER value %s at line %d: " |
| 38 | "Incompatible value specified: %s", |
| 39 | expr->Identifier, |
| 40 | expr->_lineno, |
| 41 | asn1f_printable_value(expr->value) |
| 42 | ); |
| 43 | r_value = -1; |
| 44 | } |
| 45 | } else { |
| 46 | FATAL("Value of \"%s\" at line %d: " |
| 47 | "Incompatible value specified", |
| 48 | expr->Identifier, |
| 49 | expr->_lineno |
| 50 | ); |
| 51 | r_value = -1; |
| 52 | } |
| 53 | |
| 54 | return r_value; |
| 55 | } |
| 56 | |