Example #1
0
        public override void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
        {
            node.Type?.Accept(this);
            node.Initializer?.Accept(this);

            base.VisitStackAllocArrayCreationExpression(node);
        }
        public override LuaSyntaxNode VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
        {
            var arrayType = (LuaArrayTypeAdapterExpressionSyntax)node.Type.Accept(this);

            Contract.Assert(arrayType.IsSimapleArray);
            return(new LuaInvocationExpressionSyntax(LuaIdentifierNameSyntax.StackAlloc, arrayType, arrayType.RankSpecifier.Sizes[0]));
        }
Example #3
0
        public override Evaluation VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
        {
            node.Type?.Accept <Evaluation>(this);
            node.Initializer?.Accept <Evaluation>(this);

            return(base.VisitStackAllocArrayCreationExpression(node));
        }
Example #4
0
        public override void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
        {
            /*
             *  // S *s = stackalloc S[n];
             *  IL_0007: ldarg.1
             *  IL_0008: conv.u
             *  IL_0009: sizeof MyStruct
             *  IL_000f: mul.ovf.un
             *  IL_0010: localloc
             *
             *  // int *i = stackalloc int[10];
             *  IL_0001: ldc.i4.s 40
             *  IL_0003: conv.u
             *  IL_0004: localloc
             */
            var type      = (ArrayTypeSyntax)node.Type;
            var countNode = type.RankSpecifiers[0].Sizes[0];

            if (type.RankSpecifiers.Count == 1 && countNode.IsKind(SyntaxKind.NumericLiteralExpression))
            {
                var sizeLiteral = Int32.Parse(countNode.GetFirstToken().Text) * predefinedTypeSize[type.ElementType.GetText().ToString()];

                AddCilInstruction(ilVar, OpCodes.Ldc_I4, sizeLiteral);
                AddCilInstruction(ilVar, OpCodes.Conv_U);
                AddCilInstruction(ilVar, OpCodes.Localloc);
            }
            else
            {
                countNode.Accept(this);
                AddCilInstruction(ilVar, OpCodes.Conv_U);
                AddCilInstruction(ilVar, OpCodes.Sizeof, ResolveType(type.ElementType));
                AddCilInstruction(ilVar, OpCodes.Mul_Ovf_Un);
                AddCilInstruction(ilVar, OpCodes.Localloc);
            }
        }
Example #5
0
        public override void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
        {
            TypeSyntax type = node.Type;

            if (type != null)
            {
                if (type.IsKind(SyntaxKind.ArrayType))
                {
                    VisitArrayType((ArrayTypeSyntax)type);
                }
                else
                {
                    VisitType(type);
                }
            }

            if (!ShouldVisit)
            {
                return;
            }

            InitializerExpressionSyntax initializer = node.Initializer;

            if (initializer != null)
            {
                VisitInitializerExpression(initializer);
            }
        }
 public static Doc Print(StackAllocArrayCreationExpressionSyntax node)
 {
     return(Doc.Concat(
                Token.Print(node.StackAllocKeyword, " "),
                Node.Print(node.Type),
                node.Initializer != null
             ? Doc.Concat(" ", InitializerExpression.Print(node.Initializer))
             : string.Empty
                ));
 }
