public void AddFormalParameter(FormalParameter formalParameter)
 {
     if (formalParameter != null)
     {
         ((List <FormalParameter>) this.Parameters).Add(formalParameter);
     }
 }
Esempio n. 2
0
 //private string typeParametersAsString(IEnumerable<string> typeParameters)
 //{
 //    string typeParamsAsStr = String.Join(",", typeParameters);
 //    return "(" + typeParamsAsStr + ")";
 //}
 public string SpokenText(FormalParameter formalParameter)
 {
     if ( formalParameter == null)
     {
         return String.Empty;
     }
     return formalParameter.ParameterName + $" {rm.GetString("AtLine", CultureInfo.CurrentCulture)} " + formalParameter.Location.StartLineNumber;
 }
Esempio n. 3
0
        //private string typeParametersAsString(IEnumerable<string> typeParameters)
        //{
        //    string typeParamsAsStr = String.Join(",", typeParameters);
        //    return "<" + typeParamsAsStr + ">";
        //}

        //private string formalParametersAsString(IEnumerable<FormalParameter> formalParameters)
        //{
        //    string formalParametersAsStr = String.Join(",", formalParameters.Select(fp => SpokenText(fp)));
        //    return "(" + formalParametersAsStr + ")";

        //}

        public string SpokenText(FormalParameter formalParameter)
        {
            if (formalParameter == null)
            {
                return(String.Empty);
            }
            string formalParameterAsStr = formalParameter.Modifiers + " " + formalParameter.TypeName + " " + formalParameter.ParameterName;

            return(formalParameterAsStr + $" {rm.GetString("AtLine", CultureInfo.CurrentCulture)} " + formalParameter.Location.StartLineNumber);
        }
Esempio n. 4
0
        public override void VisitParameter(ParameterSyntax node)
        {
            FormalParameter fp = CSharpEntityCreationHelper.CreateFormalParameter(node);

            if (m_currentParent.GetType() == typeof(FunctionDefinition))
            {
                (m_currentParent as FunctionDefinition).AddFormalParameter(fp);
            }
            else if (m_currentParent.GetType() == typeof(MemberProperty))
            {
                (m_currentParent as MemberProperty).SoleParameter = fp;
            }
            else
            {
                String msg = String.Format(CultureInfo.InvariantCulture, "Cannot process parameter if parent is: {0} [{1}]", m_currentParent.Kind, m_currentParent.Name);
                throw new InvalidOperationException(msg);
            }
            base.VisitParameter(node);
        }
Esempio n. 5
0
        internal static FormalParameter CreateFormalParameter(ParameterSyntax node)
        {
            FormalParameter fp = new FormalParameter(node.Type != null ? node.Type.ToFullString().Trim() : String.Empty, node.Identifier.Text);

            foreach (var modifier in node.Modifiers)
            {
                switch (modifier.Kind())
                {
                case SyntaxKind.InKeyword:
                    fp.Modifiers |= ParameterModifiers.In;
                    break;

                case SyntaxKind.OutKeyword:
                    fp.Modifiers |= ParameterModifiers.Out;
                    break;

                case SyntaxKind.RefKeyword:
                    fp.Modifiers |= ParameterModifiers.Ref;
                    break;

                case SyntaxKind.ParamsKeyword:
                    fp.Modifiers |= ParameterModifiers.Params;
                    break;

                case SyntaxKind.ThisKeyword:
                    fp.Modifiers |= ParameterModifiers.This;
                    break;

                default:
                    throw new NotSupportedException(String.Format(CultureInfo.InvariantCulture, "Unable to process keyword {0} in parameter declaration {1}", modifier, node.ToString()));
                }
            }
            if (node.Default != null)
            {
                fp.DefaultValue = node.Default.Value.ToString();
            }

            return(fp);
        }
Esempio n. 6
0
 public string SpokenText(FormalParameter formalParameter)
 {
     return(m_language.SpokenText(formalParameter));
 }