Beispiel #1
0
        public static ParameterDeclarationCollection FromArray(params Boo.Lang.Compiler.Ast.ParameterDeclaration[] items)
        {
            var collection = new ParameterDeclarationCollection();

            collection.AddRange(items);
            return(collection);
        }
Beispiel #2
0
        protected Expression SerializeCollection(Node sourceNode, string typeName, ParameterDeclarationCollection nodes)
        {
            var result = SerializeCollectionWith(Serialize, sourceNode, typeName, nodes);

            result.Arguments.Insert(0, new BoolLiteralExpression(nodes.HasParamArray));
            return(result);
        }
        public override object Clone()
        {
            ParameterDeclarationCollection c = (ParameterDeclarationCollection)base.Clone();

            c.HasParamArray = HasParamArray;
            return(c);
        }
Beispiel #4
0
 void ConvertParameters(AST.ParameterDeclarationCollection parameters, DefaultMethod m)
 {
     if (parameters == null || parameters.Count == 0)
     {
         m.Parameters = DefaultParameter.EmptyParameterList;
     }
     else
     {
         AddParameters(parameters, m.Parameters, m, m.DeclaringType);
     }
 }
Beispiel #5
0
 void ConvertParameters(AST.ParameterDeclarationCollection parameters, DefaultProperty p)
 {
     if (parameters == null || parameters.Count == 0)
     {
         p.Parameters = DefaultParameter.EmptyParameterList;
     }
     else
     {
         AddParameters(parameters, p.Parameters, p, p.DeclaringType);
     }
 }
        void ConvertParameters(List <ParameterDeclarationExpression> input, B.ParameterDeclarationCollection output)
        {
            bool isParams = false;

            foreach (ParameterDeclarationExpression pde in input)
            {
                B.ParameterDeclaration para = ConvertParameter(pde, out isParams);
                if (para != null)
                {
                    output.Add(para);
                }
            }
            output.HasParamArray = isParams;
        }
Beispiel #7
0
        internal static void AddParameters(AST.ParameterDeclarationCollection parameters, IList <IParameter> output, IMethodOrProperty method, IClass c)
        {
            if (c == null)
            {
                throw new ArgumentNullException("c");
            }
            DefaultParameter p = null;

            foreach (AST.ParameterDeclaration par in parameters)
            {
                p = new DefaultParameter(par.Name,
                                         CreateReturnType(par.Type, c, method as IMethod, c.Region.BeginLine + 1, 1, c.ProjectContent),
                                         new DomRegion(par.LexicalInfo.Line, par.LexicalInfo.Column));
                if (par.IsByRef)
                {
                    p.Modifiers |= ParameterModifiers.Ref;
                }
                output.Add(p);
            }
            if (parameters.HasParamArray)
            {
                p.Modifiers |= ParameterModifiers.Params;
            }
        }
Beispiel #8
0
        //throws RecognitionException, TokenStreamException
        protected void callable_parameter_declaration_list(
		ParameterDeclarationCollection c
	)
        {
            try {      // for error handling
            {
                switch ( LA(1) )
                {
                case CALLABLE:
                case CHAR:
                case REF:
                case ID:
                case LPAREN:
                case SPLICE_BEGIN:
                {
                    callable_parameter_declaration(c);
                    {    // ( ... )*
                        for (;;)
                        {
                            if ((LA(1)==COMMA))
                            {
                                match(COMMA);
                                callable_parameter_declaration(c);
                            }
                            else
                            {
                                goto _loop184_breakloop;
                            }

                        }
            _loop184_breakloop:						;
                    }    // ( ... )*
                    break;
                }
                case RPAREN:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_37_);
            }
            else
            {
                throw ex;
            }
            }
        }