Example #7
0
        public override Ust VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
        {
            var arrayTypeSyntax = (ArrayTypeSyntax)node.Type; // TODO: Fix it
            var type            = (TypeToken)base.Visit(node.Type);
            var sizes           = arrayTypeSyntax.RankSpecifiers
                                  .SelectMany(rank => rank.Sizes.Select(s => (Expression)VisitAndReturnNullIfError(s))).ToArray();

            var result = new ArrayCreationExpression(type, sizes, new Expression[0], node.GetTextSpan());

            return(result);
        }
        public static void Go(OutputWriter writer, StackAllocArrayCreationExpressionSyntax @as)
        {
            //import core.stdc.stdlib;
            //@as.Type;
            //auto ptr = cast(wchar*)alloca(wchar.sizeof * len);
            var arrayType       = TypeProcessor.GetTypeInfo(@as.Type);
            var elementType     = TypeProcessor.GetTypeInfo(((ArrayTypeSyntax)@as.Type).ElementType);
            var elementTypeName = TypeProcessor.ConvertType(elementType.Type);
            var size            = Core.WriteString(((ArrayTypeSyntax)@as.Type).RankSpecifiers[0].Sizes[0]);

            writer.Write("cast(" + elementTypeName + "*) core.stdc.stdlib.alloca(" + elementTypeName + ".sizeof * " + size + ")");
        }
        public static void Go(OutputWriter writer, StackAllocArrayCreationExpressionSyntax @as)
        {
            //import core.stdc.stdlib;
            //@as.Type;
            //auto ptr = cast(wchar*)alloca(wchar.sizeof * len);
            var arrayType = TypeProcessor.GetTypeInfo(@as.Type);
            var elementType = TypeProcessor.GetTypeInfo(((ArrayTypeSyntax) @as.Type).ElementType);
            var elementTypeName = TypeProcessor.ConvertType(elementType.Type);
            var size = Core.WriteString(((ArrayTypeSyntax)@as.Type).RankSpecifiers[0].Sizes[0]);
            writer.Write("cast("+ elementTypeName + "*) core.stdc.stdlib.alloca("+ elementTypeName + ".sizeof * "+ size + ")");

        }
Example #10
0
 private Doc PrintStackAllocArrayCreationExpressionSyntax(
     StackAllocArrayCreationExpressionSyntax node)
 {
     return(Concat(
                this.PrintSyntaxToken(node.StackAllocKeyword, " "),
                this.Print(node.Type),
                node.Initializer != null
             ? Concat(
                    " ",
                    this.PrintInitializerExpressionSyntax(node.Initializer)
                    )
             : string.Empty
                ));
 }
Example #11
0
        public override void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
        {
            if (!PreVisit(node))
            {
                return;
            }

            node.Type?.Accept(this);
            node.Initializer?.Accept(this);

            base.VisitStackAllocArrayCreationExpression(node);

            PostVisit(node);
        }
Example #12
0
 public override SyntaxNode VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
 {
     node = (StackAllocArrayCreationExpressionSyntax)base.VisitStackAllocArrayCreationExpression(node);
     Classes.Add(node);
     return(node);
 }
Example #13
0
 public override void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
 {
     throw new NotImplementedException();
 }
Example #14
0
 public TameStackAllocArrayCreationExpressionSyntax(StackAllocArrayCreationExpressionSyntax node)
 {
     Node = node;
     AddChildren();
 }
    /// <inheritdoc/>
    public override SyntaxNode?VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
    {
        Diagnostics.Add(StackAllocArrayCreationExpression, node);

        return(base.VisitStackAllocArrayCreationExpression(node));
    }
Example #16
0
 public override void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
 {
     Log(node, "Unsupported Syntax !");
 }
 public static InitializerExpressionSyntax Initializer(this StackAllocArrayCreationExpressionSyntax syntax)
 {
     return(InitializerAccessor(syntax));
 }
        /// <inheritdoc/>
        public override SyntaxNode?VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
        {
            Context.ReportDiagnostic(StackAllocArrayCreationExpression, node);

            return(base.VisitStackAllocArrayCreationExpression(node));
        }
 public override void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
 {
     VisitType(node.Type);
     //base.VisitStackAllocArrayCreationExpression(node);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
 {
     this.OnNodeVisited(node);
     if (!this.traverseRootOnly) base.VisitStackAllocArrayCreationExpression(node);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
 {
     this.OnNodeVisited(node, this.type.IsInstanceOfType(node));
     base.VisitStackAllocArrayCreationExpression(node);
 }
Example #22
0
 public override void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
 {
     ContainsUnsafe = true;
 }
 /// <inheritdoc />
 public override Expression VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
 {
     return(base.VisitStackAllocArrayCreationExpression(node));
 }
 public static StackAllocArrayCreationExpressionSyntax WithInitializer(this StackAllocArrayCreationExpressionSyntax syntax, InitializerExpressionSyntax initializer)
 {
     return(WithInitializerAccessor(syntax, initializer));
 }
Example #25
0
 public override void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node)
 {
 }
 //
 // Summary:
 //     Called when the visitor visits a StackAllocArrayCreationExpressionSyntax node.
 public virtual void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node);