コード例 #1
0
        public SLFunc(Visibility vis, FunctionKind funcKind, SLType type, SLIdentifier name, SLParameterList parms, SLCodeBlock body, bool isOptional = false)
        {
            GenericParams = new SLGenericTypeDeclarationCollection();
            Visibility    = vis;
            ReturnType    = type;
            bool isConstructor = (funcKind & FunctionKind.Constructor) != 0;

            Name          = isConstructor ? new SLIdentifier(isOptional ? "init?" : "init") : Exceptions.ThrowOnNull(name, nameof(name));
            Parameters    = parms ?? new SLParameterList();
            Body          = Exceptions.ThrowOnNull(body, nameof(body));
            FuncKind      = funcKind;
            IsConstructor = isConstructor;
            IsOptional    = isOptional;
        }
コード例 #2
0
        public SLClass(Visibility vis, SLIdentifier name, IEnumerable <SLFunc> methods = null,
                       bool isStatic = false, bool isSealed = false, NamedType namedType = NamedType.Class)
        {
            // swift hates when you put public on an extension on a public type
            Visibility   = vis == Visibility.Public && namedType == NamedType.Extension ? Visibility.None : vis;
            IsStatic     = isStatic;
            IsSealed     = isSealed;
            NamedType    = namedType;
            Name         = Exceptions.ThrowOnNull(name, "name");
            Inheritance  = new SLInheritance();
            Fields       = new List <ICodeElement> ();
            Constructors = new List <SLFunc> ();
            Methods      = new List <SLFunc> ();
            Properties   = new List <SLProperty> ();
            InnerClasses = new SLClasses();
            Subscripts   = new List <SLSubscript> ();
            Generics     = new SLGenericTypeDeclarationCollection();

            if (methods != null)
            {
                Methods.AddRange(methods);
            }
        }