예제 #1
0
        public Name GetDeclName(DeclReference declRef)
        {
            Name name;

            if (!this.declTree.FindByValue(declRef, out name))
            {
                throw new ArgumentException("not found");
            }

            return(name);
        }
예제 #2
0
        public int CreateFunct(Name name)
        {
            var decl = new DeclFunct();
            this.declFuncts.Add(decl);

            var declRef = new DeclReference
            {
                kind = DeclReference.Kind.Funct,
                index = this.declFuncts.Count - 1
            };

            this.declTree.Add(name, declRef);
            return this.declFuncts.Count - 1;
        }
예제 #3
0
        public bool ValidateAsFunct(DeclReference decl, Name origName, Diagnostics.Span span)
        {
            if (decl.kind != Core.Session.DeclReference.Kind.Funct)
            {
                this.AddMessage(
                    Diagnostics.MessageKind.Error,
                    Diagnostics.MessageCode.WrongDeclarationKind,
                    "'" + this.GetDeclName(decl).GetString() + "' is not a funct",
                    span);
                return(false);
            }

            return(true);
        }
예제 #4
0
        public int CreateStruct(Name name, Grammar.ASTNodeDeclStruct declASTNode)
        {
            var decl = new DeclStruct();
            decl.declASTNode = declASTNode;
            this.declStructs.Add(decl);

            var declRef = new DeclReference
            {
                kind = DeclReference.Kind.Struct,
                index = this.declStructs.Count - 1
            };

            this.declTree.Add(name, declRef);
            return this.declStructs.Count - 1;
        }
예제 #5
0
        public int CreateFunct(Name name)
        {
            var decl = new DeclFunct();

            this.declFuncts.Add(decl);

            var declRef = new DeclReference
            {
                kind  = DeclReference.Kind.Funct,
                index = this.declFuncts.Count - 1
            };

            this.declTree.Add(name, declRef);
            return(this.declFuncts.Count - 1);
        }
예제 #6
0
        public int CreatePrimitiveStruct(Name name)
        {
            var decl = new DeclStruct();
            decl.primitive = true;
            decl.declASTNode = null;
            this.declStructs.Add(decl);

            var declRef = new DeclReference
            {
                kind = DeclReference.Kind.Struct,
                index = this.declStructs.Count - 1
            };

            this.declTree.Add(name, declRef);
            return this.declStructs.Count - 1;
        }
예제 #7
0
        public int CreateStruct(Name name, Grammar.ASTNodeDeclStruct declASTNode)
        {
            var decl = new DeclStruct();

            decl.declASTNode = declASTNode;
            this.declStructs.Add(decl);

            var declRef = new DeclReference
            {
                kind  = DeclReference.Kind.Struct,
                index = this.declStructs.Count - 1
            };

            this.declTree.Add(name, declRef);
            return(this.declStructs.Count - 1);
        }
예제 #8
0
        public int CreatePrimitiveStruct(Name name)
        {
            var decl = new DeclStruct();

            decl.primitive   = true;
            decl.declASTNode = null;
            this.declStructs.Add(decl);

            var declRef = new DeclReference
            {
                kind  = DeclReference.Kind.Struct,
                index = this.declStructs.Count - 1
            };

            this.declTree.Add(name, declRef);
            return(this.declStructs.Count - 1);
        }
예제 #9
0
        public Name GetFunctName(int functIndex)
        {
            var declRef = new DeclReference
            {
                kind  = DeclReference.Kind.Funct,
                index = functIndex
            };

            Name name;

            if (!this.declTree.FindByValue(declRef, out name))
            {
                throw new ArgumentException("struct not found");
            }

            return(name);
        }
예제 #10
0
        public Name GetDeclName(DeclReference declRef)
        {
            Name name;
            if (!this.declTree.FindByValue(declRef, out name))
                throw new ArgumentException("not found");

            return name;
        }
예제 #11
0
        public bool ValidateAsType(DeclReference decl, Name origName, Diagnostics.Span span)
        {
            if (decl.kind != Core.Session.DeclReference.Kind.Struct)
            {
                this.AddMessage(
                    Diagnostics.MessageKind.Error,
                    Diagnostics.MessageCode.WrongDeclarationKind,
                    "'" + this.GetDeclName(decl).GetString() + "' is not a type",
                    span);
                return false;
            }

            return true;
        }
예제 #12
0
        public Name GetStructName(int structIndex)
        {
            var declRef = new DeclReference
            {
                kind = DeclReference.Kind.Struct,
                index = structIndex
            };

            Name name;
            if (!this.declTree.FindByValue(declRef, out name))
                throw new ArgumentException("struct not found");

            return name;
        }