Exemplo n.º 1
0
        private static ValueType Resolve(Package containingPackage, ValueTypeSyntax syntax, IReadOnlyDictionary <SyntaxNode, Binder> binders)
        {
            return(syntax.Match().Returning <ValueType>()
                   .With <PredefinedTypeSyntax>(type =>
            {
                switch (type.Name.Text)
                {
                case "void":
                    return new VoidType(type, containingPackage);

                case "string":
                    return new StringType(type, containingPackage);

                case "byte":
                    return new IntType(type, containingPackage, 8, false);

                default:
                    var text = type.Name.Text;
                    if (text.StartsWith("int"))
                    {
                        return new IntType(type, containingPackage, ParseBitLength(text.Substring("int".Length)), true);
                    }
                    if (text.StartsWith("uint"))
                    {
                        return new IntType(type, containingPackage, ParseBitLength(text.Substring("int".Length)), true);
                    }

                    throw new NotImplementedException($"Primitive type {text} not implemented");
                }
            })
                   .Exhaustive());
        }
        public ReferenceTypeSyntax(bool? isOwned, bool isMutable, ValueTypeSyntax type)
        {
            Requires.NotNull(type, nameof(type));

            IsOwned = isOwned;
            IsMutable = isMutable;
            Type = type;
        }
        public ReferenceTypeSyntax(bool?isOwned, bool isMutable, ValueTypeSyntax type)
        {
            Requires.NotNull(type, nameof(type));

            IsOwned   = isOwned;
            IsMutable = isMutable;
            Type      = type;
        }
Exemplo n.º 4
0
        public NewAnonymousObjectSyntax(ValueTypeSyntax baseClass, IEnumerable <ValueTypeSyntax> interfaces, IEnumerable <ExpressionSyntax> arguments, IEnumerable <ClassMemberSyntax> members)
        {
            Requires.NotNull(baseClass, nameof(baseClass));

            BaseClass  = baseClass;
            Interfaces = interfaces.ToList();
            Arguments  = arguments.ToList();
            Members    = members.ToList();
        }
        public NewAnonymousObjectSyntax(ValueTypeSyntax baseClass, IEnumerable<ValueTypeSyntax> interfaces, IEnumerable<ExpressionSyntax> arguments, IEnumerable<ClassMemberSyntax> members)
        {
            Requires.NotNull(baseClass, nameof(baseClass));

            BaseClass = baseClass;
            Interfaces = interfaces.ToList();
            Arguments = arguments.ToList();
            Members = members.ToList();
        }
 public CastSyntax(ExpressionSyntax expression, CastType castType, ValueTypeSyntax type)
 {
     Expression = expression;
     CastType = castType;
     Type = type;
 }
        private static ValueType Resolve(Package containingPackage, ValueTypeSyntax syntax, IReadOnlyDictionary<SyntaxNode, Binder> binders)
        {
            return syntax.Match().Returning<ValueType>()
                .With<PredefinedTypeSyntax>(type =>
                {
                    switch(type.Name.Text)
                    {
                        case "void":
                            return new VoidType(type, containingPackage);
                        case "string":
                            return new StringType(type, containingPackage);
                        case "byte":
                            return new IntType(type, containingPackage, 8, false);
                        default:
                            var text = type.Name.Text;
                            if(text.StartsWith("int"))
                                return new IntType(type, containingPackage, ParseBitLength(text.Substring("int".Length)), true);
                            if(text.StartsWith("uint"))
                                return new IntType(type, containingPackage, ParseBitLength(text.Substring("int".Length)), true);

                            throw new NotImplementedException($"Primitive type {text} not implemented");
                    }
                })
                .Exhaustive();
        }
 public virtual void VisitValueType(ValueTypeSyntax node)
 {
 }
Exemplo n.º 9
0
 public CastSyntax(ExpressionSyntax expression, CastType castType, ValueTypeSyntax type)
 {
     Expression = expression;
     CastType   = castType;
     Type       = type;
 }
Exemplo n.º 10
0
 protected ValueType(ValueTypeSyntax syntax, Package containingPackage)
     : base(syntax, containingPackage)
 {
 }
Exemplo n.º 11
0
 private static TypeSymbol BindValueType(ValueTypeSyntax syntax, bool isReadOnly)
 {
     return(ValueTypeSymbol.FromString(syntax.TypeName.ToString()));
 }
 protected ValueType(ValueTypeSyntax syntax, Package containingPackage)
     : base(syntax, containingPackage)
 {
 }