public TypeEntry(TypeDef type, FileNamespaceEntry ns)
        {
            Type = type;
            Namespace = ns;

            Namespace.Types.Add(this);

            Nested = new List<TypeEntry>();
        }
        public MemberDef(TypeDef parent, MemberName memberName, Modifier modifiers)
        {
            Modifiers = modifiers;
            MemberName = memberName;
            Parent = parent;

            Locals = new Dictionary<string, LocalBuilder>();

            attributes = new List<AttributeInstance>();
        }
        public TypeEntry(TypeDef type, TypeEntry parent)
        {
            Type = type;
            Namespace = parent.Namespace;

            Namespace.Types.Add(this);

            Nested = new List<TypeEntry>();
            Parent.Nested.Add(this);
        }
 public MemberDef(TypeDef parent, string memberName, Modifier modifiers)
     : this(parent, new MemberName(memberName), modifiers)
 {
     //this.Modifiers = modifiers;
 }
 public FieldDef(TypeDef parent, string name, FullNamedExpression type, Modifier modifiers)
     : base(parent, new MemberName(parent.MemberName, Separators.DoubleColon, name), modifiers)
 {
     FieldType = type;
 }
 public void AddType(TypeDef type)
 {
     types.Add(type);
 }
        private void ParseModule()
        {
            TokenInfo token, token2;

            token = default(TokenInfo);
            token2 = default(TokenInfo);

            bool flag = false;
            Modifier modifiers;

            token = tokenQueue.Dequeue();

            modifiers = ParseModuleModifiers();

            flag = Expect(Token.Identifier, ref token2);

            type = new ModuleDef(ns, token2, modifiers);

            OpenModule();

            TokenList symbols = statementSymbols;

            ExpectEndOfStatementOrEat();

            flag = ParseModuleMembers();

            if (!flag)
            {
                Report.AddItem(VBErrors.ModuleStatementMustEndWithAMatchingEndModule, SourceFile, token.GetSpan(token2),
                               symbols);
            }

            CloseType();
        }
        private void ParseField()
        {
            #region Old

            //bool b = Expect(Token.LeftSquareBracket);

            //TokenInfo token = Tokenizer.PeekToken();

            //if (token.Is(Token.Identifier) || token.Is(Token.ReservedWord))
            //{

            //}

            //if (Expect(Token.As))
            //{
            //    token = Tokenizer.PeekToken();

            //    if (Expect(Token.Identifier))
            //    {

            //    }
            //    else
            //    {

            //    }
            //}
            //else
            //{

            //}

            //if (Expect(Token.Equality))
            //{
            //    token = Tokenizer.PeekToken();

            //    if (Expect(Token.Identifier))
            //    {

            //    }
            //    else
            //    {

            //    }
            //}
            //else
            //{

            //}

            #endregion

            TokenInfo token;

            Modifier modifiers;
            SimpleName name;
            FullNamedExpression type;
            Expression expr;

            modifiers = ParseMethodModifiers();

            token = tokenQueue.Dequeue();

            name = null;
            type = null;
            expr = null;


            if (token.Is(Token.Identifier))
            {
                name = new SimpleName(statement, token.Value,
                                      new SourceData(token.GetSpan(token), SourceFile, statementSymbols));

                if (EatOptional(Token.As))
                {
                    type = ParseFullName();
                }

                TokenInfo token3 = Tokenizer.PeekToken();

                if (EatOptional(Token.Equality))
                {
                    EatOptional(Token.EOL);

                    //Set parse context to initializer
                    MethodDef initializer;

                    if ((modifiers & Modifier.Shared) == Modifier.Shared)
                    {
                        initializer = (MethodDef) this.type.GetTypeInitializer();
                    }
                    else
                    {
                        initializer = (MethodDef) this.type.GetDefaultConstructor();
                    }

                    //Initalize context
                    method = initializer;
                    block = method.Body;
                    var assignStmt = new ExpressionStatement(initializer.Body);
                    statement = assignStmt;

                    //Parse initialization expression
                    expr = ParseExpression();

                    //Build initialization expression statement
                    assignStmt.SetExpression(
                        new BinaryExpression(assignStmt, Operator.Assign,
                                             new VariableAccess(assignStmt,
                                                                new SimpleName(assignStmt, name, null), null),
                                             expr, null));

                    //Add statement
                    initializer.Body.AddStatement(assignStmt);

                    //Reset context to null
                    method = null;
                    block = null;
                    statement = null;

                    if (expr == null)
                    {
                        Report.AddItem(VBErrors.ExpressionExpected, SourceFile,
                                       token3.GetSpan(token3), statementSymbols);
                    }
                }

                TokenInfo token4 = Tokenizer.PeekToken();

                if (token4.Is(Token.EOL))
                {
                    //GetNextToken(); //*
                    resetStmtTokens();
                }
                else
                {
                    ExpectEndOfStatementOrEat();
                }
            }
            else
            {
                GetNextToken();
                TokenInfo token2 = Tokenizer.PeekToken();
                Report.AddItem(VBErrors.IdentifierExpected, SourceFile,
                               new SourceSpan(token.GetSourceLocation(), token2.GetSourceLocation()), statementSymbols);
                EatToEOL();
            }

            var fieldDef = new FieldDef(this.type, name, type, modifiers);
            fieldDef.SetInitalizationExpression(expr);

            ((ClassStructOrModuleDef) this.type).AddField(fieldDef);
        }
        private Parameter ParseMethodParameter(ParameterList plist)
        {
            TokenInfo token;
            Modifier[] modifiers;
            FullNamedExpression type;

            token = tokenQueue.Dequeue();

            modifiers = popModifiers();

            Expect(Token.As);

            type = ParseFullName();

            return new Parameter(plist, token.Value, type, default(Modifier));
        }
        private Statement ParseDeclareStmt()
        {
            TokenInfo token;

            SimpleName name;
            FullNamedExpression type;
            Expression expr;

            tokenQueue.Dequeue();

            token = Tokenizer.PeekToken();

            name = null;
            type = null;
            expr = null;

            var stmt = new DeclareStatement(block);
            statement = stmt;

            if (EatOptional(Token.Identifier))
            {
                name = new SimpleName(statement, token.Value,
                                      new SourceData(token.GetSpan(token), SourceFile, statementSymbols));

                if (EatOptional(Token.As))
                {
                    type = ParseFullName();
                }

                TokenInfo token3 = Tokenizer.PeekToken();

                if (EatOptional(Token.Equality))
                {
                    EatOptional(Token.EOL);

                    expr = ParseExpression();

                    if (expr == null)
                    {
                        Report.AddItem(VBErrors.ExpressionExpected, SourceFile,
                                       token3.GetSpan(token3), statementSymbols);
                    }
                }

                TokenInfo token4 = Tokenizer.PeekToken();

                if (token4.Is(Token.EOL))
                {
                    //GetNextToken(); //*
                    resetStmtTokens();
                }
                else
                {
                    ExpectEndOfStatementOrEat();
                }
            }
            else
            {
                GetNextToken();
                TokenInfo token2 = Tokenizer.PeekToken();
                Report.AddItem(VBErrors.IdentifierExpected, SourceFile,
                               new SourceSpan(token.GetSourceLocation(), token2.GetSourceLocation()), statementSymbols);
                EatToEOL();
            }

            stmt.SetName(name);
            stmt.SetType(type);
            stmt.SetInitializationExpression(expr);

            return stmt;
        }
        private TypeDef CloseType()
        {
            this.type.SetFileNamespaceEntry(fileNamespaceEntry);

            if (typeEntry.Parent == null)
            {
                typeEntry = null;
            }
            else
            {
                typeEntry = typeEntry.Parent;
            }

            TypeDef type = this.type;
            this.type = this.type.Parent;

            return type;
        }
 public static void AddUserDefinedType(TypeDef typeDefinition)
 {
     types.Add(typeDefinition);
 }
Esempio n. 13
0
 public TypeDef(TypeDef parent, string name, MemberName baseClass, MemberName[] inplements, Modifier modifiers)
     : base(parent, new MemberName(parent.MemberName, Separators.Slash, name), modifiers)
 {
     Initialize(baseClass, inplements);
 }