public override object Exec(MethodType actualMethod, object arg)
 {
     // * 1.1 The implicit object has a known type and can a lso have candidate methods maybe a candidate objec
     if (this.firstTime)
     {
         this.firstTime = false;
         this.areThereNonValidObjects = TypeExpression.As <UnionType>(((FieldAccessExpression)this.node.Identifier).Expression.ExpressionType) != null;
         this.InvokeSingleMethod(actualMethod, arg);
         //this.EndInvocationMethod();
         return(null);
     }
     this.InvokeUnionMethod(actualMethod, arg);
     return(null);
 }
        private object InvokeUnionMethod(MethodType actualMethodCalled, object arg)
        {
            List <string> nextMethod = new List <string>();
            Dictionary <MethodInvocationArgument, object> dic = (Dictionary <MethodInvocationArgument, object>)arg;

            if (this.nonValidObjectsList.Remove(actualMethodCalled.MemberInfo.Class))
            {
                this.codeGenerator.Comment("Removing..." + actualMethodCalled + " from non suitable objects");
            }
            string nextMethodLabel = this.codeGenerator.NewLabel;

            if ((actualMethodCalled.MemberInfo.ModifierMask & Modifier.Static) == 0)
            {
                // check the invocation reference
                dic[MethodInvocationArgument.Clean] = true;
                this.codeGenerator.dup(this.indent);
                this.codeGenerator.isinst(this.indent, actualMethodCalled.MemberInfo.Class);
                this.codeGenerator.brfalse(this.indent, nextMethodLabel);
                if (actualMethodCalled.MemberInfo.Class.IsValueType())
                {
                    this.codeGenerator.Unbox(this.indent, actualMethodCalled.MemberInfo.Class);
                }
            }
            InheritedAttributes ia = this.inheritedAttributes;

            this.objArgs = new InheritedAttributes(ia.CurrentMethod, ia.Assignment, ia.Reference, ia.ArrayAccessFound, actualMethodCalled, ia.IsParentNodeAnInvocation);
            // checks arguments with the parameters of the current method
            this.visitor.RuntimeCheckArguments(this.node, this.objArgs, actualMethodCalled, nextMethod);
            // call currentMethod
            TypeExpression hasReturn = this.codeGenerator.MakeCall(this.indent, this.node, dic[MethodInvocationArgument.DecorationAttributes], actualMethodCalled, (FieldAccessExpression)this.node.Identifier, arg);

            if (hasReturn.IsValueType() && (bool)dic[MethodInvocationArgument.MakeBox])
            {
                this.codeGenerator.Box(this.indent, hasReturn);
            }

            this.codeGenerator.br(this.indent, endLabel);
            // Check next method
            for (int k = nextMethod.Count - 1; k >= 0; k--)
            {
                this.codeGenerator.WriteLabel(this.indent, nextMethod[k]);
                this.codeGenerator.pop(this.indent);
            }
            if ((bool)dic[MethodInvocationArgument.Clean])
            {
                this.codeGenerator.WriteLabel(this.indent, nextMethodLabel);
            }

            return(dic[MethodInvocationArgument.DecorationAttributes]);
        }
        public override object Exec(SingleIdentifierExpression s, object arg)
        {
            // * 2. A message is sent with without the implicit object "method(...)"
            //// * 2.1 A method is called (not a constructor)
            MethodType actualMethodCalled = TypeExpression.As <MethodType>(node.ActualMethodCalled);

            if ((((MethodType)node.ActualMethodCalled).MemberInfo.ModifierMask & Modifier.Static) == 0)
            {
                this.codeGenerator.ldarg(this.indent, 0);
            }
            this.node.Arguments.Accept(this.visitor, this.objArgs);
            this.codeGenerator.Call(this.indent, actualMethodCalled, actualMethodCalled.MemberInfo.Class, s.Identifier);
            return(null);
        }
        public override Node VisitGetProcessIntent(GetProcessIntent intent)
        {
            var typeExpression = new TypeExpression("System.Diagnostics.Process");

            if (intent.Id != null)
            {
                return(new Invocation(new MemberAccess(typeExpression, "GetProcessById"), new ArgumentList(new Argument(intent.Id))));
            }
            if (intent.Name != null)
            {
                return(new Invocation(new MemberAccess(typeExpression, "GetProcessesByName"), new ArgumentList(new Argument(intent.Name))));
            }
            return(new Invocation(new MemberAccess(typeExpression, "GetProcesses"), new ArgumentList()));
        }
Beispiel #5
0
        /// <summary>
        ///   Defines the constant in the @parent
        /// </summary>
        public override bool Define()
        {
            if (!base.Define())
            {
                return(false);
            }

            if (!member_type.IsConstantCompatible)
            {
                Error_InvalidConstantType(member_type, Location, Report);
            }

            FieldAttributes field_attr = FieldAttributes.Static | ModifiersExtensions.FieldAttr(ModFlags);

            // Decimals cannot be emitted into the constant blob.  So, convert to 'readonly'.
            if (member_type.BuiltinType == BuiltinTypeSpec.Type.Decimal)
            {
                field_attr |= FieldAttributes.InitOnly;
            }
            else
            {
                field_attr |= FieldAttributes.Literal;
            }

            FieldBuilder = Parent.TypeBuilder.DefineField(Name, MemberType.GetMetaInfo(), field_attr);
            spec         = new ConstSpec(Parent.Definition, this, MemberType, FieldBuilder, ModFlags, initializer);

            Parent.MemberCache.AddMember(spec);

            if ((field_attr & FieldAttributes.InitOnly) != 0)
            {
                Parent.PartialContainer.RegisterFieldForInitialization(this,
                                                                       new FieldInitializer(spec, initializer, this));
            }

            if (declarators != null)
            {
                var t     = new TypeExpression(MemberType, TypeExpression.Location);
                int index = Parent.PartialContainer.Constants.IndexOf(this);
                foreach (var d in declarators)
                {
                    var c = new Const(Parent, t, ModFlags & ~Modifiers.STATIC, new MemberName(d.Name.Value, d.Name.Location), OptAttributes);
                    c.initializer = d.Initializer;
                    ((ConstInitializer)c.initializer).Name = d.Name.Value;
                    Parent.PartialContainer.Constants.Insert(++index, c);
                }
            }

            return(true);
        }
 /// <summary>
 /// To assign the IsDynamicProperty
 /// </summary>
 /// <param name="typeExpression1">First type expression</param>
 /// <param name="typeExpression2">Second type expression</param>
 public void AssignDynamism(TypeExpression typeExpression1, TypeExpression typeExpression2)
 {
     if (this.EverythingDynamic)
     {
         typeExpression1.IsDynamic = typeExpression2.IsDynamic = true;
         return;
     }
     if (this.EverythingStatic)
     {
         typeExpression1.IsDynamic = typeExpression2.IsDynamic = false;
         return;
     }
     typeExpression1.IsDynamic = typeExpression2.IsDynamic = typeExpression1.IsDynamic | typeExpression2.IsDynamic;
 }
Beispiel #7
0
 public override object Exec(FieldType d, object arg)
 {
     if (d.FieldTypeExpression != null)
     {
         // * If the field type is a dynamic union type, so it is the union
         UnionType unionType = TypeExpression.As <UnionType>(d.FieldTypeExpression);
         if (unionType != null)
         {
             DynVarOptions.Instance.AssignDynamism(d.FieldTypeExpression, d.IsDynamic);
         }
         return(d.FieldTypeExpression.AcceptOperation(this, arg));
     }
     return(null);
 }
 public void AssignDynamism(TypeExpression typeExpression, bool isDynamic)
 {
     if (this.EverythingDynamic)
     {
         typeExpression.IsDynamic = true;
         return;
     }
     if (this.EverythingStatic)
     {
         typeExpression.IsDynamic = false;
         return;
     }
     typeExpression.IsDynamic = isDynamic;
 }
Beispiel #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="alpha">The type expression to be modified</param>
 /// <param name="beta">The type to be added</param>
 /// <param name="sortOfUnification">The kind of unification used in the assignment</param>
 public FieldTypeAssignmentConstraint(FieldType alpha, TypeExpression beta, SortOfUnification sortOfUnification)
 {
     this.alpha = alpha;
     this.beta  = beta;
     if (sortOfUnification == SortOfUnification.Equivalent)
     {
         // * Equivalence is translated into override when fields are assigned
         this.sortOfUnification = SortOfUnification.Override;
     }
     else
     {
         this.sortOfUnification = sortOfUnification;
     }
 }
        public override object Exec(FieldAccessExpression f, object arg)
        {
            // * 1. A message has been sent with the syntax "obj.method(...)"
            TypeExpression caller = this.node.ActualMethodCalled;

            if (caller != null)
            {
                return(caller.AcceptOperation(new CGILMethodInvocationOperation <T>(
                                                  this.indent, this.visitor, this.codeGenerator, this.node,
                                                  this.inheritedAttributes, this.objArgs, this.objInv), arg));
            }

            throw new FieldAccessException();
        }
Beispiel #11
0
            /// <summary>
            /// Constructs an AST that represents a root namespace with a single class, Test, containing a single
            /// method, Main, which contains a single statement that writes "hello" to the console.
            /// </summary>
            private RootNamespaceDeclaration ConstructRootNamespace()
            {
                //Normally this routine will use a parser to parse the contents of this.SourceLocation.
                //However, this sample just illustrates how an AST can be constructed and then compiled to a PE file,
                //so parsing is not necessary.

                var nameTable = this.Helper.Compilation.NameTable;

                //Note that this is top down constrution, exploiting the mutability of the member lists.
                //Some parsers may need to do bottom up construction, which is also supported.

                var namespaceMembers = new List <INamespaceDeclarationMember>(1);
                var result           = new RootNamespaceDeclaration(this, null, namespaceMembers, this.sourceLocation);

                var typeName            = nameTable.GetNameFor("Test");
                var typeNameDeclaration = new NameDeclaration(typeName, this.sourceLocation);
                var baseTypes           = new List <TypeExpression>(0);
                var typeMembers         = new List <ITypeDeclarationMember>(1);
                var classDeclaration    = new NamespaceClassDeclaration(null, TypeDeclaration.Flags.None, typeNameDeclaration, null,
                                                                        baseTypes, typeMembers, this.sourceLocation);

                namespaceMembers.Add(classDeclaration);

                var voidExpr              = TypeExpression.For(this.Helper.Compilation.PlatformType.SystemVoid);
                var methodName            = nameTable.GetNameFor("Main");
                var methodNameDeclaration = new NameDeclaration(methodName, this.sourceLocation);
                var statements            = new List <Statement>(1);
                var body = new BlockStatement(statements, this.sourceLocation);
                var methodDeclaration = new MethodDeclaration(null, MethodDeclaration.Flags.Static, TypeMemberVisibility.Public, voidExpr, null,
                                                              methodNameDeclaration, null, null, null, body, this.sourceLocation);

                typeMembers.Add(methodDeclaration);

                var system        = new SimpleName(nameTable.GetNameFor("System"), this.sourceLocation, false);
                var console       = new SimpleName(nameTable.GetNameFor("Console"), this.sourceLocation, false);
                var systemConsole = new QualifiedName(system, console, this.sourceLocation);
                var writeLine     = new SimpleName(nameTable.GetNameFor("WriteLine"), this.sourceLocation, false);
                var methodToCall  = new QualifiedName(systemConsole, writeLine, this.sourceLocation);
                var arguments     = new List <Expression>(1);

                arguments.Add(new CompileTimeConstant("hello", this.sourceLocation));
                var methodCall    = new MethodCall(methodToCall, arguments, this.sourceLocation);
                var callStatement = new ExpressionStatement(methodCall, this.sourceLocation.SourceDocument.GetSourceLocation(0, 5));

                statements.Add(callStatement);

                //The statements above do only the first phase initialization of the AST. The second phase
                //occurs as the AST is traversed from the top down.
                return(result);
            }
Beispiel #12
0
        protected override Expression DoResolve(ResolveContext rc)
        {
//			BEN: This won't work because the returned type won't pass Mono's type checkers.
//			if (rc.Target == Target.JavaScript) {
//				this.type = rc.Module.PredefinedTypes.AsArray.Resolve();
//				this.eclass = ExprClass.Value;
//				foreach (var elem in Elements)
//					elem.Resolve (rc);
//				return this;
//			}

            TypeExpression type;

            if (vectorType != null)               // For new <Type> [ initializer ] expressions..
            {
                var elemTypeSpec = vectorType.ResolveAsType(rc);
                if (elemTypeSpec != null)
                {
                    type = new TypeExpression(
                        rc.Module.PredefinedTypes.AsVector.Resolve().MakeGenericType(rc, new [] { elemTypeSpec }), Location);
                }
                else
                {
                    type = new TypeExpression(rc.Module.PredefinedTypes.AsArray.Resolve(), Location);
                }
            }
            else
            {
                type = new TypeExpression(rc.Module.PredefinedTypes.AsArray.Resolve(), Location);
            }

            TypeSpec typeSpec = type.ResolveAsType(rc.MemberContext);

            if (typeSpec.IsArray)
            {
                ArrayCreation arrayCreate = (ArrayCreation) new ArrayCreation(type, this).Resolve(rc);
                return(arrayCreate);
            }
            else
            {
                var initElems = new List <Expression>();
                foreach (var e in elements)
                {
                    initElems.Add(new CollectionElementInitializer(e));
                }
                return(new NewInitialize(type, null,
                                         new CollectionOrObjectInitializers(initElems, Location), Location).Resolve(rc));
            }
        }
        public override object Exec(NullType firstOperand, object arg)
        {
            // * Built-in types: no promotion, except string
            if (this.secondOperand is BoolType || this.secondOperand is CharType || this.secondOperand is DoubleType || this.secondOperand is IntType || this.secondOperand is VoidType)
            {
                return(-1);
            }
            // * BCL Value Types (structs): No promotion
            BCLClassType bclClass = TypeExpression.As <BCLClassType>(this.secondOperand);

            if (bclClass != null)
            {
                if (bclClass.TypeInfo.IsValueType)
                {
                    return(-1);
                }
                // * Correct promotion to classes that are not value types
                return(0);
            }
            // * WriteType variable
            TypeVariable typeVariable = this.secondOperand as TypeVariable;

            if (typeVariable != null)
            {
                if (typeVariable.Substitution != null)
                {
                    // * If the variable is bounded, the promotion is the one of its substitution
                    return(firstOperand.AcceptOperation(new PromotionLevelOperation(typeVariable.EquivalenceClass.Substitution), arg));
                }
                // * A free variable is complete promotion
                return(0);
            }
            // * Union type
            UnionType unionType = TypeExpression.As <UnionType>(this.secondOperand);

            if (unionType != null)
            {
                return(unionType.SuperType(firstOperand));
            }
            // * Field type and bounded type variable
            FieldType fieldType = TypeExpression.As <FieldType>(this.secondOperand);

            if (fieldType != null)
            {
                return(firstOperand.AcceptOperation(new PromotionLevelOperation(fieldType.FieldTypeExpression), arg));
            }
            // * Correct Promotion
            return(0);
        }
        // Unbox <token>
        // Revert a boxed value type instance from the object form to its value type form. <token> specifies the value type being converted and must be a valid TypeDef or TypeRef token.
        // This instruction takes an object reference from the stack and puts a managed pointer to the value type instance on the stack.

        /// <summary>
        /// Writes the Unbox and ldobj instruction (Unbox.any = Unbox + ldobj)
        /// </summary>
        /// <param name="indent">Indentation to use.</param>
        /// <param name="type">Value type to revert.</param>
        public override void UnboxAny(int indent, TypeExpression type)
        {
            if (type is UnionType)
            {
                this.UnboxAny(indent, type as UnionType);
            }
            else if (!(type is TypeVariable))
            {
                this.WriteLNUnaryCommand(indent, "unbox.any", type.ILType());
            }
            else if (((TypeVariable)type).Substitution != null)
            {
                this.WriteLNUnaryCommand(indent, "unbox.any", type.ILType());
            }
        }
Beispiel #15
0
        public void testUnify3Wrong()
        {
            // * "Array(Var(alpha))->Var(alpha)"
            TypeExpression alpha = TypeVariable.NewTypeVariable;
            MethodType     type1 = new MethodType(alpha);

            type1.AddParameter(new ArrayType(alpha));

            // * "Array(Array(int))->double"
            MethodType type2 = new MethodType(DoubleType.Instance);

            type2.AddParameter(new ArrayType(new ArrayType(IntType.Instance)));

            Unify(type1, type2);
        }
Beispiel #16
0
        private void Unify(TypeExpression type1, TypeExpression type2)
        {
            Console.WriteLine("To Unify\n\tType 1:\t{0}\n\tType 2:\t{1}", type1, type2);

            bool unification = type1.Unify(type2, SortOfUnification.Equivalent, new List <Pair <TypeExpression, TypeExpression> >());

            Console.WriteLine("The unification is {0}.", unification);

            if (unification)
            {
                Console.WriteLine("And these are the results:\n\tType 1:\t{0}\n\tType 2:\t{1}", type1, type2);
            }

            Console.WriteLine();
        }
        public override object Exec(TypeExpression operand1, object arg)
        {
            if (this.operand2 == operand1)
            {
                return(true);
            }
            TypeVariable typeVariable = this.operand2 as TypeVariable;

            if (typeVariable != null)
            {
                return(typeVariable.AcceptOperation(new EquivalentOperation(operand1), arg));
            }

            return(operand1.FullName.Equals(this.operand2.FullName));
        }
