vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | #include "asn1fix_internal.h" |
| 2 | |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 3 | asn1p_expr_t * |
vlm | 2e0c194 | 2004-08-22 03:10:23 +0000 | [diff] [blame] | 4 | asn1f_class_access(arg_t *arg, asn1p_module_t *mod, asn1p_ref_t *ref) { |
vlm | dc7cf04 | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 5 | asn1p_expr_t *ioclass; |
| 6 | asn1p_expr_t *classfield; |
| 7 | asn1p_expr_t *expr; |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 8 | asn1p_ref_t tmpref; |
| 9 | |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 10 | assert(ref->comp_count > 1); |
| 11 | |
vlm | dc7cf04 | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 12 | DEBUG("ClassAccess lookup (%s) for line %d", asn1f_printable_reference(ref), ref->_lineno); |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 13 | |
| 14 | /* |
| 15 | * Fetch the first part of the reference (OBJECT or ObjectSet). |
| 16 | * OBJECT.&<something>... |
| 17 | * ObjectSet.&<something>... |
| 18 | */ |
| 19 | assert(isupper(ref->components[0].name[0])); |
| 20 | |
| 21 | tmpref = *ref; |
| 22 | tmpref.comp_count = 1; |
vlm | dc7cf04 | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 23 | ioclass = asn1f_lookup_symbol(arg, mod, &tmpref); |
| 24 | if(ioclass == NULL) { |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 25 | errno = ESRCH; |
| 26 | return NULL; |
| 27 | } |
| 28 | |
vlm | dc7cf04 | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 29 | classfield = asn1f_lookup_child(ioclass, ref->components[1].name); |
| 30 | if(classfield == NULL) { |
| 31 | DEBUG("CLASS %s does not contain field %s", |
| 32 | ioclass->Identifier, ref->components[1].name); |
| 33 | errno = ESRCH; |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 34 | return NULL; |
| 35 | } |
| 36 | |
vlm | dc7cf04 | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 37 | assert(classfield->meta_type == AMT_OBJECTFIELD); |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 38 | |
vlm | dc7cf04 | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 39 | DEBUG("CLASS %s -> %s (%d)", ioclass->Identifier, |
| 40 | classfield->Identifier, classfield->expr_type); |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 41 | |
vlm | dc7cf04 | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 42 | switch(classfield->expr_type) { |
| 43 | case A1TC_CLASSFIELD_TFS: |
| 44 | if(TQ_FIRST(&classfield->members)) { |
| 45 | /* Already have something */ |
| 46 | } else { |
| 47 | expr = asn1p_expr_new(classfield->_lineno); |
| 48 | expr->expr_type = ASN_TYPE_ANY; |
| 49 | expr->meta_type = AMT_TYPE; |
| 50 | asn1p_expr_add(classfield, expr); |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 51 | } |
vlm | dc7cf04 | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 52 | /* Fall through */ |
| 53 | case A1TC_CLASSFIELD_FTVFS: |
| 54 | expr = TQ_FIRST(&classfield->members); |
| 55 | assert(expr); |
| 56 | return expr; |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 57 | break; |
| 58 | default: |
vlm | dc7cf04 | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 59 | FATAL("%s.%s: field type not yet supported. " |
| 60 | "Consider donation to the asn1c author.", |
| 61 | ioclass->Identifier, classfield->Identifier); |
| 62 | return NULL; |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 63 | } |
| 64 | |
vlm | dc7cf04 | 2006-03-09 08:49:26 +0000 | [diff] [blame] | 65 | return NULL; |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 66 | } |
vlm | 51aed88 | 2006-03-14 15:53:59 +0000 | [diff] [blame^] | 67 | |
| 68 | |
| 69 | int |
| 70 | asn1f_parse_class_with_syntax(arg_t *arg) { |
| 71 | asn1p_expr_t *expr = arg->expr; |
| 72 | |
| 73 | if(expr->expr_type != A1TC_CLASSDEF |
| 74 | || expr->with_syntax == NULL) |
| 75 | return 0; |
| 76 | |
| 77 | DEBUG("Class %s: checking WITH SYNTAX", expr->Identifier); |
| 78 | |
| 79 | return 0; |
| 80 | } |