Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpType"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly type from which the C# type is created.</param>
        /// <param name="originatingTypedef">The typedef where this type is declared.</param>
        protected CSharpType(ICSharpContext context, ICompiledType source, ICSharpTypedef originatingTypedef)
        {
            Debug.Assert(source != null);
            Debug.Assert(originatingTypedef != null);

            Source             = source;
            OriginatingTypedef = originatingTypedef;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CSharpProcedureType"/> class.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly type from which the C# type is created.</param>
        /// <param name="originatingTypedef">The typedef where this type is declared.</param>
        protected CSharpProcedureType(ICSharpContext context, IProcedureType source, ICSharpTypedef originatingTypedef)
            : base(context, source, originatingTypedef)
        {
            Debug.Assert(source.OverloadList.Count > 0);

            ICSharpClass Owner = context.GetClass(source.EmbeddingClass);

            BaseType = Create(context, source.ResolvedBaseType.Item) as ICSharpTypeWithFeature;
            Debug.Assert(BaseType != null);

            foreach (ICommandOverloadType OverloadType in source.OverloadList)
            {
                ICSharpCommandOverloadType NewOverloadType = CSharpCommandOverloadType.Create(context, OverloadType, Owner);
                OverloadTypeList.Add(NewOverloadType);
            }
        }
Example #3
0
 /// <summary>
 /// Create a new C# type.
 /// </summary>
 /// <param name="context">The creation context.</param>
 /// <param name="source">The Easly type from which the C# type is created.</param>
 /// <param name="originatingTypedef">The typedef where this type is declared.</param>
 public static ICSharpProcedureType Create(ICSharpContext context, IProcedureType source, ICSharpTypedef originatingTypedef)
 {
     return(new CSharpProcedureType(context, source, originatingTypedef));
 }
Example #4
0
        /// <summary>
        /// Creates a new C# type associated to a typedef.
        /// </summary>
        /// <param name="context">The creation context.</param>
        /// <param name="source">The Easly type from which the C# type is created.</param>
        /// <param name="typedef">The typedef.</param>
        public static ICSharpType Create(ICSharpContext context, ICompiledType source, ICSharpTypedef typedef)
        {
            ICSharpType Result = null;

            switch (source)
            {
            case IClassType AsClassType:
                Result = CSharpClassType.Create(context, AsClassType);
                break;

            case IFormalGenericType AsFormalGenericType:
                Result = CSharpFormalGenericType.Create(context, AsFormalGenericType);
                break;

            case IFunctionType AsFunctionType:
                Result = CSharpFunctionType.Create(context, AsFunctionType, typedef);
                break;

            case IProcedureType AsProcedureType:
                Result = CSharpProcedureType.Create(context, AsProcedureType, typedef);
                break;

            case IIndexerType AsIndexerType:
                Result = CSharpIndexerType.Create(context, AsIndexerType);
                break;

            case IPropertyType AsPropertyType:
                Result = CSharpPropertyType.Create(context, AsPropertyType);
                break;

            case ITupleType AsTupleType:
                Result = CSharpTupleType.Create(context, AsTupleType);
                break;
            }

            Debug.Assert(Result != null);

            return(Result);
        }
 /// <summary>
 /// Create a new C# type.
 /// </summary>
 /// <param name="context">The creation context.</param>
 /// <param name="source">The Easly type from which the C# type is created.</param>
 /// <param name="originatingTypedef">The typedef where this type is declared.</param>
 public static ICSharpFunctionType Create(ICSharpContext context, IFunctionType source, ICSharpTypedef originatingTypedef)
 {
     return(new CSharpFunctionType(context, source, originatingTypedef));
 }