Beispiel #18
0
        ///  * ld       <implicit object>
        ///  * <for each method of UnionMethods>
        ///  *    // check the invocation reference
        ///  *    dup
        ///  *    isinst <class type of actualMethod>
        ///  *    brfalse <check NextMethod> (Unbox needed for value types (not Unbox.any))
        ///  *    // check arguments
        ///  *    <for each argument>
        ///  *       dup
        ///  *       isinst <current parameter of actualMethod> (If param is ValueType, is the argument of this type or can promote to this type?)
        ///  *       brfalse <NextMethod> (Box needed for value types)
        ///  *    call <current method>
        ///  *    br <EndLabel>
        ///  *    // check NextMethod
        ///  *    <NextMethod>
        ///  *    <clean elements on the stack>
        ///  *  // There are some mistakes
        ///  *  call <WrongMethodException>
        ///  *  <EndLabel>

        #endregion
        public override Object Visit(InvocationExpression node, Object obj)
        {
            InheritedAttributes ia = (InheritedAttributes)obj; //Simple cast to shorten thee expression
            Object objArgs         = obj;
            //Object o = null;
            InheritedAttributes objInv             = new InheritedAttributes(ia.CurrentMethod, ia.Assignment, ia.Reference, ia.ArrayAccessFound, ia.ActualMethodCalled, true);
            MethodType          actualMethodCalled = TypeExpression.As <MethodType>(node.ActualMethodCalled);

            if (actualMethodCalled != null)
            {
                objArgs = new InheritedAttributes(ia.CurrentMethod, ia.Assignment, ia.Reference, ia.ArrayAccessFound, actualMethodCalled, true);
            }

            return(node.Identifier.AcceptOperation(new CGILInvocationExpressionOperation <T>(this.indent, this, this.codeGenerator, node, ia, objInv, objArgs), null));
        }
        /// <summary>
        /// Tries to unify the constraints of a method call
        /// </summary>
        /// <param name="methodAnalyzed">The method that is being analyzed when the operation is performed.</param>
        /// <param name="actualImplicitObject">Only suitable in an assignment constraint. It represents the actual object used to pass the message.</param>
        /// <param name="showInvocationMessage">To show the invocation line and column in case an error exists</param>
        /// <param name="activeSortOfUnification">The active sort of unification used (Equivalent is the default
        /// one and Incremental is used in the SSA bodies of the while, for and do statements)</param>
        /// <param name="location">The location of the method call.</param>
        /// <returns>If the unification has been satisfied</returns>
        public override TypeExpression Check(MethodType methodAnalyzed, TypeExpression actualImplicitObject, bool showInvocationMessage,
                                             SortOfUnification activeSortOfUnification, Location location)
        {
            TypeExpression result = (TypeExpression)this.FirstOperand.Exec(new BracketOperation(this.SecondOperand, methodAnalyzed, true, this.Location));

            if (result == null && showInvocationMessage)
            {
                ErrorManager.Instance.NotifyError(new ConstraintError(location));
                return(null);
            }
            // * If no error exists, we unify the return type variable with the actual result
            this.ReturnType.Unify(result, SortOfUnification.Equivalent, new List <Pair <TypeExpression, TypeExpression> >());
            this.ReturnType.ValidTypeExpression = this.ValidTypeExpression = false;
            return(this.ReturnType);
        }
Beispiel #20
0
        protected override bool TypeChecking(List <Error> errors, SymbolTable symbolTable)
        {
            TypeExpression iterType = IterationInstr.ReturnType;

            if (iterType is VoidType)
            {
                ReturnType = TypeExpression.VoidType;
                return(true);
            }
            string message = string.Format("The type of a loop's body expression must be void");

            errors.Add(new Error(message, IterationInstr.Line, IterationInstr.CharPositionInLine));
            ReturnType = TypeExpression.ErrorType;
            return(false);
        }
Beispiel #21
0
        public override object Exec(UnionType d, object arg)
        {
            // * Infinite loop detection
            if (previousDot.Contains(d))
            {
                return(new UnionType());
            }
            previousDot.Add(d);

            // * If all the types in typeset generate a constraint, we simply generate one constraint using the whole union type
            if (d.IsFreshVariable() && methodAnalyzed != null)
            {
                // * A constraint is added to the method analyzed
                DotConstraint constraint = new DotConstraint(d, this.memberName, this.location);
                methodAnalyzed.AddConstraint(constraint);
                return(constraint.ReturnType);
            }
            TypeExpression returnType = null;

            foreach (TypeExpression type in d.TypeSet)
            {
                TypeExpression ret;
                if (!d.IsDynamic)
                {
                    // * Static Behaviour: All the types must accept the attribute access
                    ret = (TypeExpression)type.AcceptOperation(this, arg);
                    if (ret == null)
                    {
                        return(null);
                    }
                }
                else
                {
                    // * Dynamic Behaviour: Only one type must accept the attribute access
                    ret = (TypeExpression)type.AcceptOperation(new UnconstrainedDotOperation(this.memberName, previousDot), arg);
                }
                if (ret != null)
                {
                    returnType = UnionType.collect(returnType, ret);
                }
            }
            // * If it is a dynamic union, one type must accept the attribute access
            if (returnType == null)
            {
                ErrorManager.Instance.NotifyError(new NoTypeHasMember(d.FullName, this.memberName, this.location));
            }
            return(returnType);
        }
Beispiel #22
0
        /// <summary>
        /// Checks if a token its a contained in the TypeTable
        /// First find on the TypeTable as it
        /// Second find appending the "Usings" of the source file
        /// Third find appendid the namespaces of the source file
        /// </summary>
        /// <param name="token">IToken with correct line number and colum</param>
        /// <returns>True if TypeTable Contains the token</returns>
        public bool CheckTokenTypeOnCurrentDocument(IToken token)
        {
            //Get the currect open file name
            string currentDocumentFileName = FileUtilities.Instance.getCurrentOpenDocumentFilePath();
            //Refresh the fileName
            // token.setFilename(currentDocumentFileName);

            // Location location = ITokenToLocation.Instance.convertToLocation(token);

            //Location location = new Location(Path.GetFileName(currentDocumentFileName), token.getLine(), token.getColumn());
            Location location = new Location(currentDocumentFileName, token.getLine(), token.getColumn());

            TypeExpression tokenType = null;

            //Simple search on typeTable
            tokenType = TypeTable.Instance.GetType(token.getText(), location);

            if (tokenType != null)
            {
                return(true);
            }

            //Get the current AST
            StaDynSourceFileAST currentSourceFile = ProjectFileAST.Instance.getAstFile(currentDocumentFileName);

            if (currentSourceFile == null || currentSourceFile.Ast == null)
            {
                return(false);
            }

            //if (currentSourceFile.Ast == null) return false;

            tokenType = this.findTypeAtUsings(token.getText(), location, currentSourceFile.Ast.Usings);

            if (tokenType != null)
            {
                return(true);
            }

            tokenType = this.findTypeAtCurrentNameSpace(token.getText(), location, currentSourceFile.Ast);

            if (tokenType != null)
            {
                return(true);
            }

            return(false);
        }
Beispiel #23
0
        public override object Exec(ClassType d, object arg)
        {
            TypeExpression member = (TypeExpression)d.AcceptOperation(new UnconstrainedDotOperation(memberName, this.previousDot), arg);

            if (member == null)
            {
                ErrorManager.Instance.NotifyError(new UnknownMemberError(this.memberName, this.location));
                return(null);
            }
            if (!d.validAccess(member))
            {
                ErrorManager.Instance.NotifyError(new ProtectionLevelError(this.memberName, this.location));
                return(null);
            }
            return(member);
        }
 /// <summary>
 /// It delegates the operation in several types.
 /// </summary>
 /// <param name="operand"></param>
 /// <returns></returns>
 public override object Exec(TypeVariable operand, object arg)
 {
     if (!operand.IsValueType())
     {
         return(null);
     }
     if (TypeExpression.Is <IntType>(operand))
     {
         return(this.Exec(TypeExpression.As <IntType>(operand), arg));
     }
     if (TypeExpression.Is <DoubleType>(operand))
     {
         return(this.Exec(TypeExpression.As <DoubleType>(operand), arg));
     }
     return(this.Exec((TypeExpression)operand, arg));
 }
        public override object Exec(TypeVariable t, object arg)
        {
            if (!t.IsFreshVariable())
            {
                return(t.Substitution.AcceptOperation(this, arg));
            }

            this.hasTypeVariable = true;
            if (this.firstTime)
            {
                this.firstTime = false;
                this.areThereNonValidObjects = TypeExpression.As <UnionType>(((FieldAccessExpression)this.node.Identifier).Expression.ExpressionType) != null;
                this.EndInvocationMethod(false);
            }
            return(null);
        }
        public ImageSource getImage(TypeExpression type, IGlyphService glyphService)
        {
            //StandardGlyphGroup group;
            StandardGlyphItem item = StandardGlyphItem.GlyphItemPublic;

            if (type is IMemberType)
            {
                //group = this.getGroupVSValue(type);
                if (((IMemberType)type).MemberInfo != null)
                {
                    item = this.getItemVSValue(((IMemberType)type).MemberInfo);
                }
            }

            return(glyphService.GetGlyph(this.getGroupVSValue(type), item));
        }
Beispiel #27
0
        protected override bool TypeChecking(List <Error> errors, SymbolTable symbolTable)
        {
            TypeExpression thenType     = ThenInstruction.ReturnType;
            TypeExpression expectedType = ExpectedType();

            if (thenType.IsEquivalent(expectedType))
            {
                ReturnType = (expectedType.PrimitiveType is BuiltInType) ? expectedType.PrimitiveType : expectedType;
                return(true);
            }
            string message = string.Format("Could not convert type : '{0}' to '{1}'. {2}", thenType, expectedType, TypeMessage);

            errors.Add(new Error(message, ThenInstruction.Line, ThenInstruction.CharPositionInLine));
            ReturnType = TypeExpression.ErrorType;
            return(false);
        }
Beispiel #28
0
        /// <summary>
        /// Insert a new symbol in the current scope.
        /// </summary>
        /// <param name="id">Symbol identifier.</param>
        /// <param name="type">Symbol type.</param>
        /// <param name="isDynamic">True if the symbol is dynamic, false otherwise.</param>
        /// <returns>The symbol inserted, null otherwise.</returns>
        public Symbol Insert(string id, TypeExpression type, bool isDynamic)
        {
            if (this.table[this.table.Count - 1].ContainsKey(id))
            {
                return(null);
            }
            if (type is TypeVariable && type.IsDynamic && id.EndsWith("0"))
            {
                updateSSATypeVariables(id);
            }
            Symbol s = new Symbol(id, this.table.Count - 1, type, isDynamic);

            this.table[this.table.Count - 1].Add(id, s);
            //Console.WriteLine(s.ToString());
            return(s);
        }
 /// <summary>
 /// Tries to unify the constraints of a method call
 /// </summary>
 /// <param name="methodAnalyzed">The method that is being analyzed when the operation is performed.</param>
 /// <param name="actualImplicitObject">Only suitable in an assignment constraint. It represents the actual object used to pass the message.</param>
 /// <param name="showInvocationMessage">To show the invocation line and column in case an error exists</param>
 /// <param name="activeSortOfUnification">The active sort of unification used (Equivalent is the default
 /// one and Incremental is used in the SSA bodies of the while, for and do statements)</param>
 /// <param name="location">The location of the method call</param>
 /// <returns>If the unification has been satisfied</returns>
 public override TypeExpression Check(MethodType methodAnalyzed, TypeExpression actualImplicitObject, bool showInvocationMessage, SortOfUnification activeSortOfUnification, Location location)
 {
     foreach (ConstraintList constraint in this.ConstraintLists)
     {
         TypeExpression result = constraint.Check(methodAnalyzed, actualImplicitObject, false, activeSortOfUnification, location);
         if (result != null)
         {
             return(result);
         }
     }
     if (showInvocationMessage)
     {
         ErrorManager.Instance.NotifyError(new ConstraintError(location));
     }
     return(null);
 }
Beispiel #30
0
        public void testUnify6OK()
        {
            // * "( Var(alpha) -> Array( int )"
            TypeExpression alpha = TypeVariable.NewTypeVariable;
            MethodType     type1 = new MethodType(new ArrayType(IntType.Instance));

            type1.AddParameter(alpha);

            // * "( Var(beta) -> Array( Var(beta) )"
            TypeExpression beta  = TypeVariable.NewTypeVariable;
            MethodType     type2 = new MethodType(new ArrayType(beta));

            type2.AddParameter(beta);

            Unify(type1, type2);
        }
Beispiel #31
0
		/// <summary>
		///   Defines the constant in the @parent
		/// </summary>
		public override bool Define ()
		{
			if (!base.Define ())
				return false;

			if (!member_type.IsConstantCompatible) {
				Error_InvalidConstantType (member_type, Location, Report);
			}

			FieldAttributes field_attr = FieldAttributes.Static | ModifiersExtensions.FieldAttr (ModFlags);
			// Decimals cannot be emitted into the constant blob.  So, convert to 'readonly'.
			if (member_type.BuiltinType == BuiltinTypeSpec.Type.Decimal) {
				field_attr |= FieldAttributes.InitOnly;
			} else {
				field_attr |= FieldAttributes.Literal;
			}

			FieldBuilder = Parent.TypeBuilder.DefineField (Name, MemberType.GetMetaInfo (), field_attr);
			spec = new ConstSpec (Parent.Definition, this, MemberType, FieldBuilder, ModFlags, initializer);

			Parent.MemberCache.AddMember (spec);

			if ((field_attr & FieldAttributes.InitOnly) != 0)
				Parent.PartialContainer.RegisterFieldForInitialization (this,
					new FieldInitializer (this, initializer, Location));

			if (declarators != null) {
				var t = new TypeExpression (MemberType, TypeExpression.Location);
				foreach (var d in declarators) {
					var c = new Const (Parent, t, ModFlags & ~Modifiers.STATIC, new MemberName (d.Name.Value, d.Name.Location), OptAttributes);
					c.initializer = d.Initializer;
					((ConstInitializer) c.initializer).Name = d.Name.Value;
					c.Define ();
					Parent.PartialContainer.Members.Add (c);
				}
			}

			return true;
		}
