示例#1
0
 public Indexer(ReturnType type, ParameterCollection parameters, Modifier m, IRegion region, IRegion bodyRegion)
 {
     returnType      = type;
     this.parameters = parameters;
     this.region     = region;
     this.bodyRegion = bodyRegion;
     modifiers = (ModifierEnum)m;
 }
 /// <summary>
 ///     <para>
 ///       Initializes a new instance of <see cref='.IParameterCollection'/> based on another <see cref='.IParameterCollection'/>.
 ///    </para>
 /// </summary>
 /// <param name='value'>
 ///       A <see cref='.IParameterCollection'/> from which the contents are copied
 /// </param>
 public ParameterCollection(ParameterCollection value)
 {
     this.AddRange(value);
 }
 public IParameterEnumerator(ParameterCollection mappings)
 {
     this.temp = ((IEnumerable)(mappings));
     this.baseEnumerator = temp.GetEnumerator();
 }
 /// <summary>
 ///     <para>
 ///       Adds the contents of another <see cref='.IParameterCollection'/> to the end of the collection.
 ///    </para>
 /// </summary>
 /// <param name='value'>
 ///    A <see cref='.IParameterCollection'/> containing the objects to add to the collection.
 /// </param>
 /// <returns>
 ///   <para>None.</para>
 /// </returns>
 /// <seealso cref='.IParameterCollection.Add'/>
 public void AddRange(ParameterCollection value)
 {
     for (int i = 0; (i < value.Count); i = (i + 1)) {
         this.Add(value[i]);
     }
 }
 public override object Visit(AST.IndexerDeclaration indexerDeclaration, object data)
 {
     DefaultRegion region     = GetRegion(indexerDeclaration.StartLocation, indexerDeclaration.EndLocation);
     DefaultRegion bodyRegion = GetRegion(indexerDeclaration.BodyStart,     indexerDeclaration.BodyEnd);
     ParameterCollection parameters = new ParameterCollection();
     Indexer i = new Indexer(new ReturnType(indexerDeclaration.TypeReference), parameters, indexerDeclaration.Modifier, region, bodyRegion);
     if (indexerDeclaration.Parameters != null) {
         foreach (AST.ParameterDeclarationExpression par in indexerDeclaration.Parameters) {
             ReturnType parType = new ReturnType(par.TypeReference);
             Parameter p = new Parameter(par.ParameterName, parType);
             parameters.Add(p);
         }
     }
     Class c = (Class)currentClass.Peek();
     c.Indexer.Add(i);
     return null;
 }
        public override object Visit(AST.ConstructorDeclaration constructorDeclaration, object data)
        {
            DefaultRegion region     = GetRegion(constructorDeclaration.StartLocation, constructorDeclaration.EndLocation);
            DefaultRegion bodyRegion = GetRegion(constructorDeclaration.EndLocation, constructorDeclaration.Body != null ? constructorDeclaration.Body.EndLocation : new Point(-1, -1));
            Class c       = (Class)currentClass.Peek();

            Constructor constructor = new Constructor(constructorDeclaration.Modifier, region, bodyRegion);
            ParameterCollection parameters = new ParameterCollection();
            if (constructorDeclaration.Parameters != null) {
                foreach (AST.ParameterDeclarationExpression par in constructorDeclaration.Parameters) {
                    ReturnType parType = new ReturnType(par.TypeReference);
                    Parameter p = new Parameter(par.ParameterName, parType);
                    parameters.Add(p);
                }
            }
            constructor.Parameters = parameters;
            c.Methods.Add(constructor);
            return null;
        }
        public override object Visit(AST.MethodDeclaration methodDeclaration, object data)
        {
            DefaultRegion region     = GetRegion(methodDeclaration.StartLocation, methodDeclaration.EndLocation);
            DefaultRegion bodyRegion = GetRegion(methodDeclaration.EndLocation, methodDeclaration.Body != null ? methodDeclaration.Body.EndLocation : new Point(-1, -1));
            //			Console.WriteLine(region + " --- " + bodyRegion);
            ReturnType type = new ReturnType(methodDeclaration.TypeReference);
            Class c       = (Class)currentClass.Peek();

            Method method = new Method(String.Concat(methodDeclaration.Name), type, methodDeclaration.Modifier, region, bodyRegion);
            ParameterCollection parameters = new ParameterCollection();
            if (methodDeclaration.Parameters != null) {
                foreach (AST.ParameterDeclarationExpression par in methodDeclaration.Parameters) {
                    ReturnType parType = new ReturnType(par.TypeReference);
                    Parameter p = new Parameter(par.ParameterName, parType);
                    parameters.Add(p);
                }
            }
            method.Parameters = parameters;
            c.Methods.Add(method);
            return null;
        }