Beispiel #9
0
        //throws RecognitionException, TokenStreamException
        protected bool parameter_declaration(
            ParameterDeclarationCollection c
            )
        {
            bool variableArguments;

            IToken  id1 = null;
            IToken  id2 = null;

                IToken id = null;
                TypeReference tr = null;
                ParameterModifiers pm = ParameterModifiers.None;
                variableArguments = false;

            try {      // for error handling
            attributes();
            {
                switch ( LA(1) )
                {
                case MULTIPLY:
                {
                    {
                        match(MULTIPLY);
                        if (0==inputState.guessing)
                        {
                            variableArguments=true;
                        }
                        id1 = LT(1);
                        match(ID);
                        {
                            switch ( LA(1) )
                            {
                            case AS:
                            {
                                match(AS);
                                tr=array_type_reference();
                                break;
                            }
                            case RPAREN:
                            case RBRACK:
                            case COMMA:
                            case BITWISE_OR:
                            {
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
                             }
                        }
                        if (0==inputState.guessing)
                        {
                            id = id1;
                        }
                    }
                    break;
                }
                case REF:
                case ID:
                {
                    {
                        {
                            switch ( LA(1) )
                            {
                            case REF:
                            {
                                pm=parameter_modifier();
                                break;
                            }
                            case ID:
                            {
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
                             }
                        }
                        id2 = LT(1);
                        match(ID);
                        {
                            switch ( LA(1) )
                            {
                            case AS:
                            {
                                match(AS);
                                tr=type_reference();
                                break;
                            }
                            case RPAREN:
                            case RBRACK:
                            case COMMA:
                            case BITWISE_OR:
                            {
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
                             }
                        }
                        if (0==inputState.guessing)
                        {
                            id = id2;
                        }
                    }
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            if (0==inputState.guessing)
            {

                        ParameterDeclaration pd = new ParameterDeclaration(SourceLocationFactory.ToLexicalInfo(id));
                        pd.Name = id.getText();
                        pd.Type = tr;
                        pd.Modifiers = pm;
                        AddAttributes(pd.Attributes);
                        c.Add(pd);

            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_81_);
            }
            else
            {
                throw ex;
            }
            }
            return variableArguments;
        }
Beispiel #10
0
 void WriteParameterList(ParameterDeclarationCollection items)
 {
     WriteParameterList(items, "(", ")");
 }
 public Boo.Lang.Compiler.Ast.ParameterDeclarationCollection PopRange(int begin)
 {
     Boo.Lang.Compiler.Ast.ParameterDeclarationCollection range = new Boo.Lang.Compiler.Ast.ParameterDeclarationCollection(_parent);
     range.InnerList.Extend(InternalPopRange(begin));
     return(range);
 }
Beispiel #12
0
 void WriteParameterList(ParameterDeclarationCollection items, string st, string ed)
 {
     Write(st);
     int last = items.Count-1;
     int i = 0;
     foreach (ParameterDeclaration item in items)
     {
         if (i > 0)
         {
             Write(", ");
         }
         if (i == last && items.VariableNumber)
         {
             Write("*");
         }
         Visit(item);
         ++i;
     }
     Write(ed);
 }
Beispiel #13
0
	protected void parameter_declaration_list(
		ParameterDeclarationCollection c
	) //throws RecognitionException, TokenStreamException
{
		
		
				bool variableArguments = false;
			
		
		try {      // for error handling
			{
				switch ( LA(1) )
				{
				case REF:
				case ID:
				case MULTIPLY:
				case LBRACK:
				case SPLICE_BEGIN:
				{
					variableArguments=parameter_declaration(c);
					{    // ( ... )*
						for (;;)
						{
							if (((LA(1)==COMMA))&&(!variableArguments))
							{
								{
									match(COMMA);
									variableArguments=parameter_declaration(c);
								}
							}
							else
							{
								goto _loop210_breakloop;
							}
							
						}
_loop210_breakloop:						;
					}    // ( ... )*
					break;
				}
				case RPAREN:
				case RBRACK:
				case BITWISE_OR:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				c.HasParamArray = variableArguments;
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "parameter_declaration_list");
				recover(ex,tokenSet_42_);
			}
			else
			{
				throw ex;
			}
		}
	}
Beispiel #14
0
	protected void callable_parameter_declaration_list(
		ParameterDeclarationCollection c
	) //throws RecognitionException, TokenStreamException
{
		
		
			bool varArgs = false;
		
		
		try {      // for error handling
			{
				switch ( LA(1) )
				{
				case CALLABLE:
				case CHAR:
				case REF:
				case THEN:
				case LPAREN:
				case ID:
				case MULTIPLY:
				case SPLICE_BEGIN:
				{
					varArgs=callable_parameter_declaration(c);
					{    // ( ... )*
						for (;;)
						{
							if (((LA(1)==COMMA))&&(!varArgs))
							{
								{
									match(COMMA);
									varArgs=callable_parameter_declaration(c);
								}
							}
							else
							{
								goto _loop224_breakloop;
							}
							
						}
_loop224_breakloop:						;
					}    // ( ... )*
					if (0==inputState.guessing)
					{
						c.HasParamArray = varArgs;
					}
					break;
				}
				case RPAREN:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "callable_parameter_declaration_list");
				recover(ex,tokenSet_53_);
			}
			else
			{
				throw ex;
			}
		}
	}
Beispiel #15
0
 Type[] GetParameterTypes(ParameterDeclarationCollection parameters)
 {
     Type[] types = new Type[parameters.Count];
     for (int i=0; i<types.Length; ++i)
     {
         types[i] = GetSystemType(parameters[i].Type);
         if (parameters[i].IsByRef && !types[i].IsByRef)
         {
             types[i] = types[i].MakeByRefType();
         }
     }
     return types;
 }
Beispiel #16
0
 void DefineParameters(MethodBuilder builder, ParameterDeclarationCollection parameters)
 {
     DefineParameters(parameters, new ParameterFactory(builder.DefineParameter));
 }
Beispiel #17
0
        //throws RecognitionException, TokenStreamException
        protected void callable_parameter_declaration(
		ParameterDeclarationCollection c
	)
        {
            TypeReference tr = null;
                ParameterModifiers pm = ParameterModifiers.None;

            try {      // for error handling
            {
                {
                    switch ( LA(1) )
                    {
                    case REF:
                    {
                        pm=parameter_modifier();
                        break;
                    }
                    case CALLABLE:
                    case CHAR:
                    case ID:
                    case LPAREN:
                    case SPLICE_BEGIN:
                    {
                        break;
                    }
                    default:
                    {
                        throw new NoViableAltException(LT(1), getFilename());
                    }
                     }
                }
                {
                    tr=type_reference();
                }
            }
            if (0==inputState.guessing)
            {

                        ParameterDeclaration pd = new ParameterDeclaration(tr.LexicalInfo);
                        pd.Name = "arg" + c.Count;
                        pd.Type = tr;
                        pd.Modifiers = pm;
                        c.Add(pd);

            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_69_);
            }
            else
            {
                throw ex;
            }
            }
        }
Beispiel #18
0
 void DefineParameters(ParameterDeclarationCollection parameters, ParameterFactory defineParameter)
 {
     int last = parameters.Count - 1;
     for (int i=0; i<parameters.Count; ++i)
     {
         ParameterBuilder paramBuilder = defineParameter(i+1, GetParameterAttributes(parameters[i]), parameters[i].Name);
         if (last == i && parameters.VariableNumber)
         {
             SetParamArrayAttribute(paramBuilder);
         }
         SetBuilder(parameters[i], paramBuilder);
     }
 }
Beispiel #19
0
 public IParameter[] Map(ParameterDeclarationCollection parameters)
 {
     IParameter[] mapped = new IParameter[parameters.Count];
     for (int i=0; i<mapped.Length; ++i)
     {
         mapped[i] = (IParameter)GetEntity(parameters[i]);
     }
     return mapped;
 }
Beispiel #20
0
 void DefineParameters(ParameterDeclarationCollection parameters, ParameterFactory defineParameter)
 {
     for (int i=0; i<parameters.Count; ++i)
     {
         ParameterBuilder paramBuilder = defineParameter(i+1, GetParameterAttributes(parameters[i]), parameters[i].Name);
         if (parameters[i].IsParamArray)
         {
             SetParamArrayAttribute(paramBuilder);
         }
         SetBuilder(parameters[i], paramBuilder);
     }
 }
Beispiel #21
0
        protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls)
        {
            ParameterDeclarationCollection parameters = new ParameterDeclarationCollection();
            ParameterDeclaration newParameterDeclaration =
                new ParameterDeclaration("input", new SimpleTypeReference("System.String"));
            parameters.Add(newParameterDeclaration);

            pipeline.Insert(1, new ImplicitBaseClassCompilerStep(typeof(MyClassWithParams),
                "Hello",
                parameters,
                "System"));
        }
        /// <summary>
        /// Create new instance of <seealso cref="ImplicitBaseClassCompilerStep"/>
        /// </summary>
        /// <param name="baseClass">The base class that will be used</param>
        /// <param name="methodName">The name of the method that will get all the code from globals moved to it.</param>
        /// <param name="parameters">The parameters of this method</param>        
        /// <param name="namespaces">Namespaces that would be automatically imported into all modules</param>               
        public ImplicitBaseClassCompilerStep(Type baseClass, string methodName, ParameterDeclarationCollection parameters, params string[] namespaces)
			: base(baseClass, namespaces)
        {
            this.methodName = methodName;
            this.parameters = parameters;
        }
Beispiel #23
0
		void DefineParameters(ConstructorBuilder builder, ParameterDeclarationCollection parameters)
		{
			DefineParameters(parameters, builder.DefineParameter);
		}
Beispiel #24
0
	protected bool  parameter_declaration(
		ParameterDeclarationCollection c
	) //throws RecognitionException, TokenStreamException
{
		bool variableArguments;
		
		IToken  id1 = null;
		IToken  begin1 = null;
		IToken  id2 = null;
		IToken  begin2 = null;
				
				IToken id = null;
				TypeReference tr = null;
				ParameterModifiers pm = ParameterModifiers.None;
				variableArguments = false;
				Expression nameSplice = null;
			
		
		try {      // for error handling
			attributes();
			{
				switch ( LA(1) )
				{
				case MULTIPLY:
				{
					{
						match(MULTIPLY);
						if (0==inputState.guessing)
						{
							variableArguments=true;
						}
						{
							switch ( LA(1) )
							{
							case ID:
							{
								id1 = LT(1);
								match(ID);
								if (0==inputState.guessing)
								{
									id = id1;
								}
								break;
							}
							case SPLICE_BEGIN:
							{
								begin1 = LT(1);
								match(SPLICE_BEGIN);
								nameSplice=atom();
								if (0==inputState.guessing)
								{
									id = begin1;
								}
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
						{
							switch ( LA(1) )
							{
							case AS:
							{
								match(AS);
								tr=array_type_reference();
								break;
							}
							case RPAREN:
							case RBRACK:
							case COMMA:
							case BITWISE_OR:
							{
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
					}
					break;
				}
				case REF:
				case ID:
				case SPLICE_BEGIN:
				{
					{
						{
							switch ( LA(1) )
							{
							case REF:
							{
								pm=parameter_modifier();
								break;
							}
							case ID:
							case SPLICE_BEGIN:
							{
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
						{
							switch ( LA(1) )
							{
							case ID:
							{
								id2 = LT(1);
								match(ID);
								if (0==inputState.guessing)
								{
									id = id2;
								}
								break;
							}
							case SPLICE_BEGIN:
							{
								begin2 = LT(1);
								match(SPLICE_BEGIN);
								nameSplice=atom();
								if (0==inputState.guessing)
								{
									id = begin2;
								}
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
						{
							switch ( LA(1) )
							{
							case AS:
							{
								match(AS);
								tr=type_reference();
								break;
							}
							case RPAREN:
							case RBRACK:
							case COMMA:
							case BITWISE_OR:
							{
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				
						ParameterDeclaration pd = new ParameterDeclaration(ToLexicalInfo(id));
						pd.Name = id.getText();
						pd.Type = tr;
						pd.Modifiers = pm;
						AddAttributes(pd.Attributes);
						
						c.Add(
							nameSplice != null
							? new SpliceParameterDeclaration(pd, nameSplice)
							: pd);
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "parameter_declaration");
				recover(ex,tokenSet_86_);
			}
			else
			{
				throw ex;
			}
		}
		return variableArguments;
	}
Beispiel #25
0
		void DefineParameters(MethodBuilder builder, ParameterDeclarationCollection parameters)
		{
			DefineParameters(parameters, builder.DefineParameter);
		}
Beispiel #26
0
	protected bool  callable_parameter_declaration(
		ParameterDeclarationCollection c
	) //throws RecognitionException, TokenStreamException
{
		bool varArgs;
		
				
				TypeReference tr = null;
				ParameterModifiers pm = ParameterModifiers.None;
				varArgs = false;
			
		
		try {      // for error handling
			{
				switch ( LA(1) )
				{
				case MULTIPLY:
				{
					{
						match(MULTIPLY);
						if (0==inputState.guessing)
						{
							varArgs=true;
						}
						tr=type_reference();
					}
					break;
				}
				case CALLABLE:
				case CHAR:
				case REF:
				case THEN:
				case LPAREN:
				case ID:
				case SPLICE_BEGIN:
				{
					{
						{
							switch ( LA(1) )
							{
							case REF:
							{
								pm=parameter_modifier();
								break;
							}
							case CALLABLE:
							case CHAR:
							case THEN:
							case LPAREN:
							case ID:
							case SPLICE_BEGIN:
							{
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
						{
							tr=type_reference();
						}
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				
						ParameterDeclaration pd = new ParameterDeclaration(tr.LexicalInfo);
						pd.Name = "arg" + c.Count;
						pd.Type = tr;
						pd.Modifiers = pm;
						c.Add(pd);
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "callable_parameter_declaration");
				recover(ex,tokenSet_87_);
			}
			else
			{
				throw ex;
			}
		}
		return varArgs;
	}
        public void function_type_parameters(ParameterDeclarationCollection parameters)
        {
            try
            {
                this.match(0x3f);
                switch (this.LA(1))
                {
                    case 0x13:
                    case 0x3b:
                    {
                        TypeReference reference = this.type_reference();
                        if (base.inputState.guessing == 0)
                        {
                            ParameterDeclaration declaration;
                            ParameterDeclaration declaration1 = declaration = new ParameterDeclaration();
                            declaration.set_Type(reference);
                            declaration.set_Name("arg" + parameters.Count);
                            parameters.Add(declaration);
                        }
                        while (this.LA(1) == 0x43)
                        {
                            this.match(0x43);
                            reference = this.type_reference();
                            if (base.inputState.guessing == 0)
                            {
                                ParameterDeclaration declaration2;
                                ParameterDeclaration declaration3 = declaration2 = new ParameterDeclaration();
                                declaration2.set_Type(reference);
                                declaration2.set_Name("arg" + parameters.Count);
                                parameters.Add(declaration2);
                            }
                        }
                        break;
                    }
                    case 0x40:
                        break;

                    default:
                        throw new NoViableAltException(this.LT(1), this.getFilename());
                }
                this.match(0x40);
            }
            catch (RecognitionException exception)
            {
                if (base.inputState.guessing != 0)
                {
                    throw;
                }
                this.reportError(exception);
                this.recover(exception, tokenSet_35_);
            }
        }