Beispiel #32
0
    private void ParseProperty(List<ITypeDeclarationMember> members, 
      List<SourceCustomAttribute>/*?*/ attributes, List<ModifierToken> modifiers, TypeExpression type, List<TypeExpression>/*?*/ implementedInterfaces, 
      NameDeclaration name, SourceLocationBuilder sctx, TokenSet followers) 
      //^ requires (this.currentToken == Token.This && name.Value == "Item") || this.currentToken == Token.LeftBrace;
      //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
    {
      PropertyDeclaration.Flags flags = 0;
      TypeMemberVisibility visibility = this.ConvertToTypeMemberVisibility(modifiers);
      if (this.LookForModifier(modifiers, Token.Abstract, Error.None)) flags |= PropertyDeclaration.Flags.Abstract;
      if (this.LookForModifier(modifiers, Token.New, Error.None)) flags |= PropertyDeclaration.Flags.New;
      if (this.LookForModifier(modifiers, Token.Extern, Error.None)) flags |= PropertyDeclaration.Flags.External;
      if (this.LookForModifier(modifiers, Token.Override, Error.None)) flags |= PropertyDeclaration.Flags.Override;
      this.LookForModifier(modifiers, Token.Readonly, Error.InvalidModifier);
      if (this.LookForModifier(modifiers, Token.Sealed, Error.None)) flags |= PropertyDeclaration.Flags.Sealed;
      if (this.LookForModifier(modifiers, Token.Static, Error.None)) flags |= PropertyDeclaration.Flags.Static;
      if (this.LookForModifier(modifiers, Token.Unsafe, Error.None)) flags |= PropertyDeclaration.Flags.Unsafe;
      if (this.LookForModifier(modifiers, Token.Virtual, Error.None)) flags |= PropertyDeclaration.Flags.Virtual;
      this.LookForModifier(modifiers, Token.Volatile, Error.InvalidModifier);

      bool isIndexer = this.currentToken == Token.This;
      this.GetNextToken();
      List<Ast.ParameterDeclaration>/*?*/ parameters = null;
      if (isIndexer) {
        parameters = new List<Ast.ParameterDeclaration>();
        this.ParseParameters(parameters, Token.RightBracket, followers|Token.LeftBrace);
        this.Skip(Token.LeftBrace);
      }

      //if (this.currentToken == Token.LeftBrace)
      //  this.GetNextToken();
      //else {
      //  Error e = Error.ExpectedLeftBrace;
      //  if (implementedInterfaces != null) e = Error.ExplicitEventFieldImpl;
      //  this.SkipTo(followers|Token.LeftBracket|Token.Add|Token.Remove|Token.RightBrace, e);
      //}

      TokenSet followersOrRightBrace = followers|Token.RightBrace;
      List<SourceCustomAttribute>/*?*/ getterAttributes = null;
      TypeMemberVisibility getterVisibility = visibility;
      BlockStatement/*?*/ getterBody = null;
      List<SourceCustomAttribute>/*?*/ setterAttributes = null;
      BlockStatement/*?*/ setterBody = null;
      TypeMemberVisibility setterVisibility = visibility;
      bool alreadyComplainedAboutModifier = false;
      List<ModifierToken>/*?*/ accessorModifiers = null;
      SourceLocationBuilder/*?*/ bodyCtx = null;
      for (; ; ) {
        if (bodyCtx == null) bodyCtx = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
        List<SourceCustomAttribute>/*?*/ accessorAttrs = this.ParseAttributes(followers | Parser.GetOrLeftBracketOrSetOrModifier | Token.LeftBrace);
        switch (this.currentToken) {
          case Token.Get:
            if (accessorModifiers != null) {
              getterVisibility = this.ConvertToTypeMemberVisibility(accessorModifiers);
              accessorModifiers = null;
            }
            getterAttributes = accessorAttrs;
            if (getterBody != null)
              this.HandleError(Error.DuplicateAccessor);
            this.GetNextToken();
            bool bodyAllowed = true;
            if (this.currentToken == Token.Semicolon) {
              this.GetNextToken();
              bodyAllowed = false;
            }
            //this.ParseMethodContract(m, followers|Token.LeftBrace|Token.Semicolon, ref swallowedSemicolonAlready);
            if (bodyAllowed)
              getterBody = this.ParseBody(bodyCtx, followersOrRightBrace|Token.Set);
            bodyCtx = null;
            continue;
          case Token.Set:
            if (accessorModifiers != null) {
              setterVisibility = this.ConvertToTypeMemberVisibility(accessorModifiers);
              accessorModifiers = null;
            }
            setterAttributes = accessorAttrs;
            if (setterBody != null)
              this.HandleError(Error.DuplicateAccessor);
            this.GetNextToken();
            bodyAllowed = true;
            if (this.currentToken == Token.Semicolon) {
              this.GetNextToken();
              bodyAllowed = false;
            }
            //this.ParseMethodContract(m, followers|Token.LeftBrace|Token.Semicolon, ref swallowedSemicolonAlready);
            if (bodyAllowed)
              setterBody = this.ParseBody(bodyCtx, followersOrRightBrace|Token.Get);
            bodyCtx = null;
            continue;
          case Token.Protected:
          case Token.Internal:
          case Token.Private:
            if (accessorModifiers != null) goto case Token.Public;
            accessorModifiers = this.ParseModifiers();
            continue;
          case Token.Public:
          case Token.New:
          case Token.Abstract:
          case Token.Sealed:
          case Token.Static:
          case Token.Readonly:
          case Token.Volatile:
          case Token.Virtual:
          case Token.Override:
          case Token.Extern:
          case Token.Unsafe:
            if (!alreadyComplainedAboutModifier)
              this.HandleError(Error.NoModifiersOnAccessor);
            this.GetNextToken();
            alreadyComplainedAboutModifier = true;
            continue;
          case Token.RightBrace:
            break;
          default:
            this.HandleError(Error.GetOrSetExpected);
            break;
        }
        break;
      }
      sctx.UpdateToSpan(bodyCtx.GetSourceLocation());
      PropertyDeclaration prop = new PropertyDeclaration(attributes, flags, visibility, type, implementedInterfaces, name, parameters, 
        getterAttributes, getterBody, getterVisibility, setterAttributes, setterBody, setterVisibility, sctx.GetSourceLocation());
      members.Add(prop);
      this.SkipOverTo(Token.RightBrace, followers);
    }
		protected override Expression DoResolve (ResolveContext ec)
		{
			if (ec.Target == Target.JavaScript) {
				expr = Expr.Resolve (ec);
				objExpr = objExpr.Resolve (ec);
				type = ec.BuiltinTypes.Bool;
				eclass = ExprClass.Value;
				return this;
			}

			var objExpRes = objExpr.Resolve (ec);

			var args = new Arguments (1);
			args.Add (new Argument (expr));

			if (objExpRes.Type == ec.BuiltinTypes.Dynamic) {
				// If dynamic, cast to IDictionary<string,object> and call ContainsKey
				var dictExpr = new TypeExpression(ec.Module.PredefinedTypes.IDictionaryGeneric.Resolve().MakeGenericType(ec, 
				                      new [] { ec.BuiltinTypes.String, ec.BuiltinTypes.Object }), loc);
				return new Invocation (new MemberAccess (new Cast(dictExpr, objExpr, loc), "ContainsKey", loc), args).Resolve (ec);
			} else {
				string containsMethodName = "Contains";
	
				if (objExpRes.Type != null && objExpRes.Type.ImplementsInterface (ec.Module.PredefinedTypes.IDictionary.Resolve(), true)) {
					containsMethodName = "ContainsKey";
				}

				return new Invocation (new MemberAccess (objExpr, containsMethodName, loc), args).Resolve (ec);
			}
		}
		protected void EmitCall (EmitContext ec, Expression binder, Arguments arguments, bool isStatement)
		{
			//
			// This method generates all internal infrastructure for a dynamic call. The
			// reason why it's quite complicated is the mixture of dynamic and anonymous
			// methods. Dynamic itself requires a temporary class (ContainerX) and anonymous
			// methods can generate temporary storey as well (AnonStorey). Handling MVAR
			// type parameters rewrite is non-trivial in such case as there are various
			// combinations possible therefore the mutator is not straightforward. Secondly
			// we need to keep both MVAR(possibly VAR for anon storey) and type VAR to emit
			// correct Site field type and its access from EmitContext.
			//

			int dyn_args_count = arguments == null ? 0 : arguments.Count;
			int default_args = isStatement ? 1 : 2;
			var module = ec.Module;

			bool has_ref_out_argument = false;
			var targs = new TypeExpression[dyn_args_count + default_args];
			targs[0] = new TypeExpression (module.PredefinedTypes.CallSite.TypeSpec, loc);

			TypeExpression[] targs_for_instance = null;
			TypeParameterMutator mutator;

			var site_container = ec.CreateDynamicSite ();

			if (context_mvars != null) {
				TypeParameters tparam;
				TypeContainer sc = site_container;
				do {
					tparam = sc.CurrentTypeParameters;
					sc = sc.Parent;
				} while (tparam == null);

				mutator = new TypeParameterMutator (context_mvars, tparam);

				if (!ec.IsAnonymousStoreyMutateRequired) {
					targs_for_instance = new TypeExpression[targs.Length];
					targs_for_instance[0] = targs[0];
				}
			} else {
				mutator = null;
			}

			for (int i = 0; i < dyn_args_count; ++i) {
				Argument a = arguments[i];
				if (a.ArgType == Argument.AType.Out || a.ArgType == Argument.AType.Ref)
					has_ref_out_argument = true;

				var t = a.Type;

				// Convert any internal type like dynamic or null to object
				if (t.Kind == MemberKind.InternalCompilerType)
					t = ec.BuiltinTypes.Object;

				if (targs_for_instance != null)
					targs_for_instance[i + 1] = new TypeExpression (t, loc);

				if (mutator != null)
					t = t.Mutate (mutator);

				targs[i + 1] = new TypeExpression (t, loc);
			}

			TypeExpr del_type = null;
			TypeExpr del_type_instance_access = null;
			if (!has_ref_out_argument) {
				string d_name = isStatement ? "Action" : "Func";

				TypeExpr te = null;
				Namespace type_ns = module.GlobalRootNamespace.GetNamespace ("System", true);
				if (type_ns != null) {
					te = type_ns.LookupType (module, d_name, dyn_args_count + default_args, LookupMode.Normal, loc);
				}

				if (te != null) {
					if (!isStatement) {
						var t = type;
						if (t.Kind == MemberKind.InternalCompilerType)
							t = ec.BuiltinTypes.Object;

						if (targs_for_instance != null)
							targs_for_instance[targs_for_instance.Length - 1] = new TypeExpression (t, loc);

						if (mutator != null)
							t = t.Mutate (mutator);

						targs[targs.Length - 1] = new TypeExpression (t, loc);
					}

					del_type = new GenericTypeExpr (te.Type, new TypeArguments (targs), loc);
					if (targs_for_instance != null)
						del_type_instance_access = new GenericTypeExpr (te.Type, new TypeArguments (targs_for_instance), loc);
					else
						del_type_instance_access = del_type;
				}
			}

			//
			// Create custom delegate when no appropriate predefined delegate has been found
			//
			Delegate d;
			if (del_type == null) {
				TypeSpec rt = isStatement ? ec.BuiltinTypes.Void : type;
				Parameter[] p = new Parameter[dyn_args_count + 1];
				p[0] = new Parameter (targs[0], "p0", Parameter.Modifier.NONE, null, loc);

				var site = ec.CreateDynamicSite ();
				int index = site.Containers == null ? 0 : site.Containers.Count;

				if (mutator != null)
					rt = mutator.Mutate (rt);

				for (int i = 1; i < dyn_args_count + 1; ++i) {
					p[i] = new Parameter (targs[i], "p" + i.ToString ("X"), arguments[i - 1].Modifier, null, loc);
				}

				d = new Delegate (site, new TypeExpression (rt, loc),
					Modifiers.INTERNAL | Modifiers.COMPILER_GENERATED,
					new MemberName ("Container" + index.ToString ("X")),
					new ParametersCompiled (p), null);

				d.CreateContainer ();
				d.DefineContainer ();
				d.Define ();

				site.AddTypeContainer (d);
				del_type = new TypeExpression (d.CurrentType, loc);
				if (targs_for_instance != null) {
					del_type_instance_access = null;
				} else {
					del_type_instance_access = del_type;
				}
			} else {
				d = null;
			}

			var site_type_decl = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec, new TypeArguments (del_type), loc);
			var field = site_container.CreateCallSiteField (site_type_decl, loc);
			if (field == null)
				return;

			if (del_type_instance_access == null) {
				var dt = d.CurrentType.DeclaringType.MakeGenericType (module, context_mvars.Types);
				del_type_instance_access = new TypeExpression (MemberCache.GetMember (dt, d.CurrentType), loc);
			}

			var instanceAccessExprType = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec,
				new TypeArguments (del_type_instance_access), loc);

			if (instanceAccessExprType.ResolveAsType (ec.MemberContext) == null)
				return;

			bool inflate_using_mvar = context_mvars != null && ec.IsAnonymousStoreyMutateRequired;

			TypeSpec gt;
			if (inflate_using_mvar || context_mvars == null) {
				gt = site_container.CurrentType;
			} else {
				gt = site_container.CurrentType.MakeGenericType (module, context_mvars.Types);
			}

			// When site container already exists the inflated version has to be
			// updated manually to contain newly created field
			if (gt is InflatedTypeSpec && site_container.AnonymousMethodsCounter > 1) {
				var tparams = gt.MemberDefinition.TypeParametersCount > 0 ? gt.MemberDefinition.TypeParameters : TypeParameterSpec.EmptyTypes;
				var inflator = new TypeParameterInflator (module, gt, tparams, gt.TypeArguments);
				gt.MemberCache.AddMember (field.InflateMember (inflator));
			}

			FieldExpr site_field_expr = new FieldExpr (MemberCache.GetMember (gt, field), loc);

			BlockContext bc = new BlockContext (ec.MemberContext, null, ec.BuiltinTypes.Void);

			Arguments args = new Arguments (1);
			args.Add (new Argument (binder));
			StatementExpression s = new StatementExpression (new SimpleAssign (site_field_expr, new Invocation (new MemberAccess (instanceAccessExprType, "Create"), args)));

			using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {
				if (s.Resolve (bc)) {
					Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc)), s, loc);
					init.Emit (ec);
				}

				args = new Arguments (1 + dyn_args_count);
				args.Add (new Argument (site_field_expr));
				if (arguments != null) {
					int arg_pos = 1;
					foreach (Argument a in arguments) {
						if (a is NamedArgument) {
							// Name is not valid in this context
							args.Add (new Argument (a.Expr, a.ArgType));
						} else {
							args.Add (a);
						}

						if (inflate_using_mvar && a.Type != targs[arg_pos].Type)
							a.Expr.Type = targs[arg_pos].Type;

						++arg_pos;
					}
				}

				Expression target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, loc).Resolve (bc);
				if (target != null)
					target.Emit (ec);
			}
		}
			public override object Visit (TypeExpression typeExpression)
			{
				return new TypeReferenceExpression (new PrimitiveType (keywordTable [(int)typeExpression.Type.BuiltinType], Convert (typeExpression.Location)));
			}
Beispiel #36
0
void case_257()
#line 2252 "cs-parser.jay"
{
		report.Error (590, GetLocation (yyVals[0+yyTop]), "User-defined operators cannot return void");
		yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop]));
	  }
Beispiel #37
0
void case_403()
#line 3298 "cs-parser.jay"
{
		Expression.Error_VoidInvalidInTheContext (GetLocation (yyVals[0+yyTop]), report);
		yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop]));
	  }
Beispiel #38
0
    private void ParseEventWithAccessors(List<ITypeDeclarationMember> members, 
      List<SourceCustomAttribute>/*?*/ attributes, List<ModifierToken> modifiers, TypeExpression type, NameDeclaration name, SourceLocationBuilder sctx, TokenSet followers)
      //^ requires this.currentToken == Token.Dot || this.currentToken == Token.LessThan || this.currentToken == Token.LeftBrace;
      //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
    {
      EventDeclaration.Flags flags = 0;
      TypeMemberVisibility visibility = this.ConvertToTypeMemberVisibility(modifiers);
      if (this.LookForModifier(modifiers, Token.Abstract, Error.None)) flags |= EventDeclaration.Flags.Abstract;
      if (this.LookForModifier(modifiers, Token.New, Error.None)) flags |= EventDeclaration.Flags.New;
      if (this.LookForModifier(modifiers, Token.Extern, Error.None)) flags |= EventDeclaration.Flags.External;
      if (this.LookForModifier(modifiers, Token.Override, Error.None)) flags |= EventDeclaration.Flags.Override;
      this.LookForModifier(modifiers, Token.Readonly, Error.InvalidModifier);
      if (this.LookForModifier(modifiers, Token.Sealed, Error.None)) flags |= EventDeclaration.Flags.Sealed;
      if (this.LookForModifier(modifiers, Token.Static, Error.None)) flags |= EventDeclaration.Flags.Static;
      if (this.LookForModifier(modifiers, Token.Unsafe, Error.None)) flags |= EventDeclaration.Flags.Unsafe;
      if (this.LookForModifier(modifiers, Token.Virtual, Error.None)) flags |= EventDeclaration.Flags.Virtual;
      this.LookForModifier(modifiers, Token.Volatile, Error.InvalidModifier);

      List<TypeExpression>/*?*/ implementedInterfaces = null;
      Expression implementedInterface = this.ParseImplementedInterfacePlusName(ref name, false, followers);
      QualifiedName/*?*/ qual = implementedInterface as QualifiedName;
      if (qual != null) {
        implementedInterfaces = new List<TypeExpression>(1);
        GenericTypeInstanceExpression/*?*/ gte = qual.Qualifier as GenericTypeInstanceExpression;
        if (gte != null)
          implementedInterfaces.Add(gte);
        else {
          //^ assume qual.Qualifier is SimpleName || qual.Qualifier is QualifiedName; //follows from post condition of ParseImplementedInterfacePlusName
          implementedInterfaces.Add(new NamedTypeExpression(qual.Qualifier));
        }
      }

      if (this.currentToken == Token.LeftBrace) 
        this.GetNextToken();
      else{
        Error e = Error.ExpectedLeftBrace;
        if (implementedInterfaces != null) e = Error.ExplicitEventFieldImpl;
        this.SkipTo(followers|Token.LeftBracket|Token.Add|Token.Remove|Token.RightBrace, e);
      }

      TokenSet followersOrRightBrace = followers|Token.RightBrace;
      List<SourceCustomAttribute>/*?*/ adderAttributes = null;
      BlockStatement/*?*/ adderBody = null;
      List<SourceCustomAttribute>/*?*/ removerAttributes = null;
      BlockStatement/*?*/ removerBody = null;
      bool alreadyComplainedAboutModifier = false;
      for (; ; ) {
        List<SourceCustomAttribute>/*?*/ accessorAttrs = this.ParseAttributes(followers|Parser.AddOrRemoveOrModifier|Token.LeftBrace);
        switch (this.currentToken) {
          case Token.Add:
            adderAttributes = accessorAttrs;
            if (adderBody != null)
              this.HandleError(Error.DuplicateAccessor);
            this.GetNextToken();
            if (this.currentToken != Token.LeftBrace) {
              this.SkipTo(followersOrRightBrace|Token.Remove, Error.AddRemoveMustHaveBody);
            } else
              adderBody = this.ParseBody(followersOrRightBrace|Token.Remove);
            continue;
          case Token.Remove:
            removerAttributes = accessorAttrs;
            if (removerBody != null)
              this.HandleError(Error.DuplicateAccessor);
            this.GetNextToken();
            if (this.currentToken != Token.LeftBrace) {
              this.SkipTo(followersOrRightBrace|Token.Remove, Error.AddRemoveMustHaveBody);
              removerBody = null;
            } else
              removerBody = this.ParseBody(followersOrRightBrace|Token.Add);
            continue;
          case Token.New:
          case Token.Public:
          case Token.Protected:
          case Token.Internal:
          case Token.Private:
          case Token.Abstract:
          case Token.Sealed:
          case Token.Static:
          case Token.Readonly:
          case Token.Volatile:
          case Token.Virtual:
          case Token.Override:
          case Token.Extern:
          case Token.Unsafe:
            if (!alreadyComplainedAboutModifier)
              this.HandleError(Error.NoModifiersOnAccessor);
            this.GetNextToken();
            alreadyComplainedAboutModifier = true;
            continue;
          default:
            this.HandleError(Error.AddOrRemoveExpected);
            break;
        }
        break;
      }
      if (adderBody == null)
        adderBody = null;
      if (removerBody == null)
        removerBody = null;
      EventDeclaration evnt = new EventDeclaration(attributes, flags, visibility, type, implementedInterfaces, name, 
        adderAttributes, adderBody, removerAttributes, removerBody, sctx.GetSourceLocation());
      members.Add(evnt);
      this.SkipOverTo(Token.RightBrace, followers);
    }
Beispiel #39
0
 /// <summary>
 /// A copy constructor that allocates an instance that is the same as the given template, except for its containing block.
 /// </summary>
 /// <param name="containingBlock">The containing block of the copied postcondition. This should be different from the containing block of the template postcondition.</param>
 /// <param name="template">The statement to copy.</param>
 private ThrownException(BlockStatement containingBlock, ThrownException template)
     : base(template.SourceLocation)
 {
     this.exceptionType = (TypeExpression)template.ExceptionType.MakeCopyFor(containingBlock);
       this.postcondition = template.Postcondition.MakeCopyFor(containingBlock);
 }
Beispiel #40
0
 private List<Expression> ParseArrayInitializers(uint rank, TypeExpression elementType, TokenSet followers, bool doNotSkipClosingBrace, SourceLocationBuilder ctx)
   //^ requires this.currentToken == Token.LeftBrace;
   //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
 {
   this.GetNextToken();
   List<Expression> initialValues = new List<Expression>();
   if (this.currentToken == Token.RightBrace) {
     ctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
     this.GetNextToken();
     initialValues.TrimExcess();
     return initialValues;
   }
   while (true) {
     if (rank > 1) {
       List<Expression> elemArrayInitializers;
       SourceLocationBuilder ectx = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
       if (this.currentToken == Token.LeftBrace) {
         elemArrayInitializers = this.ParseArrayInitializers(rank-1, elementType, followers|Token.Comma|Token.LeftBrace, false, ectx);
       } else {
         elemArrayInitializers = new List<Expression>(0);
         this.SkipTo(followers|Token.Comma|Token.LeftBrace, Error.ExpectedLeftBrace);
       }
       CreateArray elemArr = new CreateArray(elementType, elemArrayInitializers.AsReadOnly(), new List<Expression>(0).AsReadOnly(), rank-1, new List<Expression>(0).AsReadOnly(), ectx);
       initialValues.Add(elemArr);
     } else {
       if (this.currentToken == Token.LeftBrace) {
         this.HandleError(Error.ArrayInitInBadPlace);
         SourceLocationBuilder ectx = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
         //^ assume this.currentToken == Token.LeftBrace;
         List<Expression> elemArrayInitializers = this.ParseArrayInitializers(1, elementType, followers|Token.Comma|Token.LeftBrace, false, ectx);
         CreateArray elemArr = new CreateArray(elementType, elemArrayInitializers.AsReadOnly(), new List<Expression>(0).AsReadOnly(), 1, new List<Expression>(0).AsReadOnly(), ectx);
         initialValues.Add(elemArr);
       } else
         initialValues.Add(this.ParseExpression(followers|Token.Comma|Token.RightBrace));
     }
     if (this.currentToken != Token.Comma) break;
     this.GetNextToken();
     if (this.currentToken == Token.RightBrace) break;
   }
   ctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
   if (!doNotSkipClosingBrace) {
     this.Skip(Token.RightBrace);
     this.SkipTo(followers);
   }
   initialValues.TrimExcess();
   return initialValues;
 }
