Пример #1
0
		public DefaultParameter(IParameter p)
		{
			this.name = p.Name;
			this.region = p.Region;
			this.modifier = p.Modifiers;
			this.returnType = p.ReturnType;
		}
Пример #2
0
        /// <summary>
        /// prepare the method declaration for another parameter;
        /// this is useful for writing method declarations
        /// </summary>
        /// <param name="MethodDeclaration"></param>
        /// <param name="firstParameter"></param>
        /// <param name="align"></param>
        /// <param name="AParamName"></param>
        /// <param name="AParamModifier"></param>
        /// <param name="AParamTypeName"></param>
        public static void AddParameter(ref string MethodDeclaration, ref bool firstParameter, int align,
            string AParamName, ParameterModifiers AParamModifier, string AParamTypeName)
        {
            if (!firstParameter)
            {
                MethodDeclaration += "," + Environment.NewLine;
                MethodDeclaration += new String(' ', align);
            }

            firstParameter = false;

            String parameterType = AParamTypeName;
            String StrParameter = "";

            if ((ParameterModifiers.Ref & AParamModifier) > 0)
            {
                StrParameter += "ref ";
            }
            else if ((ParameterModifiers.Out & AParamModifier) > 0)
            {
                StrParameter += "out ";
            }

            StrParameter += parameterType + " " + AParamName;

            MethodDeclaration += StrParameter;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the Argument class.
        /// </summary>
        /// <param name="name">The optional name of the argument.</param>
        /// <param name="modifiers">Modifers applied to this argument.</param>
        /// <param name="argumentExpression">The expression that forms the body of the argument.</param>
        /// <param name="location">The location of the argument in the code.</param>
        /// <param name="parent">The parent code part.</param>
        /// <param name="tokens">The tokens that form the argument.</param>
        /// <param name="generated">Indicates whether the argument is located within a block of generated code.</param>
        internal Argument(
            CsToken name, 
            ParameterModifiers modifiers, 
            Expression argumentExpression,
            CodeLocation location, 
            Reference<ICodePart> parent,
            CsTokenList tokens, 
            bool generated)
        {
            Param.Ignore(name);
            Param.Ignore(modifiers);
            Param.AssertNotNull(argumentExpression, "argumentExpression");
            Param.AssertNotNull(location, "location");
            Param.AssertNotNull(parent, "parent");
            Param.Ignore(tokens);
            Param.Ignore(generated);

            this.name = name;
            this.modifiers = modifiers;
            this.argumentExpression = argumentExpression;
            this.location = location;
            this.parent = parent;
            this.tokens = tokens;
            this.generated = generated;
        }
        /// <summary>
        /// Initializes a new instance of the GenericTypeParameter class.
        /// </summary>
        /// <param name="type">The generic type parameter.</param>
        /// <param name="modifiers">Optional modifiers.</param>
        internal GenericTypeParameter(TypeToken type, ParameterModifiers modifiers)
        {
            Param.AssertNotNull(type, "type");
            Param.Ignore(modifiers);

            this.type = type;
            this.modifiers = modifiers;
        }
Пример #5
0
 public void Add(ParameterModifiers m)
 {
     if ((cur & m) == 0) {
         cur |= m;
     } else {
         parser.Error("param modifier " + m + " already defined");
     }
 }
Пример #6
0
 internal Parameter(TypeToken type, string name, ParameterModifiers modifiers, CodeLocation location, CsTokenList tokens, bool generated)
 {
     this.type = type;
     this.name = name;
     this.modifiers = modifiers;
     this.location = location;
     this.tokens = tokens;
     this.generated = generated;
 }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the Argument class.
        /// </summary>
        /// <param name="proxy">The proxy class.</param>
        /// <param name="modifiers">The parameter modifiers.</param>
        /// <param name="argumentExpression">The argument expression.</param>
        internal Argument(CodeUnitProxy proxy, ParameterModifiers modifiers, Expression argumentExpression)
            : base(proxy, CodeUnitType.Argument)
        {
            Param.AssertNotNull(proxy, "proxy");
            Param.Ignore(modifiers, "modifiers");
            Param.AssertNotNull(argumentExpression, "argumentExpression");

            this.modifiers.Value = modifiers;
            this.argumentExpression.Value = argumentExpression;
        }
Пример #8
0
 public ParameterDeclaration(string name, TypeReference type, ParameterModifiers modifiers)
 {
     this.Name = name;
     this.Type = type;
     this.Modifiers = modifiers;
 }
Пример #9
0
 public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParameterModifiers paramModifier, Expression defaultValue)
 {
 }
		protected string GetString (ParameterModifiers m)
		{
			string res;
			if (cachedParameterModifiers.TryGetValue (m, out res))
				return res;
			
			StringBuilder result = new StringBuilder ();
			foreach (ParameterModifiers singleModifier in Enum.GetValues (typeof(ParameterModifiers))) {
				if ((m & singleModifier) == singleModifier && parameterModifiers.ContainsKey (singleModifier)) {
					if (result.Length > 0)
						result.Append (' ');
					result.Append (parameterModifiers[singleModifier]);
				}
			}
			return cachedParameterModifiers [m] = result.ToString ();
		}
 public ParamModifierList(Parser parser)
 {
     this.parser = parser;
     cur         = ParameterModifiers.None;
 }
