Ejemplo n.º 1
0
        public override bool Visit(AstClassField node)
        {
            int[] size = null;
            if (node.TypeDef is AstIdArrayExpression)
            {
                var indexNode = (node.TypeDef as AstIdArrayExpression).Index;
                try
                {
                    size = (indexNode as AstIntegerListExpression).GetSize();
                }
                catch (OverflowException e)
                {
                    throw new ArraySizeIncorrectException(e.Message);
                }
            }

            if (size == null)
                table.EnterSymbol(node.Name.Id, node.TypeDef.Id, -1);
            else
                table.EnterSymbol(node.Name.Id, node.TypeDef.Id, size);

            return false;
        }
 public override bool Visit(AstClassField node)
 {
     ErrorIfIsNull(node.Name);
     ErrorIfIsNull(node.TypeDef);
     return true;
 }
Ejemplo n.º 3
0
        // #FIELD_DECLARATION #VISIBILITY_MODIFIER #STATIC_MODIFIER #TYPE_DEFINITION ID LINE_END
        private void ConstructFieldDeclaration()
        {
            var name = nodes.Pop() as AstIdExpression;
            var typeDef = nodes.Pop() as AstIdExpression;
            var staticModifier = nodes.Pop() as AstStaticModifier;
            var visibilityModifier = nodes.Pop() as AstVisibilityModifier;

            var fieldDeclaration = new AstClassField(visibilityModifier, staticModifier, typeDef, name);
            PushNode(fieldDeclaration);
        }
Ejemplo n.º 4
0
 public override bool Visit(AstClassField node)
 {
     var symbolTableElement = table.Lookup(node.Name.Id);
     if (Symbol.IsArray(symbolTableElement))
     {
         codeStream.WriteLine("@" + symbolTableElement.Name + " = " + GetLLVMVisibility(node.Visibility) + " global " +
             GetArrayId(symbolTableElement.Size as int[]) +
           " zeroinitializer");
     }
     else
     {
         codeStream.WriteLine("@" + node.Name.Id + " = " + GetLLVMVisibility(node.Visibility) + " global "
             + GetLLVMType(node.TypeDef.Id) + " " + GetDefaultTypeValue(node.TypeDef));
         classVariables.Add(node.Name.Id);
     }
     return false;
 }
 public override bool Visit(AstClassField node)
 {
     return true;
 }
Ejemplo n.º 6
0
        public override bool Visit(AstClassField node)
        {
            var type = node.TypeDef;

            if (type is AstIdArrayExpression)
            {
                isClassFieldDef = true;
                (type as AstIdArrayExpression).Accept(this);
                isClassFieldDef = false;
            }

            return false;
        }
Ejemplo n.º 7
0
 public abstract bool Visit(AstClassField node);