Beispiel #41
0
 private void ParseEnumMember(TypeExpression typeExpression, List<ITypeDeclarationMember> members, TokenSet followers)
   //^ requires this.currentToken == Token.LeftBracket || Parser.IdentifierOrNonReservedKeyword[this.currentToken];
   //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
 {
   SourceLocationBuilder sctx = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
   List<SourceCustomAttribute>/*?*/ attributes = this.ParseAttributes(followers|Parser.AttributeOrTypeDeclarationStart|Parser.IdentifierOrNonReservedKeyword);
   if (!Parser.IdentifierOrNonReservedKeyword[this.currentToken])
     this.HandleError(Error.ExpectedIdentifier);
   NameDeclaration name = this.ParseNameDeclaration();
   Expression/*?*/ initializer = null;
   if (this.currentToken == Token.Assign) {
     this.GetNextToken();
     initializer = this.ParseExpression(followers);
   }
   EnumMember member = new EnumMember(attributes, typeExpression, name, initializer, sctx);
   members.Add(member);
   this.SkipTo(followers);
 }
Beispiel #42
0
 private TypeExpression ParseArrayType(uint rank, TypeExpression elementType, SourceLocationBuilder sctx, TokenSet followers)
   //^ requires rank > 0;
   //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
 {
   List<uint> rankList = new List<uint>();
   for (;;) 
     // ^ invariant forall{int i in (0:rankList.Count); rankList[i] > 0}; //TODO: find out why this does not parse
   {
     rankList.Add(rank); //TODO: find away to tell Boogie that this does not modify this.currentToken
     if (this.currentToken != Token.LeftBracket) break;
     rank = this.ParseRankSpecifier(sctx, followers|Token.LeftBracket);
   }
   for (int i = rankList.Count; i > 0; i--)
     // ^ invariant forall{int i in (0:rankList.Count); rankList[i] > 0};
   {
     rank = rankList[i-1];
     //^ assume rank > 0; 
     elementType = new ArrayTypeExpression(elementType, rank, sctx.GetSourceLocation()); //TODO: find away to tell Boogie that this does not modify this.currentToken
   }
   //^ assume followers[this.currentToken] || this.currentToken == Token.EndOfFile;
   return elementType;
 }
Beispiel #43
0
    private LocalDeclarationsStatement ParseLocalDeclarations(SourceLocationBuilder slb, TypeExpression typeExpression, bool constant, bool initOnly, bool skipSemicolon, TokenSet followers)
      //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
    {
      List<LocalDeclaration> declarations = new List<LocalDeclaration>();
      for (; ; ) {
        NameDeclaration locName = this.ParseNameDeclaration();
        SourceLocationBuilder locSctx = new SourceLocationBuilder(locName.SourceLocation);
        //if (this.currentToken == Token.LeftBracket) {
        //  this.HandleError(Error.CStyleArray);
        //  int endPos = this.scanner.endPos;
        //  int rank = this.ParseRankSpecifier(true, followers|Token.RightBracket|Parser.IdentifierOrNonReservedKeyword|Token.Assign|Token.Semicolon|Token.Comma);
        //  if (rank > 0)
        //    t = result.Type = result.TypeExpression =
        //      this.ParseArrayType(rank, t, followers|Token.RightBracket|Parser.IdentifierOrNonReservedKeyword|Token.Assign|Token.Semicolon|Token.Comma);
        //  else {
        //    this.currentToken = Token.LeftBracket;
        //    this.scanner.endPos = endPos;
        //    this.GetNextToken();
        //    while (!this.scanner.TokenIsFirstAfterLineBreak && 
        //      this.currentToken != Token.RightBracket && this.currentToken != Token.Assign && this.currentToken != Token.Semicolon)
        //      this.GetNextToken();
        //    if (this.currentToken == Token.RightBracket) this.GetNextToken();
        //  }
        //}
        //if (this.currentToken == Token.LeftParenthesis) {
        //  this.HandleError(Error.BadVarDecl);
        //  int dummy;
        //  SourceContext lpCtx = this.scanner.CurrentSourceContext;
        //  this.GetNextToken();
        //  this.ParseArgumentList(followers|Token.LeftBrace|Token.Semicolon|Token.Comma, lpCtx, out dummy);
        //} else 
        Expression/*?*/ locInitialValue = null;
        if (this.currentToken == Token.Assign || constant) {
          this.Skip(Token.Assign);
          ArrayTypeExpression/*?*/ arrayTypeExpression = typeExpression as ArrayTypeExpression;
          if (this.currentToken == Token.LeftBrace && arrayTypeExpression != null)
            locInitialValue = this.ParseArrayInitializer(arrayTypeExpression, followers|Token.Semicolon|Token.Comma);
          else
            locInitialValue = this.ParseExpression(followers|Token.Semicolon|Token.Comma);
        }
        locSctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
        if (declarations.Count == 0) locSctx.UpdateToSpan(typeExpression.SourceLocation);
        slb.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
        declarations.Add(new LocalDeclaration(false, false, locName, locInitialValue, locSctx));

        if (this.currentToken != Token.Comma) break;
        this.GetNextToken();

        //SourceContext sctx = this.scanner.CurrentSourceContext;
        //ScannerState ss = this.scanner.state;
        //TypeNode ty = this.ParseTypeExpression(null, followers|Token.Identifier|Token.Comma|Token.Semicolon, true);
        //if (ty == null || this.currentToken != Token.Identifier) {
        //  this.scanner.endPos = sctx.StartPos;
        //  this.scanner.state = ss;
        //  this.currentToken = Token.None;
        //  this.GetNextToken();
        //} else
        //  this.HandleError(sctx, Error.MultiTypeInDeclaration);
      }
      if (skipSemicolon) this.SkipSemiColon(followers);
      declarations.TrimExcess();
      LocalDeclarationsStatement result = new LocalDeclarationsStatement(constant, initOnly, !constant, typeExpression, declarations, slb);
      this.SkipTo(followers);
      return result;
    }
Beispiel #44
0
    //private ParseFixedPointerDeclarations

    private LocalDeclarationsStatement ParseFixedPointerDeclarations(SourceLocationBuilder slb, TypeExpression typeExpression, TokenSet followers)
      //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
    {
      List<LocalDeclaration> declarations = new List<LocalDeclaration>();
      for (; ; ) {
        NameDeclaration locName = this.ParseNameDeclaration();
        SourceLocationBuilder locSctx = new SourceLocationBuilder(locName.SourceLocation);
        if (declarations.Count == 0) locSctx.UpdateToSpan(typeExpression.SourceLocation);
        this.Skip(Token.Assign);
        Expression/*?*/ locInitialValue = this.ParseExpression(followers|Token.Semicolon|Token.Comma);
        locSctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
        slb.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
        declarations.Add(new FixedPointerDeclaration(locName, locInitialValue, locSctx));
        if (this.currentToken != Token.Comma) break;
        this.GetNextToken();
      }
      declarations.TrimExcess();
      LocalDeclarationsStatement result = new LocalDeclarationsStatement(false, true, false, typeExpression, declarations, slb);
      this.SkipTo(followers);
      return result;
    }
Beispiel #45
0
		protected override Expression DoResolve (ResolveContext ec)
		{
			constructor_method = Delegate.GetConstructor (type);

			var invoke_method = Delegate.GetInvokeMethod (type);

			if (!ec.HasSet (ResolveContext.Options.ConditionalAccessReceiver)) {
				if (method_group.HasConditionalAccess ()) {
					conditional_access_receiver = true;
					ec.Set (ResolveContext.Options.ConditionalAccessReceiver);
				}
			}

			Arguments arguments = CreateDelegateMethodArguments (ec, invoke_method.Parameters, invoke_method.Parameters.Types, loc);
			method_group = method_group.OverloadResolve (ec, ref arguments, this, OverloadResolver.Restrictions.CovariantDelegate);

			if (conditional_access_receiver)
				ec.With (ResolveContext.Options.ConditionalAccessReceiver, false);

			if (method_group == null)
				return null;

			var delegate_method = method_group.BestCandidate;
			
			if (delegate_method.DeclaringType.IsNullableType) {
				ec.Report.Error (1728, loc, "Cannot create delegate from method `{0}' because it is a member of System.Nullable<T> type",
					delegate_method.GetSignatureForError ());
				return null;
			}		
			
			if (!AllowSpecialMethodsInvocation)
				Invocation.IsSpecialMethodInvocation (ec, delegate_method, loc);

			ExtensionMethodGroupExpr emg = method_group as ExtensionMethodGroupExpr;
			if (emg != null) {
				method_group.InstanceExpression = emg.ExtensionExpression;
				TypeSpec e_type = emg.ExtensionExpression.Type;
				if (TypeSpec.IsValueType (e_type)) {
					ec.Report.Error (1113, loc, "Extension method `{0}' of value type `{1}' cannot be used to create delegates",
						delegate_method.GetSignatureForError (), e_type.GetSignatureForError ());
				}
			}

			TypeSpec rt = method_group.BestCandidateReturnType;
			if (rt.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
				rt = ec.BuiltinTypes.Object;

			if (!Delegate.IsTypeCovariant (ec, rt, invoke_method.ReturnType)) {
				Expression ret_expr = new TypeExpression (delegate_method.ReturnType, loc);
				Error_ConversionFailed (ec, delegate_method, ret_expr);
			}

			if (method_group.IsConditionallyExcluded) {
				ec.Report.SymbolRelatedToPreviousError (delegate_method);
				MethodOrOperator m = delegate_method.MemberDefinition as MethodOrOperator;
				if (m != null && m.IsPartialDefinition) {
					ec.Report.Error (762, loc, "Cannot create delegate from partial method declaration `{0}'",
						delegate_method.GetSignatureForError ());
				} else {
					ec.Report.Error (1618, loc, "Cannot create delegate with `{0}' because it has a Conditional attribute",
						TypeManager.CSharpSignature (delegate_method));
				}
			}

			var expr = method_group.InstanceExpression;
			if (expr != null && (expr.Type.IsGenericParameter || !TypeSpec.IsReferenceType (expr.Type)))
				method_group.InstanceExpression = new BoxedCast (expr, ec.BuiltinTypes.Object);

			eclass = ExprClass.Value;
			return this;
		}
Beispiel #46
0
 protected virtual MemberList GetMembers(int line, int col, TypeExpression tExpr, Scope scope) {
   if (tExpr == null) return null;
   MemberList members;
   QualifiedIdentifier qual = tExpr.Expression as QualifiedIdentifier;
   if (qual != null)
     members = this.GetMembers(line, col, qual, scope);
   else
     members = this.languageService.GetTypesNamespacesAndPrefixes(scope, true, false);
   if (members == null) return null;
   return this.GetTypesAndNamespacesThatContainThem(members);
 }
Beispiel #47
0
 /// <summary>
 /// Allocates an exception that can be thrown by the associated method, along with a possibly empty list of postconditions that are true when that happens.
 /// </summary>
 /// <param name="exceptionType">The exception that can be thrown by the associated method.</param>
 /// <param name="postcondition">The postcondition that holds if the associated method throws this exception.</param>
 /// <param name="sourceLocation">The source location corresponding to the newly allocated source item.</param>
 public ThrownException(TypeExpression exceptionType, Postcondition postcondition, ISourceLocation sourceLocation)
     : base(sourceLocation)
 {
     this.exceptionType = exceptionType;
       this.postcondition = postcondition;
 }
Beispiel #48
0
		public virtual object Visit (TypeExpression typeExpression)
		{
			return null;
		}
Beispiel #49
0
  /** the generated parser.
      Maintains a state and a value stack, currently with fixed maximum size.
      @param yyLex scanner.
      @return result of the last reduction, if any.
      @throws yyException on irrecoverable parse error.
    */
  internal Object yyparse (yyParser.yyInput yyLex)
  {
    if (yyMax <= 0) yyMax = 256;		// initial size
    int yyState = 0;                   // state stack ptr
    int [] yyStates;               	// state stack 
    yyVal = null;
    yyToken = -1;
    int yyErrorFlag = 0;				// #tks to shift
	if (use_global_stacks && global_yyStates != null) {
		yyVals = global_yyVals;
		yyStates = global_yyStates;
   } else {
		yyVals = new object [yyMax];
		yyStates = new int [yyMax];
		if (use_global_stacks) {
			global_yyVals = yyVals;
			global_yyStates = yyStates;
		}
	}

    /*yyLoop:*/ for (yyTop = 0;; ++ yyTop) {
      if (yyTop >= yyStates.Length) {			// dynamically increase
        global::System.Array.Resize (ref yyStates, yyStates.Length+yyMax);
        global::System.Array.Resize (ref yyVals, yyVals.Length+yyMax);
      }
      yyStates[yyTop] = yyState;
      yyVals[yyTop] = yyVal;
//t      if (debug != null) debug.push(yyState, yyVal);

      /*yyDiscarded:*/ while (true) {	// discarding a token does not change stack
        int yyN;
        if ((yyN = yyDefRed[yyState]) == 0) {	// else [default] reduce (yyN)
          if (yyToken < 0) {
            yyToken = yyLex.advance() ? yyLex.token() : 0;
//t            if (debug != null)
//t              debug.lex(yyState, yyToken, yyname(yyToken), yyLex.value());
          }
          if ((yyN = yySindex[yyState]) != 0 && ((yyN += yyToken) >= 0)
              && (yyN < yyTable.Length) && (yyCheck[yyN] == yyToken)) {
//t            if (debug != null)
//t              debug.shift(yyState, yyTable[yyN], yyErrorFlag-1);
            yyState = yyTable[yyN];		// shift to yyN
            yyVal = yyLex.value();
            yyToken = -1;
            if (yyErrorFlag > 0) -- yyErrorFlag;
            goto continue_yyLoop;
          }
          if ((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0
              && yyN < yyTable.Length && yyCheck[yyN] == yyToken)
            yyN = yyTable[yyN];			// reduce (yyN)
          else
            switch (yyErrorFlag) {
  
            case 0:
              yyExpectingState = yyState;
              // yyerror(String.Format ("syntax error, got token `{0}'", yyname (yyToken)), yyExpecting(yyState));
//t              if (debug != null) debug.error("syntax error");
              if (yyToken == 0 /*eof*/ || yyToken == eof_token) throw new yyParser.yyUnexpectedEof ();
              goto case 1;
            case 1: case 2:
              yyErrorFlag = 3;
              do {
                if ((yyN = yySindex[yyStates[yyTop]]) != 0
                    && (yyN += Token.yyErrorCode) >= 0 && yyN < yyTable.Length
                    && yyCheck[yyN] == Token.yyErrorCode) {
//t                  if (debug != null)
//t                    debug.shift(yyStates[yyTop], yyTable[yyN], 3);
                  yyState = yyTable[yyN];
                  yyVal = yyLex.value();
                  goto continue_yyLoop;
                }
//t                if (debug != null) debug.pop(yyStates[yyTop]);
              } while (-- yyTop >= 0);
//t              if (debug != null) debug.reject();
              throw new yyParser.yyException("irrecoverable syntax error");
  
            case 3:
              if (yyToken == 0) {
//t                if (debug != null) debug.reject();
                throw new yyParser.yyException("irrecoverable syntax error at end-of-file");
              }
//t              if (debug != null)
//t                debug.discard(yyState, yyToken, yyname(yyToken),
//t  							yyLex.value());
              yyToken = -1;
              goto continue_yyDiscarded;		// leave stack alone
            }
        }
        int yyV = yyTop + 1-yyLen[yyN];
//t        if (debug != null)
//t          debug.reduce(yyState, yyStates[yyV-1], yyN, YYRules.getRule (yyN), yyLen[yyN]);
        yyVal = yyV > yyTop ? null : yyVals[yyV]; // yyVal = yyDefault(yyV > yyTop ? null : yyVals[yyV]);
        switch (yyN) {
case 1:
#line 392 "cs-parser.jay"
  {
		Lexer.check_incorrect_doc_comment ();
	  }
  break;
case 2:
#line 393 "cs-parser.jay"
  { Lexer.CompleteOnEOF = false; }
  break;
case 6:
  case_6();
  break;
case 7:
#line 412 "cs-parser.jay"
  {
		module.AddAttributes ((Attributes) yyVals[0+yyTop], current_namespace);
	  }
  break;
case 8:
  case_8();
  break;
case 13:
  case_13();
  break;
case 14:
#line 457 "cs-parser.jay"
  {
		Error_SyntaxError (yyToken);
	  }
  break;
case 17:
  case_17();
  break;
case 18:
  case_18();
  break;
case 19:
  case_19();
  break;
case 20:
  case_20();
  break;
case 23:
  case_23();
  break;
case 24:
  case_24();
  break;
case 25:
  case_25();
  break;
case 26:
  case_26();
  break;
case 29:
  case_29();
  break;
case 30:
  case_30();
  break;
case 31:
  case_31();
  break;
case 32:
  case_32();
  break;
case 45:
  case_45();
  break;
case 46:
#line 660 "cs-parser.jay"
  {
		current_namespace.DeclarationFound = true;
	  }
  break;
case 47:
  case_47();
  break;
case 55:
  case_55();
  break;
case 56:
  case_56();
  break;
case 57:
  case_57();
  break;
case 58:
  case_58();
  break;
case 59:
  case_59();
  break;
case 60:
  case_60();
  break;
case 61:
  case_61();
  break;
case 62:
  case_62();
  break;
case 63:
  case_63();
  break;
case 64:
  case_64();
  break;
case 65:
#line 787 "cs-parser.jay"
  { yyVal = "event"; PushLocation (GetLocation (yyVals[0+yyTop])); }
  break;
case 66:
#line 788 "cs-parser.jay"
  { yyVal = "return"; PushLocation (GetLocation (yyVals[0+yyTop])); }
  break;
case 67:
#line 795 "cs-parser.jay"
  {
		yyVal = new List<Attribute> (4) { (Attribute) yyVals[0+yyTop] };
	  }
  break;
case 68:
  case_68();
  break;
case 69:
#line 812 "cs-parser.jay"
  {
		++lexer.parsing_block;
	  }
  break;
case 70:
  case_70();
  break;
case 72:
#line 840 "cs-parser.jay"
  { yyVal = null; HadAttributeParens = false;  }
  break;
case 73:
  case_73();
  break;
case 74:
#line 852 "cs-parser.jay"
  { yyVal = null; }
  break;
case 75:
  case_75();
  break;
case 76:
  case_76();
  break;
case 77:
  case_77();
  break;
case 78:
  case_78();
  break;
case 79:
#line 896 "cs-parser.jay"
  {
	  	yyVal = new Argument ((Expression) yyVals[0+yyTop]);
	  }
  break;
case 81:
  case_81();
  break;
case 82:
#line 909 "cs-parser.jay"
  {
		++lexer.parsing_block;
	  }
  break;
case 83:
  case_83();
  break;
case 84:
  case_84();
  break;
case 86:
#line 940 "cs-parser.jay"
  { yyVal = null; }
  break;
case 87:
#line 944 "cs-parser.jay"
  { 
		yyVal = Argument.AType.Ref;
	  }
  break;
case 88:
#line 948 "cs-parser.jay"
  { 
		yyVal = Argument.AType.Out;
	  }
  break;
case 91:
  case_91();
  break;
case 92:
  case_92();
  break;
case 106:
  case_106();
  break;
case 107:
  case_107();
  break;
case 108:
  case_108();
  break;
case 109:
#line 1025 "cs-parser.jay"
  {
	  }
  break;
case 110:
  case_110();
  break;
case 111:
  case_111();
  break;
case 112:
  case_112();
  break;
case 113:
  case_113();
  break;
case 114:
  case_114();
  break;
case 115:
#line 1075 "cs-parser.jay"
  {
		Error_SyntaxError (yyToken);
	  }
  break;
case 116:
  case_116();
  break;
case 117:
  case_117();
  break;
case 118:
  case_118();
  break;
case 121:
#line 1124 "cs-parser.jay"
  {
		current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]);
	  }
  break;
case 122:
#line 1128 "cs-parser.jay"
  {
		current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]);
	  }
  break;
case 123:
  case_123();
  break;
case 124:
#line 1144 "cs-parser.jay"
  {
		++lexer.parsing_block;
	  }
  break;
case 125:
  case_125();
  break;
case 126:
  case_126();
  break;
case 129:
  case_129();
  break;
case 130:
  case_130();
  break;
case 131:
  case_131();
  break;
case 132:
  case_132();
  break;
case 133:
#line 1223 "cs-parser.jay"
  {
		report.Error (1641, GetLocation (yyVals[-1+yyTop]), "A fixed size buffer field must have the array size specifier after the field name");
	  }
  break;
case 135:
  case_135();
  break;
case 136:
  case_136();
  break;
case 139:
#line 1253 "cs-parser.jay"
  {
		current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]);
	  }
  break;
