Ejemplo n.º 1
0
        private TypeSyntax voStructMemberDataType(XP.VostructmemberContext context)
        {
            var varType = context.DataType?.Get <TypeSyntax>() ?? MissingType();

            if (context.DataType is XP.SimpleDatatypeContext)
            {
                var sdt = context.DataType as XP.SimpleDatatypeContext;
                if (sdt.TypeName.NativeType != null)
                {
                    if (sdt.TypeName.NativeType.Token.Type == XP.LOGIC)
                    {
                        varType = GenerateQualifiedName(_winBoolType);
                    }
                }
            }
            return(varType);
        }
Ejemplo n.º 2
0
        public override void ExitVostructmember([NotNull] XP.VostructmemberContext context)
        {
            bool isDim         = context.Dim != null;
            bool isUnionMember = (context.Parent is XP.VounionContext);
            var  varType       = voStructMemberDataType(context);

            varType.XVoDecl = true;
            if (context.As?.Type == XP.IS)
            {
                varType.XVoIsDecl = true;
            }
            if (isDim)
            {
                voStructHasDim = true;
            }

            SyntaxList <AttributeListSyntax> atts = null;

            if (isUnionMember)
            {
                var args = MakeSeparatedList(
                    _syntaxFactory.AttributeArgument(null, null,
                                                     GenerateLiteral("0", 0)));
                var arglist = MakeAttributeArgumentList(args);
                var att     = MakeSeparatedList(
                    _syntaxFactory.Attribute(
                        name: GenerateQualifiedName(SystemQualifiedNames.FieldOffset),
                        argumentList: arglist));
                atts = MakeAttributeList(null, att);
            }
            else
            {
                atts = EmptyList <AttributeListSyntax>();
            }
            context.Put(_syntaxFactory.FieldDeclaration(
                            atts,
                            TokenList(SyntaxKind.PublicKeyword, isDim ? SyntaxKind.FixedKeyword : SyntaxKind.None),
                            _syntaxFactory.VariableDeclaration(varType,
                                                               MakeSeparatedList(
                                                                   isDim ? GenerateBuffer(context.Id.Get <SyntaxToken>(), MakeBracketedArgumentList(context.ArraySub._ArrayIndex.Select(e => _syntaxFactory.Argument(null, null, e.Get <ExpressionSyntax>())).ToArray()))
                        : GenerateVariable(context.Id.Get <SyntaxToken>()))),
                            SyntaxFactory.MakeToken(SyntaxKind.SemicolonToken)));
        }