コード例 #1
0
 // Forces accepting an IR program.
 public DefaultProtoCompiler(IRProgram program)
 {
     _program          = program;
     DumpMode          = false;
     PackageStructured = true;
     _fileOptions      = new Dictionary <string, OptionValueString>();
 }
コード例 #2
0
        public DependancyAnalyzer(IRProgram program) : base(program)
        {
            _DryRun = false;
            Runs    = 0;

            _TypeNSMapper     = new Dictionary <IRTypeNode, IRNamespace>();
            _NSDependancies   = new Dictionary <IRNamespace, HashSet <IRNamespace> >();
            _TypeDependancies = new Dictionary <IRTypeNode, HashSet <IRTypeNode> >();
        }
コード例 #3
0
        public static List <IRNamespace> FindNSParents(IRProgram program, IRNamespace subject)
        {
            // Return all namespaces whos fullname are found at the beginnen of the subject
            // namespace.
            var subjName = subject.FullName;
            var parents  = program.Namespaces.Where(p => subjName.StartsWith(p.FullName)).ToList();

            // Remove subject, because fullname matches always with itself.
            parents.Remove(subject);
            return(parents);
        }
コード例 #4
0
 public Proto2Compiler(IRProgram program) : base(program)
 {
 }
コード例 #5
0
        // Converts data from internal caches into the IR Program structure.
        public override IRProgram GetRoot()
        {
            // Create a list of all types to process.
            List <TypeDefinition> classesToProcess = new List <TypeDefinition>(_classCache.Keys);
            List <TypeDefinition> enumsToProcess   = new List <TypeDefinition>(_enumCache.Keys);

            // Holds a set of all known namespaces.
            Dictionary <string, IRNamespace> nsSet = new Dictionary <string, IRNamespace>();

            // Until all types are processed, we repeat the same operation.
            while (classesToProcess.Count() > 0)
            {
                // Take the first item from the list.
                var currentType = classesToProcess.ElementAt(0);
                classesToProcess.RemoveAt(0);
                // Find namespace list.
                var         nsName = GetNamespaceName(currentType);
                IRNamespace ns;
                nsSet.TryGetValue(nsName, out ns);
                if (ns == null)
                {
                    // Construct a shortname of the last namespace part of the full name.
                    var lastDotIdx  = nsName.LastIndexOf('.');
                    var nsShortname = (lastDotIdx != -1) ? nsName.Substring(lastDotIdx + 1) : nsName;
                    ns = new IRNamespace(nsName, nsShortname)
                    {
                        Classes = new List <IRClass>(),
                        Enums   = new List <IREnum>(),
                    };
                    nsSet[nsName] = ns;
                }

                // Get the matching IR object.
                var irClass = _classCache[currentType];
                if (irClass.IsPrivate != true && irClass.Parent == null)
                {
                    irClass.Parent = ns;
                }
                // Save it into the namespace.
                ns.Classes.Add(irClass);
            }

            // Do basically the same for enums.
            while (enumsToProcess.Count() > 0)
            {
                // Take the first item from the list.
                var currentType = enumsToProcess.ElementAt(0);
                enumsToProcess.RemoveAt(0);
                // Find namespace list.
                var         nsName = GetNamespaceName(currentType);
                IRNamespace ns;
                nsSet.TryGetValue(nsName, out ns);
                if (ns == null)
                {
                    // Construct a shortname of the last namespace part of the full name.
                    var lastDotIdx  = nsName.LastIndexOf('.');
                    var nsShortname = (lastDotIdx != -1) ? nsName.Substring(lastDotIdx + 1) : nsName;
                    ns = new IRNamespace(nsName, nsShortname)
                    {
                        Classes = new List <IRClass>(),
                        Enums   = new List <IREnum>(),
                    };
                    nsSet[nsName] = ns;
                }

                // Get the matching IR object.
                var irEnum = _enumCache[currentType];
                if (irEnum.IsPrivate != true && irEnum.Parent == null)
                {
                    irEnum.Parent = ns;
                }
                // Save it into the namespace.
                ns.Enums.Add(irEnum);
            }

            // Generate IR root of all namespaces.
            _root = new IRProgram()
            {
                Namespaces = nsSet.Values.ToList(),
            };
            // Return the program root.
            return(_root);
        }
コード例 #6
0
 public AutoPackager(IRProgram program) : base(program)
 {
     _packagedNSNames = new Dictionary <IRNamespace, string>();
 }
コード例 #7
0
 public ManualPackager(IRProgram program, string typesFile) : base(program)
 {
     _typesFile = typesFile;
 }
コード例 #8
0
 public NameCollisionAnalyzer(IRProgram program) : base(program)
 {
     _md5Hash = MD5.Create();
 }