#include "ex-compiler.h" #include static void weed_uses_clause (ExUsesClause *clause); static void weed_definition (ExDefinition *definition, exboolean allow_extensions); static void weed_namespace (ExNamespace *namespace, exboolean allow_extensions); static void weed_extension (ExExtension *extension, exboolean allow_extensions); static void weed_request (ExRequest *request); static void weed_event (ExEvent *event); static void weed_type_def (ExTypeDef *type_def); static void weed_identifier (ExIdentifier *identifier); static void weed_type (ExType *type); static void weed_field (ExField *field, exboolean allow_create); static void weed_error (ExError *error); void ex_weed (ExSpec *spec) { if (!spec) return; weed_uses_clause (spec->uses_clauses); weed_definition (spec->definitions, EX_TRUE); } static void weed_uses_clause (ExUsesClause *clause) { if (!clause) return; weed_uses_clause (clause->next); } static void weed_definition (ExDefinition *definition, exboolean allow_extensions) { if (!definition) return; switch (definition->type) { case EX_DEFINITION_NAMESPACE: weed_namespace (definition->u.namespace, allow_extensions); break; case EX_DEFINITION_EXTENSION: if (!allow_extensions) { ex_fatal_error (-1, -1, "Nested extensions are not allowed"); return; } weed_extension (definition->u.extension, EX_FALSE); break; case EX_DEFINITION_REQUEST: weed_request (definition->u.request); break; case EX_DEFINITION_TYPE_DEF: weed_type_def (definition->u.type_def); break; case EX_DEFINITION_ERROR: weed_error (definition->u.error); break; case EX_DEFINITION_EVENT: weed_event (definition->u.event); break; } weed_definition (definition->next, allow_extensions); } static void weed_namespace (ExNamespace *namespace, exboolean allow_extensions) { if (!namespace) return; weed_definition (namespace->definitions, allow_extensions); } static void weed_extension (ExExtension *extension, exboolean allow_extensions) { if (!extension) return; weed_definition (extension->definitions, allow_extensions); } static void weed_request (ExRequest *request) { if (!request) return; weed_field (request->parameters, EX_TRUE); weed_field (request->reply, EX_FALSE); weed_identifier (request->errors); } static void weed_type_def (ExTypeDef *type_def) { if (!type_def) return; weed_type (type_def->type); } static void weed_error (ExError *error) { if (!error) return; } static void weed_event (ExEvent *event) { if (!event) return; weed_field (event->fields, EX_FALSE); } static void weed_identifier (ExIdentifier *identifier) { if (!identifier) return; weed_identifier (identifier->next); } static void weed_type (ExType *type) { if (!type) return; switch (type->type) { case EX_TYPE_CARD8: break; case EX_TYPE_CARD16: break; case EX_TYPE_CARD32: break; case EX_TYPE_CARD64: break; case EX_TYPE_INT8: break; case EX_TYPE_INT16: break; case EX_TYPE_INT32: break; case EX_TYPE_INT64: break; case EX_TYPE_BOOLEAN: break; case EX_TYPE_ENUM: weed_identifier (type->u._enum.identifiers); break; case EX_TYPE_STRUCT: weed_field (type->u._struct.fields, EX_FALSE); break; case EX_TYPE_BITS: weed_identifier (type->u.bits.fields); break; case EX_TYPE_DERIVED_BITS: break; case EX_TYPE_MASKED_LIST: weed_field (type->u.masked_list.fields, EX_FALSE); break; case EX_TYPE_IDENTIFIER: break; case EX_TYPE_UNION: weed_field (type->u._struct.fields, EX_FALSE); break; case EX_TYPE_LIST: weed_type (type->u._list.type); break; case EX_TYPE_XID: break; } } static void weed_field (ExField *field, exboolean allow_create) { if (!field) return; if (!allow_create && field->is_created) { ex_fatal_error (-1, -1, "Created parameter is not allowed here"); } weed_type (field->type); weed_field (field->next, allow_create); }