case 140:
#line 1257 "cs-parser.jay"
  {
		current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]);
	  }
  break;
case 141:
  case_141();
  break;
case 142:
#line 1270 "cs-parser.jay"
  {
		++lexer.parsing_block;
	  }
  break;
case 143:
  case_143();
  break;
case 146:
#line 1289 "cs-parser.jay"
  {
		current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]);
	  }
  break;
case 147:
#line 1293 "cs-parser.jay"
  {
		current_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]);
	  }
  break;
case 148:
  case_148();
  break;
case 149:
#line 1309 "cs-parser.jay"
  {
		++lexer.parsing_block;
	  }
  break;
case 150:
  case_150();
  break;
case 151:
  case_151();
  break;
case 154:
  case_154();
  break;
case 155:
  case_155();
  break;
case 156:
  case_156();
  break;
case 157:
#line 1377 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.All;
	  }
  break;
case 158:
  case_158();
  break;
case 159:
  case_159();
  break;
case 160:
#line 1416 "cs-parser.jay"
  {
		lexer.parsing_generic_declaration = true;
	  }
  break;
case 161:
  case_161();
  break;
case 162:
#line 1426 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = true;
	  }
  break;
case 163:
  case_163();
  break;
case 164:
  case_164();
  break;
case 165:
  case_165();
  break;
case 169:
#line 1504 "cs-parser.jay"
  { savedLocation = GetLocation (yyVals[0+yyTop]); yyVal = null; }
  break;
case 170:
  case_170();
  break;
case 171:
  case_171();
  break;
case 172:
#line 1528 "cs-parser.jay"
  { yyVal = ParametersCompiled.EmptyReadOnlyParameters; }
  break;
case 174:
  case_174();
  break;
case 175:
  case_175();
  break;
case 176:
  case_176();
  break;
case 177:
  case_177();
  break;
case 178:
  case_178();
  break;
case 179:
  case_179();
  break;
case 180:
  case_180();
  break;
case 181:
#line 1600 "cs-parser.jay"
  {
		yyVal = new ParametersCompiled (new Parameter[] { (Parameter) yyVals[0+yyTop] } );
	  }
  break;
case 182:
#line 1604 "cs-parser.jay"
  {
		yyVal = new ParametersCompiled (new Parameter [] { new ArglistParameter (GetLocation (yyVals[0+yyTop])) }, true);
	  }
  break;
case 183:
  case_183();
  break;
case 184:
  case_184();
  break;
case 185:
  case_185();
  break;
case 186:
  case_186();
  break;
case 187:
  case_187();
  break;
case 188:
  case_188();
  break;
case 189:
  case_189();
  break;
case 190:
#line 1685 "cs-parser.jay"
  {
	  	++lexer.parsing_block;
	  }
  break;
case 191:
  case_191();
  break;
case 192:
#line 1726 "cs-parser.jay"
  { yyVal = Parameter.Modifier.NONE; }
  break;
case 194:
#line 1734 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 195:
  case_195();
  break;
case 196:
  case_196();
  break;
case 197:
  case_197();
  break;
case 198:
  case_198();
  break;
case 199:
  case_199();
  break;
case 200:
  case_200();
  break;
case 201:
  case_201();
  break;
case 202:
  case_202();
  break;
case 203:
  case_203();
  break;
case 204:
#line 1828 "cs-parser.jay"
  {
		Error_DuplicateParameterModifier (GetLocation (yyVals[-1+yyTop]), Parameter.Modifier.PARAMS);
	  }
  break;
case 205:
  case_205();
  break;
case 206:
  case_206();
  break;
case 207:
  case_207();
  break;
case 208:
  case_208();
  break;
case 209:
  case_209();
  break;
case 210:
#line 1878 "cs-parser.jay"
  {
		current_property = null;
	  }
  break;
case 211:
  case_211();
  break;
case 212:
  case_212();
  break;
case 214:
  case_214();
  break;
case 215:
  case_215();
  break;
case 218:
#line 1940 "cs-parser.jay"
  {
	  	valid_param_mod = ParameterModifierType.Params | ParameterModifierType.DefaultValue;
	  }
  break;
case 219:
  case_219();
  break;
case 220:
  case_220();
  break;