Пример #12
0
        public void CalculateChangeHandlesAllPossibleValues(ParameterModifiers oldValue, ParameterModifiers newValue)
        {
            var sut = new ParameterModifiersChangeTable();

            Action action = () => sut.CalculateChange(oldValue, newValue);

            action.Should().NotThrow();
        }
Пример #13
0
 public FormalParameter(string typeName, string parameterName, ParameterModifiers modifiers, FileSpan location)
     : this(typeName, parameterName)
 {
     this.Modifiers = modifiers;
     this.Location  = location;
 }
Пример #14
0
 public ParamModifierList(Parser parser)
 {
     this.parser = parser;
     cur         = ParameterModifiers.None;
 }
Пример #15
0
		public bool ShouldSerialize(ParameterModifiers value)
		{
			return (long)value != 0;
		}
Пример #16
0
 public bool ShouldSerialize(ParameterModifiers value)
 {
     return value != ParameterModifiers.None;
 }
Пример #17
0
 public ParameterDeclaration(string name, TypeReference type, ParameterModifiers modifiers)
 {
     this.Name      = name;
     this.Type      = type;
     this.Modifiers = modifiers;
 }
Пример #18
0
 public ParamModifierList(Parser parser)
 {
     _parser = parser;
     _cur    = ParameterModifiers.None;
 }
        /// <summary>
        /// The save.
        /// </summary>
        /// <param name="parameterModifiers">
        /// The parameter modifiers.
        /// </param>
        /// <param name="indentedTextWriter">
        /// The indented text writer.
        /// </param>
        private void Save(ParameterModifiers parameterModifiers, IndentedTextWriter indentedTextWriter)
        {
            var parameterModifiersString = string.Empty;

            switch (parameterModifiers)
            {
                case ParameterModifiers.Out:

                    // parameterModifiersString = "out ";
                    break;
                case ParameterModifiers.Params:
                    parameterModifiersString = "/*params*/ ";
                    break;
                case ParameterModifiers.Ref:

                    // parameterModifiersString = "ref ";
                    break;
                case ParameterModifiers.This:
                    parameterModifiersString = "this ";
                    break;
                case ParameterModifiers.None:
                default:
                    return;
            }

            indentedTextWriter.Write(parameterModifiersString);
        }
Пример #20
0
 public ParameterDeclaration(string name, TypeReference type, ParameterModifiers modifiers) : base(name, type, modifiers)
 {
 }
Пример #21
0
		public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParameterModifiers paramModifier, Expression defaultValue) {
			TypeReference = typeReference;
			ParameterName = parameterName;
			ParamModifier = paramModifier;
			DefaultValue = defaultValue;
			attributes = new List<AttributeSection>();
		}
        /// <summary>
        /// Initializes a new instance of the Parameter class.
        /// </summary>
        /// <param name="type">
        /// The type of the parameter.
        /// </param>
        /// <param name="name">
        /// The name of the parameter.
        /// </param>
        /// <param name="parent">
        /// The parent of the parameter.
        /// </param>
        /// <param name="modifiers">
        /// Modifiers applied to this parameter.
        /// </param>
        /// <param name="defaultArgument">
        /// The optional default argument for the parameter.
        /// </param>
        /// <param name="location">
        /// The location of the parameter in the code.
        /// </param>
        /// <param name="tokens">
        /// The tokens that form the parameter.
        /// </param>
        /// <param name="generated">
        /// Indicates whether the parameter is located within a block of generated code.
        /// </param>
        internal Parameter(
            TypeToken type, 
            string name, 
            Reference<ICodePart> parent, 
            ParameterModifiers modifiers, 
            Expression defaultArgument, 
            CodeLocation location, 
            CsTokenList tokens, 
            bool generated)
        {
            Param.Ignore(type);
            Param.AssertValidString(name, "name");
            Param.AssertNotNull(parent, "parent");
            Param.Ignore(modifiers);
            Param.Ignore(defaultArgument);
            Param.AssertNotNull(location, "location");
            Param.Ignore(tokens);
            Param.Ignore(generated);

            this.type = type;
            this.name = CodeLexer.DecodeEscapedText(name, true);
            this.parent = parent;
            this.modifiers = modifiers;
            this.defaultArgument = defaultArgument;
            this.location = location;
            this.tokens = tokens;
            this.generated = generated;
        }
Пример #23
0
 public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParameterModifiers paramModifier, Expression defaultValue)
 {
 }
Пример #24
0
		public Expression Serialize(ParameterModifiers value)
		{
			return SerializeEnum("ParameterModifiers", (long)value);
		}
        /// <summary>
        /// The save modifiers after.
        /// </summary>
        /// <param name="parameterModifiers">
        /// The parameter modifiers.
        /// </param>
        /// <param name="indentedTextWriter">
        /// The indented text writer.
        /// </param>
        private void SaveModifiersAfter(ParameterModifiers parameterModifiers, IndentedTextWriter indentedTextWriter)
        {
            var parameterModifiersString = string.Empty;

            switch (parameterModifiers)
            {
                case ParameterModifiers.Out:
                    parameterModifiersString = "&";
                    break;
                case ParameterModifiers.Params:
                    break;
                case ParameterModifiers.Ref:
                    parameterModifiersString = "&";
                    break;
                case ParameterModifiers.This:
                    break;
                case ParameterModifiers.None:
                default:
                    return;
            }

            indentedTextWriter.Write(parameterModifiersString);
        }