예제 #1
0
        public void UsingRequires()
        {
            TypeGraphSpace graph = new TypeGraphSpace();

            graph.AddAssemblyReference("mscorlib");
            graph.AddAssemblyReference("System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");

            TypeGraphSpace sub = new TypeGraphSpace(graph);

            sub.AddRequire("System");
            sub.AddRequire("System::Diagnostics");

            TypeDefinition type = sub.GetType("Console");

            Assert.IsNotNull(type);
            Assert.AreEqual("Console", type.Name);

            type = sub.GetType("System::Console");
            Assert.IsNotNull(type);
            Assert.AreEqual("Console", type.Name);

            type = sub.GetType("Debug");
            Assert.IsNotNull(type);
            Assert.AreEqual("Debug", type.Name);

            type = sub.GetType("System::Diagnostics::Debug");
            Assert.IsNotNull(type);
            Assert.AreEqual("Debug", type.Name);
        }
        public void NamespaceAndClasses()
        {
            String contents =
                "namespace Family::Guy      \r\n" +
                "							\r\n"+
                "  class Boat				\r\n"+
                "							\r\n"+
                "  end						\r\n"+
                "							\r\n"+
                "  class Ship				\r\n"+
                "							\r\n"+
                "  end						\r\n"+
                "							\r\n"+
                "end						\r\n"+
                "							\r\n"+
                "";

            SourceUnit unit = container.ParserService.Parse(contents);

            AssertNoErrorOrWarnings();

            Assert.IsNotNull(unit);

            DeclarationBinding sb = container[typeof(DeclarationBinding)] as DeclarationBinding;

            sb.ExecutePass(unit.CompilationUnit);

            AssertNoErrorOrWarnings();

            TypeGraphSpace graph = unit.SymbolTable.Parent.TypeGraphView;

            TypeDefinition boatType = graph.GetType("Family::Guy::Boat");

            Assert.IsNotNull(boatType);
            Assert.IsNotNull(boatType as TransientType);
            Assert.IsNotNull((boatType as TransientType).TypeDef);
            Assert.AreEqual("Boat", (boatType as TransientType).TypeDef.Name);

            TypeDefinition shipType = graph.GetType("Family::Guy::Ship");

            Assert.IsNotNull(shipType);
            Assert.IsNotNull(shipType as TransientType);
            Assert.IsNotNull((shipType as TransientType).TypeDef);
            Assert.AreEqual("Ship", (shipType as TransientType).TypeDef.Name);
        }
예제 #3
0
        public void AddingAssembly()
        {
            TypeGraphSpace graph = new TypeGraphSpace();

            graph.AddAssemblyReference("mscorlib");
            graph.AddAssemblyReference("System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");

            NamespaceGraph ng = graph.GetNamespace("System");

            Assert.IsNotNull(ng);
            Assert.AreEqual("System", ng.Name);

            ng = graph.GetNamespace("System::Collections::Specialized");
            Assert.IsNotNull(ng);
            Assert.AreEqual("Specialized", ng.Name);

            ng = graph.GetNamespace("System::Diagnostics");
            Assert.IsNotNull(ng);
            Assert.AreEqual("Diagnostics", ng.Name);
        }
예제 #4
0
        public void CheckAmbiguities()
        {
            TypeGraphSpace graph = new TypeGraphSpace();

            graph.AddAssemblyReference("mscorlib");
            graph.AddAssemblyReference("System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
            graph.AddAssemblyReference("Castle.Rook.Compiler.Tests");

            TypeGraphSpace sub = new TypeGraphSpace(graph);

            sub.AddRequire("System");
            sub.AddRequire("Castle::Rook::Compiler::Tests");

            Assert.IsFalse(sub.HasAmbiguity("System::Console"));

            TypeDefinition type = sub.GetType("System::Console");

            Assert.IsNotNull(type);
            Assert.AreEqual("Console", type.Name);

            Assert.IsTrue(sub.HasAmbiguity("Console"));
        }
예제 #5
0
        public RootSymbolTable() : base(ScopeType.Global)
        {
            graphSpace = new TypeGraphSpace();

            graphSpace.AddAssemblyReference("mscorlib");
        }
 public SymbolTable(ScopeType nstype, TypeGraphSpace parentGraphSpace) : this(nstype)
 {
     this.graphSpace = new TypeGraphSpace(parentGraphSpace);
 }