text: // Generated by CoffeeScript 1.7.1
  var rule;
  
  rule = require('./rule');
  
  module.exports = {
    expanded: {},
    dataStructures: {},
    dataStructure: function(element) {
      var typeName;
      typeName = element.name;
      if (!typeName) {
        typeName = {
          literal: ''
        };
      }
      this.expandMixin(typeName.literal, element);
      return delete this.expanded[''];
    },
    diveIntoElements: function(elements, content) {
      var member, memberContent, sections, superType, _i, _len, _results;
      _results = [];
      for (_i = 0, _len = elements.length; _i < _len; _i++) {
        member = elements[_i];
        switch (member['class']) {
          case 'mixin':
            superType = member.content.typeSpecification.name;
            if (typeof superType === 'object' && (superType != null ? superType.literal : void 0) && this.dataStructures[superType.literal]) {
              this.expandMixin(superType.literal, this.dataStructures[superType.literal]);
              _results.push(rule.copyMembers(this.dataStructures[superType.literal], content));
            } else {
              _results.push(void 0);
            }
            break;
          case 'property':
          case 'value':
            sections = [];
            this.diveIntoElements(member.content.sections || [], sections);
            member.content.sections = sections;
            _results.push(content.push(member));
            break;
          case 'oneOf':
          case 'group':
          case 'memberType':
            memberContent = [];
            this.diveIntoElements(member.content || [], memberContent);
            member.content = memberContent;
            _results.push(content.push(member));
            break;
          default:
            _results.push(content.push(member));
        }
      }
      return _results;
    },
    expandMixin: function(name, dataStructure) {
      var section, sectionContent, _i, _len, _ref;
      if (this.expanded[name]) {
        return;
      }
      _ref = dataStructure.sections;
      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        section = _ref[_i];
        if (section['class'] === 'memberType' && (section.content != null)) {
          sectionContent = [];
          this.diveIntoElements(section.content, sectionContent);
          section.content = sectionContent;
        }
      }
      return this.expanded[name] = true;
    },
    init: function(dataStructures) {
      var dataStructure, name, _ref, _ref1, _results;
      this.expanded = {};
      this.dataStructures = dataStructures;
      _ref = this.dataStructures;
      for (name in _ref) {
        dataStructure = _ref[name];
        this.expanded[name] = false;
      }
      _ref1 = this.dataStructures;
      _results = [];
      for (name in _ref1) {
        dataStructure = _ref1[name];
        _results.push(this.expandMixin(name, dataStructure));
      }
      return _results;
    }
  };
  