case 221:
#line 1986 "cs-parser.jay"
  {
		lbag.AppendToMember (current_property, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 222:
  case_222();
  break;
case 227:
  case_227();
  break;
case 228:
  case_228();
  break;
case 229:
  case_229();
  break;
case 230:
  case_230();
  break;
case 231:
  case_231();
  break;
case 233:
  case_233();
  break;
case 234:
  case_234();
  break;
case 235:
#line 2127 "cs-parser.jay"
  {
	  }
  break;
case 236:
  case_236();
  break;
case 237:
  case_237();
  break;
case 238:
  case_238();
  break;
case 239:
  case_239();
  break;
case 240:
#line 2167 "cs-parser.jay"
  {
		Error_SyntaxError (yyToken);	  
	  }
  break;
case 243:
  case_243();
  break;
case 244:
  case_244();
  break;
case 245:
#line 2192 "cs-parser.jay"
  {
		report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants");
	  }
  break;
case 246:
#line 2196 "cs-parser.jay"
  {
		report.Error (525, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain fields or constants");
	  }
  break;
case 251:
#line 2204 "cs-parser.jay"
  {
	  	report.Error (567, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain operators");
	  }
  break;
case 252:
#line 2208 "cs-parser.jay"
  {
	  	report.Error (526, GetLocation (yyVals[0+yyTop]), "Interfaces cannot contain contructors");
	  }
  break;
case 253:
#line 2212 "cs-parser.jay"
  {
	  	report.Error (524, GetLocation (yyVals[0+yyTop]), "Interfaces cannot declare classes, structs, interfaces, delegates, or enumerations");
	  }
  break;
case 254:
#line 2218 "cs-parser.jay"
  {
	  }
  break;
case 255:
  case_255();
  break;
case 257:
  case_257();
  break;
case 258:
  case_258();
  break;
case 259:
  case_259();
  break;
case 261:
#line 2312 "cs-parser.jay"
  { yyVal = Operator.OpType.LogicalNot; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 262:
#line 2313 "cs-parser.jay"
  { yyVal = Operator.OpType.OnesComplement; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 263:
#line 2314 "cs-parser.jay"
  { yyVal = Operator.OpType.Increment; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 264:
#line 2315 "cs-parser.jay"
  { yyVal = Operator.OpType.Decrement; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 265:
#line 2316 "cs-parser.jay"
  { yyVal = Operator.OpType.True; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 266:
#line 2317 "cs-parser.jay"
  { yyVal = Operator.OpType.False; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 267:
#line 2319 "cs-parser.jay"
  { yyVal = Operator.OpType.Addition; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 268:
#line 2320 "cs-parser.jay"
  { yyVal = Operator.OpType.Subtraction; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 269:
#line 2322 "cs-parser.jay"
  { yyVal = Operator.OpType.Multiply; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 270:
#line 2323 "cs-parser.jay"
  {  yyVal = Operator.OpType.Division; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 271:
#line 2324 "cs-parser.jay"
  { yyVal = Operator.OpType.Modulus; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 272:
#line 2325 "cs-parser.jay"
  { yyVal = Operator.OpType.BitwiseAnd; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 273:
#line 2326 "cs-parser.jay"
  { yyVal = Operator.OpType.BitwiseOr; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 274:
#line 2327 "cs-parser.jay"
  { yyVal = Operator.OpType.ExclusiveOr; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 275:
#line 2328 "cs-parser.jay"
  { yyVal = Operator.OpType.LeftShift; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 276:
#line 2329 "cs-parser.jay"
  { yyVal = Operator.OpType.RightShift; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 277:
#line 2330 "cs-parser.jay"
  { yyVal = Operator.OpType.Equality; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 278:
#line 2331 "cs-parser.jay"
  { yyVal = Operator.OpType.Inequality; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 279:
#line 2332 "cs-parser.jay"
  { yyVal = Operator.OpType.GreaterThan; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 280:
#line 2333 "cs-parser.jay"
  { yyVal = Operator.OpType.LessThan; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 281:
#line 2334 "cs-parser.jay"
  { yyVal = Operator.OpType.GreaterThanOrEqual; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 282:
#line 2335 "cs-parser.jay"
  { yyVal = Operator.OpType.LessThanOrEqual; savedOperatorLocation = GetLocation (yyVals[0+yyTop]); }
  break;
case 283:
  case_283();
  break;
case 284:
#line 2349 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.DefaultValue;
	  }
  break;
case 285:
  case_285();
  break;
case 286:
#line 2372 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.DefaultValue;
	  }
  break;
case 287:
  case_287();
  break;
case 288:
  case_288();
  break;
case 289:
  case_289();
  break;
case 290:
  case_290();
  break;
case 291:
  case_291();
  break;
case 292:
  case_292();
  break;
case 293:
  case_293();
  break;
case 295:
#line 2496 "cs-parser.jay"
  { current_block = null; yyVal = null; }
  break;
case 298:
#line 2508 "cs-parser.jay"
  {
		++lexer.parsing_block;
	  }
  break;
case 299:
  case_299();
  break;
case 300:
#line 2518 "cs-parser.jay"
  {
		++lexer.parsing_block;
	  }
  break;
case 301:
  case_301();
  break;
case 302:
  case_302();
  break;
case 303:
  case_303();
  break;
case 304:
  case_304();
  break;
case 305:
  case_305();
  break;
case 306:
  case_306();
  break;
case 307:
  case_307();
  break;
case 308:
  case_308();
  break;
case 309:
  case_309();
  break;
case 310:
  case_310();
  break;
case 311:
  case_311();
  break;
case 313:
#line 2645 "cs-parser.jay"
  {
	  	++lexer.parsing_block;
	  }
  break;
case 314:
  case_314();
  break;
case 317:
#line 2663 "cs-parser.jay"
  {
		current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]);
	  }
  break;
case 318:
#line 2667 "cs-parser.jay"
  {
		current_event_field.AddDeclarator ((FieldDeclarator) yyVals[0+yyTop]);
	  }
  break;
case 319:
  case_319();
  break;
case 320:
#line 2680 "cs-parser.jay"
  {
		++lexer.parsing_block;
	  }
  break;
case 321:
  case_321();
  break;
case 322:
  case_322();
  break;
case 323:
#line 2705 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 326:
  case_326();
  break;
case 327:
  case_327();
  break;
case 328:
  case_328();
  break;
case 329:
  case_329();
  break;
case 330:
  case_330();
  break;
case 331:
  case_331();
  break;
case 332:
  case_332();
  break;
case 333:
  case_333();
  break;
case 335:
  case_335();
  break;
case 336:
  case_336();
  break;
case 337:
  case_337();
  break;
case 338:
  case_338();
  break;
case 339:
  case_339();
  break;
case 340:
  case_340();
  break;
case 342:
  case_342();
  break;
case 343:
  case_343();
  break;
case 346:
#line 2893 "cs-parser.jay"
  {
		lbag.AppendToMember (current_container, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 348:
  case_348();
  break;
case 349:
  case_349();
  break;
case 350:
  case_350();
  break;
case 351:
  case_351();
  break;
case 352:
  case_352();
  break;
case 354:
#line 2967 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out | ParameterModifierType.Params | ParameterModifierType.DefaultValue;
	  }
  break;
case 355:
  case_355();
  break;
case 356:
#line 2986 "cs-parser.jay"
  {
		lexer.ConstraintsParsing = false;
	  }
  break;
case 357:
  case_357();
  break;
case 359:
  case_359();
  break;
case 361:
  case_361();
  break;
case 362:
  case_362();
  break;
case 364:
  case_364();
  break;
case 365:
  case_365();
  break;
case 366:
  case_366();
  break;
case 367:
  case_367();
  break;
case 369:
  case_369();
  break;
case 370:
  case_370();
  break;
case 371:
  case_371();
  break;
case 372:
  case_372();
  break;
case 373:
#line 3111 "cs-parser.jay"
  {
		lexer.parsing_generic_declaration = true;
	  }
  break;
case 374:
  case_374();
  break;
case 375:
  case_375();
  break;
case 377:
  case_377();
  break;
case 378:
  case_378();
  break;
case 379:
  case_379();
  break;
case 380:
  case_380();
  break;
case 381:
  case_381();
  break;
case 382:
  case_382();
  break;
case 384:
  case_384();
  break;
case 385:
  case_385();
  break;
case 386:
  case_386();
  break;
case 387:
  case_387();
  break;
case 388:
  case_388();
  break;
case 390:
#line 3236 "cs-parser.jay"
  {
		yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 391:
#line 3243 "cs-parser.jay"
  {
		lexer.parsing_generic_declaration = true;
	  }
  break;
case 397:
  case_397();
  break;
case 399:
#line 3273 "cs-parser.jay"
  {
		yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]);
	  }
  break;
case 400:
  case_400();
  break;
case 401:
#line 3292 "cs-parser.jay"
  {
		yyVal = new ComposedCast ((ATypeNameExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]);
	  }
  break;
case 403:
  case_403();
  break;
case 404:
  case_404();
  break;
case 405:
#line 3313 "cs-parser.jay"
  {
		yyVal = new ComposedCast ((FullNamedExpression) yyVals[-1+yyTop], (ComposedTypeSpecifier) yyVals[0+yyTop]);
	  }
  break;
case 406:
#line 3317 "cs-parser.jay"
  {
		yyVal = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[-1+yyTop])), (ComposedTypeSpecifier) yyVals[0+yyTop]);
	  }
  break;
case 407:
  case_407();
  break;
case 408:
  case_408();
  break;
case 409:
  case_409();
  break;
case 410:
#line 3351 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.Object, GetLocation (yyVals[0+yyTop])); }
  break;
case 411:
#line 3352 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.String, GetLocation (yyVals[0+yyTop])); }
  break;
case 412:
#line 3353 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.Bool, GetLocation (yyVals[0+yyTop])); }
  break;
case 413:
#line 3354 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.Decimal, GetLocation (yyVals[0+yyTop])); }
  break;
case 414:
#line 3355 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.Float, GetLocation (yyVals[0+yyTop])); }
  break;
case 415:
#line 3356 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.Double, GetLocation (yyVals[0+yyTop])); }
  break;
case 417:
#line 3361 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.SByte, GetLocation (yyVals[0+yyTop])); }
  break;
case 418:
#line 3362 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.Byte, GetLocation (yyVals[0+yyTop])); }
  break;
case 419:
#line 3363 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.Short, GetLocation (yyVals[0+yyTop])); }
  break;
case 420:
#line 3364 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.UShort, GetLocation (yyVals[0+yyTop])); }
  break;
case 421:
#line 3365 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.Int, GetLocation (yyVals[0+yyTop])); }
  break;
case 422:
#line 3366 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.UInt, GetLocation (yyVals[0+yyTop])); }
  break;
case 423:
#line 3367 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.Long, GetLocation (yyVals[0+yyTop])); }
  break;
case 424:
#line 3368 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.ULong, GetLocation (yyVals[0+yyTop])); }
  break;
case 425:
#line 3369 "cs-parser.jay"
  { yyVal = new TypeExpression (compiler.BuiltinTypes.Char, GetLocation (yyVals[0+yyTop])); }
  break;
case 448:
  case_448();
  break;
case 452:
#line 3413 "cs-parser.jay"
  { yyVal = new NullLiteral (GetLocation (yyVals[0+yyTop])); }
  break;
case 453:
#line 3417 "cs-parser.jay"
  { yyVal = new BoolLiteral (compiler.BuiltinTypes, true, GetLocation (yyVals[0+yyTop])); }
  break;
case 454:
#line 3418 "cs-parser.jay"
  { yyVal = new BoolLiteral (compiler.BuiltinTypes, false, GetLocation (yyVals[0+yyTop])); }
  break;
case 455:
#line 3425 "cs-parser.jay"
  {
		yyVal = new InterpolatedString ((StringLiteral) yyVals[-2+yyTop], (List<Expression>) yyVals[-1+yyTop], (StringLiteral) yyVals[0+yyTop]);
	  }
  break;
case 456:
#line 3429 "cs-parser.jay"
  {
		yyVal = new InterpolatedString ((StringLiteral) yyVals[0+yyTop], null, null);
	  }
  break;
case 457:
  case_457();
  break;
case 458:
  case_458();
  break;
case 459:
#line 3452 "cs-parser.jay"
  {
		yyVal = new InterpolatedStringInsert ((Expression) yyVals[0+yyTop]);
	  }
  break;
case 460:
  case_460();
  break;
case 461:
#line 3462 "cs-parser.jay"
  {
		lexer.parsing_interpolation_format = true;
	  }
  break;
case 462:
  case_462();
  break;
case 463:
#line 3474 "cs-parser.jay"
  {
		lexer.parsing_interpolation_format = true;
	  }
  break;
case 464:
  case_464();
  break;
case 469:
  case_469();
  break;
case 470:
#line 3516 "cs-parser.jay"
  {
		yyVal = new ParenthesizedExpression ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 471:
  case_471();
  break;
case 472:
  case_472();
  break;
case 473:
  case_473();
  break;
case 474:
  case_474();
  break;
case 475:
  case_475();
  break;
case 476:
  case_476();
  break;
case 477:
  case_477();
  break;
case 478:
  case_478();
  break;
case 479:
#line 3577 "cs-parser.jay"
  {
		yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null,GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 480:
  case_480();
  break;
case 481:
#line 3585 "cs-parser.jay"
  {
		yyVal = new CompletionMemberAccess ((Expression) yyVals[-2+yyTop], null, lexer.Location);
	  }
  break;
case 482:
  case_482();
  break;
case 483:
  case_483();
  break;
case 484:
  case_484();
  break;
case 485:
  case_485();
  break;
case 486:
#line 3615 "cs-parser.jay"
  { yyVal = null; }
  break;
case 488:
  case_488();
  break;
case 489:
  case_489();
  break;
case 490:
#line 3637 "cs-parser.jay"
  { yyVal = null; }
  break;
case 491:
#line 3641 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	}
  break;
case 492:
  case_492();
  break;
case 493:
  case_493();
  break;
case 494:
  case_494();
  break;
case 495:
  case_495();
  break;
case 496:
  case_496();
  break;
case 497:
#line 3680 "cs-parser.jay"
  {
		yyVal = new CompletionElementInitializer (null, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 498:
  case_498();
  break;
case 499:
  case_499();
  break;
case 500:
  case_500();
  break;
case 501:
  case_501();
  break;
case 504:
#line 3720 "cs-parser.jay"
  { yyVal = null; }
  break;
case 506:
  case_506();
  break;
case 507:
  case_507();
  break;
case 508:
  case_508();
  break;
case 509:
  case_509();
  break;
case 510:
  case_510();
  break;
case 511:
#line 3774 "cs-parser.jay"
  {
		yyVal = new Argument ((Expression) yyVals[0+yyTop]);
	  }
  break;
case 515:
  case_515();
  break;
case 516:
#line 3792 "cs-parser.jay"
  {
		yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Ref);
	  }
  break;
case 517:
  case_517();
  break;
case 518:
#line 3801 "cs-parser.jay"
  {
		yyVal = new Argument ((Expression) yyVals[0+yyTop], Argument.AType.Out);
	  }
  break;
case 519:
  case_519();
  break;
case 520:
  case_520();
  break;
case 521:
  case_521();
  break;
case 522:
  case_522();
  break;
case 523:
  case_523();
  break;
case 525:
  case_525();
  break;
case 526:
  case_526();
  break;
case 527:
  case_527();
  break;
case 528:
  case_528();
  break;
case 529:
  case_529();
  break;
case 530:
  case_530();
  break;
case 531:
  case_531();
  break;
case 532:
  case_532();
  break;
case 533:
#line 3928 "cs-parser.jay"
  {
	  	yyVal = new Argument ((Expression) yyVals[0+yyTop]);
	  }
  break;
case 535:
#line 3936 "cs-parser.jay"
  {
		yyVal = new This (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 536:
  case_536();
  break;
case 537:
  case_537();
  break;
case 538:
#line 3956 "cs-parser.jay"
  {
		yyVal = new UnaryMutator (UnaryMutator.Mode.PostIncrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 539:
#line 3963 "cs-parser.jay"
  {
		yyVal = new UnaryMutator (UnaryMutator.Mode.PostDecrement, (Expression) yyVals[-1+yyTop], GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 540:
  case_540();
  break;
case 541:
  case_541();
  break;
case 542:
  case_542();
  break;
case 543:
  case_543();
  break;
case 544:
  case_544();
  break;
case 545:
  case_545();
  break;
case 546:
  case_546();
  break;
case 547:
#line 4030 "cs-parser.jay"
  {
		++lexer.parsing_type;
	  }
  break;
case 548:
  case_548();
  break;
case 549:
  case_549();
  break;
case 550:
#line 4052 "cs-parser.jay"
  {
		yyVal = new EmptyCompletion ();
	  }
  break;
case 553:
#line 4061 "cs-parser.jay"
  { yyVal = null; }
  break;
case 555:
  case_555();
  break;
case 556:
  case_556();
  break;
case 557:
#line 4083 "cs-parser.jay"
  {
		yyVal = new EmptyCompletion ();
	  }
  break;
case 558:
#line 4087 "cs-parser.jay"
  {
	  	yyVal = yyVals[-1+yyTop];
	  }
  break;
case 559:
  case_559();
  break;
case 560:
  case_560();
  break;
case 561:
  case_561();
  break;
case 562:
  case_562();
  break;
case 566:
  case_566();
  break;
case 567:
  case_567();
  break;
case 568:
  case_568();
  break;
case 569:
#line 4147 "cs-parser.jay"
  {
		yyVal = 2;
	  }
  break;
case 570:
#line 4151 "cs-parser.jay"
  {
		yyVal = ((int) yyVals[-1+yyTop]) + 1;
	  }
  break;
case 571:
#line 4158 "cs-parser.jay"
  {
		yyVal = null;
	  }
  break;
case 572:
#line 4162 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 573:
  case_573();
  break;
case 574:
  case_574();
  break;
case 575:
  case_575();
  break;
case 576:
  case_576();
  break;
case 577:
  case_577();
  break;
case 579:
  case_579();
  break;
case 580:
  case_580();
  break;
case 581:
  case_581();
  break;
case 582:
  case_582();
  break;
case 583:
  case_583();
  break;
case 584:
  case_584();
  break;
case 585:
  case_585();
  break;
case 586:
  case_586();
  break;
case 587:
  case_587();
  break;
case 588:
  case_588();
  break;
case 589:
#line 4295 "cs-parser.jay"
  {
		start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], false, GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 590:
  case_590();
  break;
case 591:
#line 4308 "cs-parser.jay"
  {
		start_anonymous (false, (ParametersCompiled) yyVals[0+yyTop], true, GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 592:
  case_592();
  break;
case 593:
#line 4325 "cs-parser.jay"
  {
		yyVal = ParametersCompiled.Undefined;
	  }
  break;
case 595:
#line 4333 "cs-parser.jay"
  {
	  	valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;
	  }
  break;
case 596:
  case_596();
  break;
case 597:
  case_597();
  break;
case 599:
#line 4359 "cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.LogicalNot, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 600:
#line 4363 "cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.OnesComplement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 601:
  case_601();
  break;
case 602:
  case_602();
  break;
case 603:
  case_603();
  break;
case 604:
  case_604();
  break;
case 605:
  case_605();
  break;
case 606:
  case_606();
  break;
case 608:
#line 4427 "cs-parser.jay"
  { 
	  	yyVal = new Unary (Unary.Operator.UnaryPlus, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 609:
#line 4431 "cs-parser.jay"
  { 
		yyVal = new Unary (Unary.Operator.UnaryNegation, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 610:
#line 4435 "cs-parser.jay"
  {
		yyVal = new UnaryMutator (UnaryMutator.Mode.PreIncrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 611:
#line 4439 "cs-parser.jay"
  {
		yyVal = new UnaryMutator (UnaryMutator.Mode.PreDecrement, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 612:
#line 4443 "cs-parser.jay"
  {
		yyVal = new Indirection ((Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 613:
#line 4447 "cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.AddressOf, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 614:
  case_614();
  break;
case 615:
  case_615();
  break;
case 616:
  case_616();
  break;
case 617:
  case_617();
  break;
case 618:
  case_618();
  break;
case 619:
  case_619();
  break;
case 621:
  case_621();
  break;
case 622:
  case_622();
  break;
case 623:
  case_623();
  break;
case 624:
  case_624();
  break;
case 625:
  case_625();
  break;
case 626:
  case_626();
  break;
case 628:
  case_628();
  break;
case 629:
  case_629();
  break;
case 630:
  case_630();
  break;
case 631:
  case_631();
  break;
case 632:
#line 4555 "cs-parser.jay"
  {
		yyVal = new As ((Expression) yyVals[-2+yyTop], (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 633:
  case_633();
  break;
case 634:
  case_634();
  break;
case 635:
  case_635();
  break;
case 636:
  case_636();
  break;
case 637:
  case_637();
  break;
case 638:
  case_638();
  break;
case 641:
#line 4611 "cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.UnaryPlus, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 642:
#line 4615 "cs-parser.jay"
  {
		yyVal = new Unary (Unary.Operator.UnaryNegation, (Expression) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 645:
  case_645();
  break;
case 646:
#line 4626 "cs-parser.jay"
  {
		yyVal = new WildcardPattern (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 649:
#line 4635 "cs-parser.jay"
  {
		yyVal = new RecursivePattern ((ATypeNameExpression) yyVals[-3+yyTop], (Arguments) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 650:
#line 4642 "cs-parser.jay"
  {
		yyVal = new PropertyPattern ((ATypeNameExpression) yyVals[-3+yyTop], (List<PropertyPatternMember>) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 651:
  case_651();
  break;
case 652:
  case_652();
  break;
case 653:
  case_653();
  break;
case 655:
  case_655();
  break;
case 656:
#line 4684 "cs-parser.jay"
  {
		yyVal = new Arguments (0);
	  }
  break;
case 658:
  case_658();
  break;
case 659:
  case_659();
  break;
case 660:
#line 4710 "cs-parser.jay"
  {
		yyVal = new Argument ((Expression) yyVals[0+yyTop]);
	  }
  break;
case 661:
  case_661();
  break;
case 663:
  case_663();
  break;
case 664:
  case_664();
  break;
case 665:
  case_665();
  break;
case 666:
  case_666();
  break;
case 668:
  case_668();
  break;
case 669:
  case_669();
  break;
case 670:
  case_670();
  break;
case 671:
  case_671();
  break;
case 672:
  case_672();
  break;
case 673:
  case_673();
  break;
case 674:
  case_674();
  break;
case 675:
  case_675();
  break;
case 677:
  case_677();
  break;
case 678:
  case_678();
  break;
case 679:
  case_679();
  break;
case 680:
  case_680();
  break;
case 682:
  case_682();
  break;
case 683:
  case_683();
  break;
case 685:
  case_685();
  break;
case 686:
  case_686();
  break;
case 688:
  case_688();
  break;
case 689:
  case_689();
  break;
case 691:
  case_691();
  break;
case 692:
  case_692();
  break;
case 694:
  case_694();
  break;
case 695:
  case_695();
  break;
case 697:
  case_697();
  break;
case 699:
  case_699();
  break;
case 700:
  case_700();
  break;
case 701:
  case_701();
  break;
case 702:
  case_702();
  break;
case 703:
  case_703();
  break;
case 704:
  case_704();
  break;
case 705:
  case_705();
  break;
case 706:
  case_706();
  break;
case 707:
  case_707();
  break;
case 708:
  case_708();
  break;
case 709:
  case_709();
  break;
case 710:
  case_710();
  break;
case 711:
  case_711();
  break;
case 712:
  case_712();
  break;
case 713:
  case_713();
  break;
case 714:
  case_714();
  break;
case 715:
  case_715();
  break;
case 716:
  case_716();
  break;
case 717:
  case_717();
  break;
case 718:
  case_718();
  break;
case 719:
  case_719();
  break;
case 720:
#line 5055 "cs-parser.jay"
  { yyVal = ParametersCompiled.EmptyReadOnlyParameters; }
  break;
case 721:
  case_721();
  break;
case 722:
#line 5066 "cs-parser.jay"
  {
		start_block (Location.Null);
	  }
  break;
case 723:
  case_723();
  break;
case 725:
  case_725();
  break;
case 727:
  case_727();
  break;
case 728:
  case_728();
  break;
case 729:
  case_729();
  break;
case 730:
  case_730();
  break;
case 731:
  case_731();
  break;
case 732:
  case_732();
  break;
case 733:
  case_733();
  break;
case 734:
#line 5133 "cs-parser.jay"
  {
	  	valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;
	  }
  break;
case 735:
  case_735();
  break;
case 736:
  case_736();
  break;
case 737:
#line 5147 "cs-parser.jay"
  {
	  	valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;	  
	  }
  break;
case 738:
  case_738();
  break;
case 739:
  case_739();
  break;
case 745:
#line 5172 "cs-parser.jay"
  {
		yyVal = new ArglistAccess (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 746:
  case_746();
  break;
case 747:
  case_747();
  break;
case 748:
  case_748();
  break;
case 750:
#line 5201 "cs-parser.jay"
  {
		yyVal = new BooleanExpression ((Expression) yyVals[0+yyTop]);
	  }
  break;
case 751:
#line 5208 "cs-parser.jay"
  {
	  	yyVal = null;
	  }
  break;
case 753:
  case_753();
  break;
case 754:
#line 5229 "cs-parser.jay"
  {
	  	yyVal = null;
	  }
  break;
case 755:
#line 5233 "cs-parser.jay"
  {
		yyVal = null;
	  }
  break;
case 756:
#line 5237 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 757:
#line 5241 "cs-parser.jay"
  {
		yyVal = yyVals[-1+yyTop];
	  }
  break;
case 758:
  case_758();
  break;
case 759:
  case_759();
  break;
case 760:
#line 5266 "cs-parser.jay"
  {
	  }
  break;
case 761:
  case_761();
  break;
case 762:
  case_762();
  break;
case 763:
  case_763();
  break;
case 764:
  case_764();
  break;
case 765:
#line 5318 "cs-parser.jay"
  { yyVal = null; }
  break;
case 766:
#line 5320 "cs-parser.jay"
  { yyVal = yyVals[0+yyTop]; StoreModifierLocation (Modifiers.PARTIAL, GetLocation (yyVals[0+yyTop])); }
  break;
case 767:
  case_767();
  break;
case 768:
#line 5333 "cs-parser.jay"
  {
		lexer.parsing_modifiers = false;		
	  }
  break;
case 770:
  case_770();
  break;
case 771:
  case_771();
  break;
case 772:
  case_772();
  break;
case 773:
  case_773();
  break;
case 774:
  case_774();
  break;
case 775:
  case_775();
  break;
case 776:
  case_776();
  break;
case 777:
  case_777();
  break;
case 778:
  case_778();
  break;
case 779:
  case_779();
  break;
case 780:
  case_780();
  break;
case 781:
  case_781();
  break;
case 782:
  case_782();
  break;
case 783:
  case_783();
  break;
case 784:
  case_784();
  break;
case 785:
  case_785();
  break;
case 788:
  case_788();
  break;
case 789:
  case_789();
  break;
case 791:
#line 5463 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 792:
  case_792();
  break;
case 793:
  case_793();
  break;
case 794:
  case_794();
  break;
case 795:
  case_795();
  break;
case 796:
  case_796();
  break;
case 797:
  case_797();
  break;
case 798:
  case_798();
  break;
case 799:
  case_799();
  break;
case 800:
#line 5556 "cs-parser.jay"
  {
		yyVal = new SpecialContraintExpr (SpecialConstraint.Class, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 801:
#line 5560 "cs-parser.jay"
  {
		yyVal = new SpecialContraintExpr (SpecialConstraint.Struct, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 802:
#line 5567 "cs-parser.jay"
  {
		yyVal = null;
	  }
  break;
case 803:
  case_803();
  break;
case 804:
  case_804();
  break;
case 805:
  case_805();
  break;
case 806:
  case_806();
  break;
case 807:
#line 5612 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 808:
  case_808();
  break;
case 809:
  case_809();
  break;
case 810:
  case_810();
  break;
case 811:
  case_811();
  break;
case 812:
  case_812();
  break;
case 813:
  case_813();
  break;
case 814:
  case_814();
  break;
case 819:
#line 5674 "cs-parser.jay"
  {
		current_block.AddStatement ((Statement) yyVals[0+yyTop]);
	  }
  break;
case 820:
#line 5678 "cs-parser.jay"
  {
		current_block.AddStatement ((Statement) yyVals[0+yyTop]);
	  }
  break;
case 822:
  case_822();
  break;
case 823:
  case_823();
  break;
case 826:
#line 5712 "cs-parser.jay"
  {
		current_block.AddStatement ((Statement) yyVals[0+yyTop]);
	  }
  break;
case 827:
#line 5716 "cs-parser.jay"
  {
		current_block.AddStatement ((Statement) yyVals[0+yyTop]);
	  }
  break;
case 856:
  case_856();
  break;
case 857:
  case_857();
  break;
case 858:
  case_858();
  break;
case 859:
  case_859();
  break;
case 860:
  case_860();
  break;
case 863:
  case_863();
  break;
case 864:
  case_864();
  break;
case 865:
  case_865();
  break;
case 869:
  case_869();
  break;
case 870:
#line 5857 "cs-parser.jay"
  {
		yyVal = ComposedTypeSpecifier.CreatePointer (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 872:
#line 5865 "cs-parser.jay"
  {
	  	yyVal = Error_AwaitAsIdentifier (yyVals[0+yyTop]);
	  }
  break;
case 873:
  case_873();
  break;
case 874:
  case_874();
  break;
case 875:
  case_875();
  break;
case 876:
  case_876();
  break;
case 878:
  case_878();
  break;
case 880:
  case_880();
  break;
case 881:
  case_881();
  break;
case 885:
  case_885();
  break;
case 888:
  case_888();
  break;
case 889:
  case_889();
  break;
case 890:
#line 5979 "cs-parser.jay"
  {
		report.Error (145, lexer.Location, "A const field requires a value to be provided");
	  }
  break;
case 891:
  case_891();
  break;
case 896:
  case_896();
  break;
case 898:
  case_898();
  break;
case 899:
  case_899();
  break;
case 900:
  case_900();
  break;
case 901:
#line 6029 "cs-parser.jay"
  { yyVal = yyVals[-1+yyTop]; }
  break;
case 902:
  case_902();
  break;
case 903:
#line 6039 "cs-parser.jay"
  { yyVal = yyVals[-1+yyTop]; }
  break;
case 904:
#line 6040 "cs-parser.jay"
  { yyVal = yyVals[-1+yyTop]; }
  break;
case 905:
  case_905();
  break;
case 906:
  case_906();
  break;
case 907:
  case_907();
  break;
case 910:
  case_910();
  break;
case 911:
  case_911();
  break;
case 912:
  case_912();
  break;
case 913:
#line 6112 "cs-parser.jay"
  {
		start_block (GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 914:
  case_914();
  break;
case 915:
  case_915();
  break;
case 916:
#line 6132 "cs-parser.jay"
  {
		report.Warning (1522, 1, current_block.StartLocation, "Empty switch block"); 
	  }
  break;
case 920:
#line 6142 "cs-parser.jay"
  {
		Error_SyntaxError (yyToken);
	  }
  break;
case 922:
  case_922();
  break;
case 923:
#line 6159 "cs-parser.jay"
  {
		current_block.AddStatement ((Statement) yyVals[0+yyTop]);
	  }
  break;
case 924:
  case_924();
  break;
case 925:
  case_925();
  break;
case 926:
#line 6188 "cs-parser.jay"
  {
		yyVal = new SwitchLabel (null, GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 931:
  case_931();
  break;
case 932:
  case_932();
  break;
case 933:
  case_933();
  break;
case 934:
  case_934();
  break;
case 935:
  case_935();
  break;
case 936:
  case_936();
  break;
case 937:
#line 6249 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 938:
  case_938();
  break;
case 939:
#line 6264 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 940:
  case_940();
  break;
case 941:
  case_941();
  break;
case 942:
#line 6285 "cs-parser.jay"
  {
		yyVal = yyVals[0+yyTop];
	  }
  break;
case 943:
  case_943();
  break;
case 944:
  case_944();
  break;
case 945:
  case_945();
  break;
case 946:
#line 6319 "cs-parser.jay"
  { yyVal = new EmptyStatement (lexer.Location); }
  break;
case 948:
  case_948();
  break;
case 949:
  case_949();
  break;
case 951:
#line 6343 "cs-parser.jay"
  { yyVal = null; }
  break;
case 953:
#line 6348 "cs-parser.jay"
  { yyVal = new EmptyStatement (lexer.Location); }
  break;
case 957:
  case_957();
  break;
case 958:
  case_958();
  break;
case 959:
  case_959();
  break;
case 960:
  case_960();
  break;
case 961:
  case_961();
  break;
case 962:
  case_962();
  break;
case 963:
  case_963();
  break;
case 970:
  case_970();
  break;
case 971:
  case_971();
  break;
case 972:
  case_972();
  break;
case 973:
  case_973();
  break;
case 974:
  case_974();
  break;
case 975:
  case_975();
  break;
case 976:
  case_976();
  break;
case 977:
  case_977();
  break;
case 978:
  case_978();
  break;
case 979:
  case_979();
  break;
case 980:
  case_980();
  break;
case 981:
  case_981();
  break;
case 982:
  case_982();
  break;
case 983:
  case_983();
  break;
case 984:
  case_984();
  break;
case 987:
#line 6594 "cs-parser.jay"
  {
		yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List<Catch>) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false);
	  }
  break;
case 988:
  case_988();
  break;
case 989:
  case_989();
  break;
case 990:
  case_990();
  break;
case 991:
  case_991();
  break;
case 992:
  case_992();
  break;
case 995:
  case_995();
  break;
case 996:
  case_996();
  break;
case 997:
  case_997();
  break;
case 998:
  case_998();
  break;
case 999:
#line 6685 "cs-parser.jay"
  {
		yyVal = yyVals[-1+yyTop];
	  }
  break;
case 1000:
  case_1000();
  break;
case 1001:
#line 6697 "cs-parser.jay"
  {
		lexer.parsing_catch_when = false;
	  }
  break;
case 1002:
#line 6701 "cs-parser.jay"
  {
		lexer.parsing_catch_when = false;
	  }
  break;
case 1003:
  case_1003();
  break;
case 1004:
#line 6716 "cs-parser.jay"
  {
		yyVal = new Checked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 1005:
#line 6723 "cs-parser.jay"
  {
		yyVal = new Unchecked ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 1006:
  case_1006();
  break;
case 1007:
#line 6733 "cs-parser.jay"
  {
		yyVal = new Unsafe ((Block) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));
	  }
  break;
case 1008:
  case_1008();
  break;
case 1009:
  case_1009();
  break;
case 1010:
  case_1010();
  break;
case 1011:
  case_1011();
  break;
case 1012:
  case_1012();
  break;
case 1013:
  case_1013();
  break;
case 1014:
  case_1014();
  break;
case 1015:
  case_1015();
  break;
case 1016:
  case_1016();
  break;
case 1017:
  case_1017();
  break;
case 1019:
  case_1019();
  break;
case 1020:
#line 6838 "cs-parser.jay"
  {
		Error_MissingInitializer (lexer.Location);
	  }
  break;
case 1021:
  case_1021();
  break;
case 1022:
  case_1022();
  break;
case 1023:
  case_1023();
  break;
case 1024:
  case_1024();
  break;
case 1025:
  case_1025();
  break;
case 1026:
  case_1026();
  break;
case 1027:
  case_1027();
  break;
case 1028:
  case_1028();
  break;
case 1029:
  case_1029();
  break;
case 1030:
#line 6943 "cs-parser.jay"
  {
		current_block = new Linq.QueryBlock (current_block, lexer.Location);
	  }
  break;
case 1031:
  case_1031();
  break;
case 1032:
#line 6958 "cs-parser.jay"
  {
		current_block = new Linq.QueryBlock (current_block, lexer.Location);
	  }
  break;
case 1033:
  case_1033();
  break;
case 1034:
  case_1034();
  break;
case 1035:
  case_1035();
  break;
case 1037:
  case_1037();
  break;
case 1038:
  case_1038();
  break;
case 1039:
#line 7022 "cs-parser.jay"
  {
	  	current_block = new Linq.QueryBlock (current_block, lexer.Location);
	  }
  break;
case 1040:
  case_1040();
  break;
case 1041:
  case_1041();
  break;
case 1042:
  case_1042();
  break;
case 1043:
  case_1043();
  break;
case 1044:
#line 7061 "cs-parser.jay"
  {
	  	yyVal = new object[] { yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]) };
	  }
  break;
case 1045:
  case_1045();
  break;
case 1047:
  case_1047();
  break;
case 1053:
#line 7090 "cs-parser.jay"
  {
	  	current_block = new Linq.QueryBlock (current_block, lexer.Location);
	  }
  break;
case 1054:
  case_1054();
  break;
case 1055:
#line 7109 "cs-parser.jay"
  {
	  	current_block = new Linq.QueryBlock (current_block, lexer.Location);
	  }
  break;
case 1056:
  case_1056();
  break;
case 1057:
  case_1057();
  break;
case 1058:
  case_1058();
  break;
case 1059:
  case_1059();
  break;
case 1060:
  case_1060();
  break;
case 1061:
  case_1061();
  break;
case 1062:
  case_1062();
  break;
case 1063:
  case_1063();
  break;
case 1064:
  case_1064();
  break;
case 1066:
  case_1066();
  break;
case 1067:
  case_1067();
  break;
case 1068:
  case_1068();
  break;
case 1070:
  case_1070();
  break;
case 1071:
  case_1071();
  break;
case 1073:
  case_1073();
  break;
case 1074:
  case_1074();
  break;
case 1075:
#line 7310 "cs-parser.jay"
  {
		yyVal = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]);	
	  }
  break;
case 1076:
  case_1076();
  break;
case 1077:
  case_1077();
  break;
case 1078:
#line 7327 "cs-parser.jay"
  {
		yyVal = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)yyVals[0+yyTop]);	
	  }
  break;
case 1079:
  case_1079();
  break;
case 1080:
  case_1080();
  break;
case 1082:
  case_1082();
  break;
case 1083:
  case_1083();
  break;
case 1086:
  case_1086();
  break;
case 1087:
  case_1087();
  break;
case 1095:
#line 7452 "cs-parser.jay"
  {
		module.DocumentationBuilder.ParsedName = (MemberName) yyVals[0+yyTop];
	  }
  break;
case 1096:
#line 7459 "cs-parser.jay"
  {
		module.DocumentationBuilder.ParsedParameters = (List<DocumentationParameter>)yyVals[0+yyTop];
	  }
  break;
case 1097:
  case_1097();
  break;
case 1098:
  case_1098();
  break;
case 1099:
  case_1099();
  break;
case 1100:
#line 7482 "cs-parser.jay"
  {
		yyVal = new MemberName ((MemberName) yyVals[-2+yyTop], MemberCache.IndexerNameAlias, Location.Null);
	  }
  break;
case 1101:
#line 7486 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;
	  }
  break;
case 1102:
  case_1102();
  break;
case 1103:
  case_1103();
  break;
case 1104:
  case_1104();
  break;
case 1105:
  case_1105();
  break;
case 1107:
#line 7522 "cs-parser.jay"
  {
		yyVal = new MemberName (((MemberName) yyVals[-2+yyTop]), (MemberName) yyVals[0+yyTop]);
	  }
  break;
case 1109:
#line 7530 "cs-parser.jay"
  {
		valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;
	  }
  break;
case 1110:
#line 7534 "cs-parser.jay"
  {
		yyVal = yyVals[-1+yyTop];
	  }
  break;
case 1111:
#line 7541 "cs-parser.jay"
  {
		yyVal = new List<DocumentationParameter> (0);
	  }
  break;
case 1113:
  case_1113();
  break;
case 1114:
  case_1114();
  break;
case 1115:
  case_1115();
  break;
#line default
        }
        yyTop -= yyLen[yyN];
        yyState = yyStates[yyTop];
        int yyM = yyLhs[yyN];
        if (yyState == 0 && yyM == 0) {
//t          if (debug != null) debug.shift(0, yyFinal);
          yyState = yyFinal;
          if (yyToken < 0) {
            yyToken = yyLex.advance() ? yyLex.token() : 0;
//t            if (debug != null)
//t               debug.lex(yyState, yyToken,yyname(yyToken), yyLex.value());
          }
          if (yyToken == 0) {
//t            if (debug != null) debug.accept(yyVal);
            return yyVal;
          }
          goto continue_yyLoop;
        }
        if (((yyN = yyGindex[yyM]) != 0) && ((yyN += yyState) >= 0)
            && (yyN < yyTable.Length) && (yyCheck[yyN] == yyState))
          yyState = yyTable[yyN];
        else
          yyState = yyDgoto[yyM];
//t        if (debug != null) debug.shift(yyStates[yyTop], yyState);
	 goto continue_yyLoop;
      continue_yyDiscarded: ;	// implements the named-loop continue: 'continue yyDiscarded'
      }
    continue_yyLoop: ;		// implements the named-loop continue: 'continue yyLoop'
    }
  }
Beispiel #50
0
		FullNamedExpression Lookup (string name, int arity, LookupMode mode, Location loc)
		{
			//
			// Check whether it's in the namespace.
			//
			FullNamedExpression fne = ns.LookupTypeOrNamespace (this, name, arity, mode, loc);

			//
			// Check aliases. 
			//
			if (aliases != null && arity == 0) {
				UsingAliasNamespace uan;
				if (aliases.TryGetValue (name, out uan)) {
					if (fne != null && mode != LookupMode.Probing) {
						// TODO: Namespace has broken location
						//Report.SymbolRelatedToPreviousError (fne.Location, null);
						Compiler.Report.SymbolRelatedToPreviousError (uan.Location, null);
						Compiler.Report.Error (576, loc,
							"Namespace `{0}' contains a definition with same name as alias `{1}'",
							GetSignatureForError (), name);
					}

					return uan.ResolvedExpression;
				}
			}

			if (fne != null)
				return fne;

			//
			// Lookup can be called before the namespace is defined from different namespace using alias clause
			//
			if (namespace_using_table == null) {
				DoDefineNamespace ();
			}

			//
			// Check using entries.
			//
			FullNamedExpression match = null;
			foreach (Namespace using_ns in namespace_using_table) {
				//
				// A using directive imports only types contained in the namespace, it
				// does not import any nested namespaces
				//
				var t = using_ns.LookupType (this, name, arity, mode, loc);
				if (t == null)
					continue;

				fne = new TypeExpression (t, loc);
				if (match == null) {
					match = fne;
					continue;
				}

				// Prefer types over namespaces
				var texpr_fne = fne as TypeExpr;
				var texpr_match = match as TypeExpr;
				if (texpr_fne != null && texpr_match == null) {
					match = fne;
					continue;
				} else if (texpr_fne == null) {
					continue;
				}

				// It can be top level accessibility only
				var better = Namespace.IsImportedTypeOverride (Module, texpr_match.Type, texpr_fne.Type);
				if (better == null) {
					if (mode == LookupMode.Normal) {
						Compiler.Report.SymbolRelatedToPreviousError (texpr_match.Type);
						Compiler.Report.SymbolRelatedToPreviousError (texpr_fne.Type);
						Compiler.Report.Error (104, loc, "`{0}' is an ambiguous reference between `{1}' and `{2}'",
							name, texpr_match.GetSignatureForError (), texpr_fne.GetSignatureForError ());
					}

					return match;
				}

				if (better == texpr_fne.Type)
					match = texpr_fne;
			}

			return match;
		}
Beispiel #51
0
void case_397()
#line 3262 "cs-parser.jay"
{
		report.Error (1536, GetLocation (yyVals[0+yyTop]), "Invalid parameter type `void'");
		yyVal = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation (yyVals[0+yyTop]));
	  }
		public TypeExpr LookupType (IMemberContext ctx, string name, int arity, LookupMode mode, Location loc)
		{
			if (types == null)
				return null;

			TypeExpr te;
			if (arity == 0 && cached_types.TryGetValue (name, out te))
				return te;

			IList<TypeSpec> found;
			if (!types.TryGetValue (name, out found))
				return null;

			TypeSpec best = null;
			foreach (var ts in found) {
				if (ts.Arity == arity) {
					if (best == null) {
						if ((ts.Modifiers & Modifiers.INTERNAL) != 0 && !ts.MemberDefinition.IsInternalAsPublic (ctx.Module.DeclaringAssembly) && mode != LookupMode.IgnoreAccessibility)
							continue;

						best = ts;
						continue;
					}

					if (best.MemberDefinition.IsImported && ts.MemberDefinition.IsImported) {
						if (mode == LookupMode.Normal) {
							ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (best);
							ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (ts);
							ctx.Module.Compiler.Report.Error (433, loc, "The imported type `{0}' is defined multiple times", ts.GetSignatureForError ());
						}
						break;
					}

					if (best.MemberDefinition.IsImported)
						best = ts;

					if ((best.Modifiers & Modifiers.INTERNAL) != 0 && !best.MemberDefinition.IsInternalAsPublic (ctx.Module.DeclaringAssembly))
						continue;

					if (mode != LookupMode.Normal)
						continue;

					if (ts.MemberDefinition.IsImported) {
						ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (best);
						ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (ts);
					}

					ctx.Module.Compiler.Report.Warning (436, 2, loc,
						"The type `{0}' conflicts with the imported type of same name'. Ignoring the imported type definition",
						best.GetSignatureForError ());
				}

				//
				// Lookup for the best candidate with the closest arity match
				//
				if (arity < 0) {
					if (best == null) {
						best = ts;
					} else if (System.Math.Abs (ts.Arity + arity) < System.Math.Abs (best.Arity + arity)) {
						best = ts;
					}
				}
			}

			if (best == null)
				return null;

			te = new TypeExpression (best, Location.Null);

			// TODO MemberCache: Cache more
			if (arity == 0 && mode == LookupMode.Normal)
				cached_types.Add (name, te);

			return te;
		}
Beispiel #53
0
		void DefineAsyncMethods (TypeExpression returnType)
		{
			var iasync_result = Module.PredefinedTypes.IAsyncResult;
			var async_callback = Module.PredefinedTypes.AsyncCallback;

			//
			// It's ok when async types don't exist, the delegate will have Invoke method only
			//
			if (!iasync_result.Define () || !async_callback.Define ())
				return;

			//
			// BeginInvoke
			//
			ParametersCompiled async_parameters;
			if (Parameters.Count == 0) {
				async_parameters = ParametersCompiled.EmptyReadOnlyParameters;
			} else {
				var compiled = new Parameter[Parameters.Count];
				for (int i = 0; i < compiled.Length; ++i) {
					var p = parameters[i];
					compiled[i] = new Parameter (new TypeExpression (parameters.Types[i], Location),
						p.Name,
						p.ModFlags & Parameter.Modifier.RefOutMask,
						p.OptAttributes == null ? null : p.OptAttributes.Clone (), Location);
				}

				async_parameters = new ParametersCompiled (compiled);
			}

			async_parameters = ParametersCompiled.MergeGenerated (Compiler, async_parameters, false,
				new Parameter[] {
					new Parameter (new TypeExpression (async_callback.TypeSpec, Location), "callback", Parameter.Modifier.NONE, null, Location),
					new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, Location), "object", Parameter.Modifier.NONE, null, Location)
				},
				new [] {
					async_callback.TypeSpec,
					Compiler.BuiltinTypes.Object
				}
			);

			BeginInvokeBuilder = new Method (this,
				new TypeExpression (iasync_result.TypeSpec, Location), MethodModifiers,
				new MemberName ("BeginInvoke"), async_parameters, null);
			BeginInvokeBuilder.Define ();

			//
			// EndInvoke is a bit more interesting, all the parameters labeled as
			// out or ref have to be duplicated here.
			//

			//
			// Define parameters, and count out/ref parameters
			//
			ParametersCompiled end_parameters;
			int out_params = 0;

			foreach (Parameter p in Parameters.FixedParameters) {
				if ((p.ModFlags & Parameter.Modifier.RefOutMask) != 0)
					++out_params;
			}

			if (out_params > 0) {
				Parameter[] end_params = new Parameter[out_params];

				int param = 0;
				for (int i = 0; i < Parameters.FixedParameters.Length; ++i) {
					Parameter p = parameters [i];
					if ((p.ModFlags & Parameter.Modifier.RefOutMask) == 0)
						continue;

					end_params [param++] = new Parameter (new TypeExpression (p.Type, Location),
						p.Name,
						p.ModFlags & Parameter.Modifier.RefOutMask,
						p.OptAttributes == null ? null : p.OptAttributes.Clone (), Location);
				}

				end_parameters = new ParametersCompiled (end_params);
			} else {
				end_parameters = ParametersCompiled.EmptyReadOnlyParameters;
			}

			end_parameters = ParametersCompiled.MergeGenerated (Compiler, end_parameters, false,
				new Parameter (
					new TypeExpression (iasync_result.TypeSpec, Location),
					"result", Parameter.Modifier.NONE, null, Location),
				iasync_result.TypeSpec);

			//
			// Create method, define parameters, register parameters with type system
			//
			EndInvokeBuilder = new Method (this, returnType, MethodModifiers, new MemberName ("EndInvoke"), end_parameters, null);
			EndInvokeBuilder.Define ();
		}
		protected override Expression DoResolve (ResolveContext rc)
		{
//			BEN: This won't work because the returned type won't pass Mono's type checkers.
//			if (rc.Target == Target.JavaScript) {
//				this.type = rc.BuiltinTypes.Dynamic;
//				this.eclass = ExprClass.Value;
//				foreach (ElementInitializer elem in Elements)
//					elem.Resolve (rc);
//				return this;
//			}

			TypeExpression type;
			if (inferredObjType != null) {
				type = new TypeExpression (inferredObjType, Location);
			} else if (variable != null) {
				if (variable.TypeExpression is VarExpr) {
					type = new TypeExpression (rc.BuiltinTypes.Dynamic, Location);
				} else {
					type = new TypeExpression (variable.Variable.Type, variable.Variable.Location);
				}
			} else if (assign != null && assign.Target.Type != null) {
				type = new TypeExpression (assign.Target.Type, assign.Target.Location);
			} else {
				type = new TypeExpression (rc.BuiltinTypes.Dynamic, Location);
			}

			return new NewInitialize (type, null, 
				new CollectionOrObjectInitializers(elements, Location), Location).Resolve (rc);
		}
Beispiel #55
0
		protected override bool DoDefineMembers ()
		{
			var builtin_types = Compiler.BuiltinTypes;

			var ctor_parameters = ParametersCompiled.CreateFullyResolved (
				new [] {
					new Parameter (new TypeExpression (builtin_types.Object, Location), "object", Parameter.Modifier.NONE, null, Location),
					new Parameter (new TypeExpression (builtin_types.IntPtr, Location), "method", Parameter.Modifier.NONE, null, Location)
				},
				new [] {
					builtin_types.Object,
					builtin_types.IntPtr
				}
			);

			Constructor = new Constructor (this, Constructor.ConstructorName,
				Modifiers.PUBLIC, null, ctor_parameters, Location);
			Constructor.Define ();

			//
			// Here the various methods like Invoke, BeginInvoke etc are defined
			//
			// First, call the `out of band' special method for
			// defining recursively any types we need:
			//
			var p = parameters;

			if (!p.Resolve (this))
				return false;

			//
			// Invoke method
			//

			// Check accessibility
			foreach (var partype in p.Types) {
				if (!IsAccessibleAs (partype)) {
					Report.SymbolRelatedToPreviousError (partype);
					Report.Error (59, Location,
						"Inconsistent accessibility: parameter type `{0}' is less accessible than delegate `{1}'",
						partype.GetSignatureForError (), GetSignatureForError ());
				}
			}

			var ret_type = ReturnType.ResolveAsType (this);
			if (ret_type == null)
				return false;

			//
			// We don't have to check any others because they are all
			// guaranteed to be accessible - they are standard types.
			//
			if (!IsAccessibleAs (ret_type)) {
				Report.SymbolRelatedToPreviousError (ret_type);
				Report.Error (58, Location,
						  "Inconsistent accessibility: return type `" +
						  ret_type.GetSignatureForError () + "' is less " +
						  "accessible than delegate `" + GetSignatureForError () + "'");
				return false;
			}

			CheckProtectedModifier ();

			if (Compiler.Settings.StdLib && ret_type.IsSpecialRuntimeType) {
				Method.Error1599 (Location, ret_type, Report);
				return false;
			}

			VarianceDecl.CheckTypeVariance (ret_type, Variance.Covariant, this);

			var resolved_rt = new TypeExpression (ret_type, Location);
			InvokeBuilder = new Method (this, resolved_rt, MethodModifiers, new MemberName (InvokeMethodName), p, null);
			InvokeBuilder.Define ();

			//
			// Don't emit async method for compiler generated delegates (e.g. dynamic site containers)
			//
			if (!IsCompilerGenerated) {
				DefineAsyncMethods (resolved_rt);
			}

			return true;
		}
		protected override Expression DoResolve (ResolveContext rc)
		{
//			BEN: This won't work because the returned type won't pass Mono's type checkers.
//			if (rc.Target == Target.JavaScript) {
//				this.type = rc.Module.PredefinedTypes.AsArray.Resolve();
//				this.eclass = ExprClass.Value;
//				foreach (var elem in Elements)
//					elem.Resolve (rc);
//				return this;
//			}

			TypeExpression type;
			if (vectorType != null) {
				var elemTypeSpec = vectorType.ResolveAsType(rc);
				if (elemTypeSpec != null) {
					type = new TypeExpression(
						rc.Module.PredefinedTypes.AsVector.Resolve().MakeGenericType (rc, new [] { elemTypeSpec }), Location);
				} else {
					type = new TypeExpression (rc.Module.PredefinedTypes.AsArray.Resolve(), Location);
				}
			} else if (inferredArrayType != null) {
				type = new TypeExpression (inferredArrayType, Location);
			} else if (variable != null) {
				if (variable.TypeExpression is VarExpr) {
					type = new TypeExpression (rc.Module.PredefinedTypes.AsArray.Resolve(), Location);
				} else if (variable.Variable.Type == rc.BuiltinTypes.Dynamic) {
					type = new TypeExpression (rc.Module.PredefinedTypes.AsArray.Resolve(), Location);
				} else {
					type = new TypeExpression (variable.Variable.Type, variable.Variable.Location);
				}
			} else if (assign != null && assign.Target.Type != null) {
				if (assign.Target.Type == rc.BuiltinTypes.Dynamic) {
					type = new TypeExpression (rc.Module.PredefinedTypes.AsArray.Resolve(), Location);
				} else {
					type = new TypeExpression (assign.Target.Type, assign.Target.Location);
				}
			} else {
				type = new TypeExpression (rc.Module.PredefinedTypes.AsArray.Resolve(), Location);
			}

			TypeSpec typeSpec = type.ResolveAsType(rc.MemberContext);
			if (typeSpec.IsArray) {
				ArrayCreation arrayCreate = (ArrayCreation)new ArrayCreation (type, this).Resolve (rc);
				return arrayCreate;
			} else {
				var initElems = new List<Expression>();
				foreach (var e in elements) {
					initElems.Add (new CollectionElementInitializer(e));
				}
				return new NewInitialize (type, null, 
					new CollectionOrObjectInitializers(initElems, Location), Location).Resolve (rc);
			}
		}
Beispiel #57
0
    private void ParseField(List<ITypeDeclarationMember> members, 
      List<SourceCustomAttribute>/*?*/ attributes, List<ModifierToken> modifiers, TypeExpression type, NameDeclaration name, SourceLocationBuilder sctx, TokenSet followers)
      //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
    {
      TypeMemberVisibility visibility = this.ConvertToTypeMemberVisibility(modifiers);
      FieldDeclaration.Flags flags = 0;
      this.LookForModifier(modifiers, Token.Abstract, Error.InvalidModifier);
      if (this.LookForModifier(modifiers, Token.New, Error.None)) flags |= FieldDeclaration.Flags.New;
      this.LookForModifier(modifiers, Token.Extern, Error.InvalidModifier);
      this.LookForModifier(modifiers, Token.Override, Error.InvalidModifier);
      if (this.LookForModifier(modifiers, Token.Readonly, Error.None)) flags |= FieldDeclaration.Flags.ReadOnly;
      this.LookForModifier(modifiers, Token.Sealed, Error.InvalidModifier);
      if (this.LookForModifier(modifiers, Token.Static, Error.None)) flags |= FieldDeclaration.Flags.Static;
      if (this.LookForModifier(modifiers, Token.Unsafe, Error.None)) flags |= FieldDeclaration.Flags.Unsafe;
      this.LookForModifier(modifiers, Token.Virtual, Error.InvalidModifier);
      if (this.LookForModifier(modifiers, Token.Volatile, Error.None)) flags |= FieldDeclaration.Flags.Volatile;

      TokenSet followersOrCommaOrSemicolon = followers|Token.Comma|Token.Semicolon;
      for (; ; ) {
        Expression/*?*/ initializer = null;
        if (this.currentToken == Token.Assign) {
          //bool savedParsingStatement = this.parsingStatement;
          //this.parsingStatement = true;
          this.GetNextToken();
          if (this.currentToken == Token.LeftBrace) {
            //initializer = this.ParseArrayInitializer(type, followersOrCommaOrSemicolon);
          } else
            initializer = this.ParseExpression(followersOrCommaOrSemicolon);
          //if (this.currentToken != Token.EndOfFile) this.parsingStatement = savedParsingStatement;
        }
        sctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
        FieldDeclaration f = new FieldDeclaration(attributes, flags, visibility, type, name, initializer, sctx);
        members.Add(f);
        if (this.currentToken != Token.Comma) break;
        this.GetNextToken();
        name = this.ParseNameDeclaration();
        sctx = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
      }
      this.SkipSemiColon(followers);
    }
Beispiel #58
0
    private void ParseOperator(List<ITypeDeclarationMember> members, 
      List<SourceCustomAttribute>/*?*/ attributes, List<ModifierToken> modifiers, TypeExpression/*?*/ resultType, SourceLocationBuilder sctx, TokenSet followers)
      //^ requires this.currentToken == Token.Explicit || this.currentToken == Token.Implicit || this.currentToken == Token.Operator;
      //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
    {
      MethodDeclaration.Flags flags = MethodDeclaration.Flags.SpecialName;
      TypeMemberVisibility visibility = this.ConvertToTypeMemberVisibility(modifiers);
      this.LookForModifier(modifiers, Token.Abstract, Error.InvalidModifier);
      if (this.LookForModifier(modifiers, Token.Extern, Error.None)) flags |= MethodDeclaration.Flags.External;
      this.LookForModifier(modifiers, Token.New, Error.InvalidModifier);
      this.LookForModifier(modifiers, Token.Override, Error.InvalidModifier);
      this.LookForModifier(modifiers, Token.Readonly, Error.InvalidModifier);
      this.LookForModifier(modifiers, Token.Sealed, Error.InvalidModifier);
      if (this.LookForModifier(modifiers, Token.Static, Error.None)) flags |= MethodDeclaration.Flags.Static;
      if (this.LookForModifier(modifiers, Token.Unsafe, Error.None)) flags |= MethodDeclaration.Flags.Unsafe;
      this.LookForModifier(modifiers, Token.Virtual, Error.InvalidModifier);
      this.LookForModifier(modifiers, Token.Volatile, Error.InvalidModifier);


      NameDeclaration opName = new NameDeclaration(this.nameTable.EmptyName, this.scanner.SourceLocationOfLastScannedToken);
      SourceLocationBuilder ctx = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
      ISourceLocation symCtx = this.scanner.SourceLocationOfLastScannedToken;
      bool canBeBinary = false;
      bool canBeUnary = false;
      switch (this.currentToken) {
        case Token.Explicit:
          this.GetNextToken();
          ctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
          opName = this.GetNameDeclarationFor("op_Explicit", ctx.GetSourceLocation());
          this.Skip(Token.Operator);
          if (resultType != null && this.currentToken == Token.LeftParenthesis)
            this.HandleError(opName.SourceLocation, Error.BadOperatorSyntax, "explicit");
          else
            resultType = this.ParseTypeExpression(false, false, followers|Token.LeftParenthesis);
          canBeUnary = true;
          break;
        case Token.Implicit:
          this.GetNextToken();
          ctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
          opName = this.GetNameDeclarationFor("op_Implicit", ctx.GetSourceLocation());
          this.Skip(Token.Operator);
          if (resultType != null && this.currentToken == Token.LeftParenthesis)
            this.HandleError(opName.SourceLocation, Error.BadOperatorSyntax, "implicit");
          else
            resultType = this.ParseTypeExpression(false, false, followers|Token.LeftParenthesis);
          canBeUnary = true;
          break;
        case Token.Operator: 
          this.GetNextToken();
          symCtx = this.scanner.SourceLocationOfLastScannedToken;
          ctx.UpdateToSpan(symCtx);
          this.GetOperatorName(ref opName, ref canBeBinary, ref canBeUnary, ctx.GetSourceLocation());
          if (this.currentToken != Token.EndOfFile) this.GetNextToken();
          if (resultType == null) {
            this.HandleError(Error.BadOperatorSyntax2, ctx.GetSourceLocation().Source);
            if (this.currentToken != Token.LeftParenthesis)
              resultType = this.ParseTypeExpression(false, false, followers|Token.LeftParenthesis);
            else
              resultType = new NamedTypeExpression(this.RootQualifiedNameFor(Token.Void));
          }
          break;
        default:
          //^ assert false;
          break;
      }
      //Parse the parameter list
      List<Ast.ParameterDeclaration> parameters = new List<Ast.ParameterDeclaration>();
      this.ParseParameters(parameters, Token.RightParenthesis, followers|Token.LeftBrace|Token.Semicolon|Token.Requires|Token.Modifies|Token.Ensures|Token.Where|Token.Throws);
      switch (parameters.Count) {
        case 1:
          if (!canBeUnary)
            this.HandleError(symCtx, Error.OvlUnaryOperatorExpected);
          if (canBeBinary && opName != null) {
            if (opName.Value == "op_Addition") opName = this.GetNameDeclarationFor("op_UnaryPlus", opName.SourceLocation);
            else if (opName.Value == "op_Subtraction") opName = this.GetNameDeclarationFor("op_UnaryNegation", opName.SourceLocation);
          }
          break;
        case 2:
          if (!canBeBinary)
            if (canBeUnary)
              this.HandleError(symCtx, Error.WrongParsForUnaryOp, opName.SourceLocation.Source);
            else
              this.HandleError(symCtx, Error.OvlBinaryOperatorExpected);
          break;
        default:
          if (canBeBinary)
            this.HandleError(symCtx, Error.WrongParsForBinOp, opName.SourceLocation.Source);
          else if (canBeUnary)
            this.HandleError(symCtx, Error.WrongParsForUnaryOp, opName.SourceLocation.Source);
          else
            this.HandleError(symCtx, Error.OvlBinaryOperatorExpected);
          break;
      }
      ctx.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);

      //bool swallowedSemicolonAlready = false;
      //this.ParseMethodContract(oper, followers|Token.LeftBrace|Token.Semicolon, ref swallowedSemicolonAlready);
      BlockStatement body = this.ParseBody(followers);
      //^ assert followers[this.currentToken] || this.currentToken == Token.EndOfFile;
      sctx.UpdateToSpan(body.SourceLocation);

      MethodDeclaration method = new MethodDeclaration(attributes, flags, visibility, 
        resultType, null, opName, null, parameters, null, body, sctx.GetSourceLocation());
      members.Add(method);
      //^ assume followers[this.currentToken] || this.currentToken == Token.EndOfFile;
    }
Beispiel #59
0
		//
		// Public function used to locate types.
		//
		// Returns: Type or null if they type can not be found.
		//
		public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
		{
			FullNamedExpression e;
			if (arity == 0 && Cache.TryGetValue (name, out e) && mode != LookupMode.IgnoreAccessibility)
				return e;

			e = null;

			if (arity == 0) {
				var tp = CurrentTypeParameters;
				if (tp != null) {
					TypeParameter tparam = tp.Find (name);
					if (tparam != null)
						e = new TypeParameterExpr (tparam, Location.Null);
				}
			}

			if (e == null) {
				TypeSpec t = LookupNestedTypeInHierarchy (name, arity);

				if (t != null && (t.IsAccessible (this) || mode == LookupMode.IgnoreAccessibility))
					e = new TypeExpression (t, Location.Null);
				else {
					var errors = Compiler.Report.Errors;
					e = Parent.LookupNamespaceOrType (name, arity, mode, loc);

					// TODO: LookupNamespaceOrType does more than just lookup. The result
					// cannot be cached or the error reporting won't happen
					if (errors != Compiler.Report.Errors)
						return e;
				}
			}

			// TODO MemberCache: How to cache arity stuff ?
			if (arity == 0 && mode == LookupMode.Normal)
				Cache[name] = e;

			return e;
		}
Beispiel #60
0
    private void ParseMethod(List<ITypeDeclarationMember> members, 
      List<SourceCustomAttribute>/*?*/ attributes, List<ModifierToken> modifiers, TypeExpression type, 
      List<TypeExpression>/*?*/ implementedInterfaces, NameDeclaration name, SourceLocationBuilder sctx, TokenSet followers)
      //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
    {
      MethodDeclaration.Flags flags = 0;
      TypeMemberVisibility visibility = this.ConvertToTypeMemberVisibility(modifiers);
      if (this.LookForModifier(modifiers, Token.Abstract, Error.None)) flags |= MethodDeclaration.Flags.Abstract;
      if (this.LookForModifier(modifiers, Token.New, Error.None)) flags |= MethodDeclaration.Flags.New;
      if (this.LookForModifier(modifiers, Token.Extern, Error.None)) flags |= MethodDeclaration.Flags.External;
      if (this.LookForModifier(modifiers, Token.Override, Error.None)) flags |= MethodDeclaration.Flags.Override;
      this.LookForModifier(modifiers, Token.Readonly, Error.InvalidModifier);
      if (this.LookForModifier(modifiers, Token.Sealed, Error.None)) flags |= MethodDeclaration.Flags.Sealed;
      if (this.LookForModifier(modifiers, Token.Static, Error.None)) flags |= MethodDeclaration.Flags.Static;
      if (this.LookForModifier(modifiers, Token.Unsafe, Error.None)) flags |= MethodDeclaration.Flags.Unsafe;
      if (this.LookForModifier(modifiers, Token.Virtual, Error.None)) flags |= MethodDeclaration.Flags.Virtual;
      this.LookForModifier(modifiers, Token.Volatile, Error.InvalidModifier);

      List<Ast.GenericMethodParameterDeclaration> genericParameters = new List<Ast.GenericMethodParameterDeclaration>();
      List<Ast.ParameterDeclaration> parameters = new List<Ast.ParameterDeclaration>();
      List<Statement> statements = new List<Statement>();
      SourceLocationBuilder bodyCtx = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
      BlockStatement body = new BlockStatement(statements, bodyCtx);

      bool isExtensionMethod;
      this.ParseGenericMethodParameters(genericParameters, followers|Token.LeftParenthesis|Token.Where|Token.LeftBrace|Token.Semicolon);
      this.ParseParameters(parameters, Token.RightParenthesis, followers|Token.Where|Token.LeftBrace|Token.Semicolon, out isExtensionMethod);
      if (isExtensionMethod)
        flags |= MethodDeclaration.Flags.ExtensionMethod;

      MethodDeclaration method = new MethodDeclaration(attributes, flags, visibility, 
        type, implementedInterfaces, name, genericParameters, parameters, null, body, sctx);
      members.Add(method);

      // Now: how to get 
      this.ParseGenericMethodParameterConstraintsClauses(genericParameters, followers|Token.LeftBrace|Token.Semicolon);
      //bool swallowedSemicolonAlready = false;
      //this.ParseMethodContract(oper, followers|Token.LeftBrace|Token.Semicolon, ref swallowedSemicolonAlready);
      this.ParseBody(statements, bodyCtx, followers);
      //^ assert followers[this.currentToken] || this.currentToken == Token.EndOfFile;
      sctx.UpdateToSpan(bodyCtx.GetSourceLocation());
      //^ assume followers[this.currentToken] || this.currentToken == Token.EndOfFile;
    }