Пример #1
0
        /// <summary>
        /// Initializes the C# generic.
        /// </summary>
        /// <param name="context">The creation context.</param>
        public void Init(ICSharpContext context)
        {
            foreach (IConstraint Constraint in Source.ConstraintList)
            {
                ICSharpConstraint NewConstraint = CSharpConstraint.Create(context, Constraint);
                ConstraintList.Add(NewConstraint);
            }

            // Create the type after constraints have been listed.
            Type = CSharpFormalGenericType.Create(context, Source.ResolvedGenericType.Item);
        }
Пример #2
0
        /// <summary>
        /// Creates 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>
        public static ICSharpType Create(ICSharpContext context, ICompiledType source)
        {
            ICSharpType Result = null;

            // A typedef is required for IFunctionType and IProcedureType.
            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);
                break;

            case IProcedureType AsProcedureType:
                Result = CSharpProcedureType.Create(context, AsProcedureType);
                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);
        }