Esempio n. 1
0
 private void ObserveSignalDeclaration(VHDLCompilerInterface compiler, SignalDeclaration item)
 {
     if (item.Objects.Count != 0)
     {
         signalNames = new List <string>();
         foreach (VHDL.Object.Signal v in item.Objects)
         {
             SignalDeclarationObserver varObserver = new SignalDeclarationObserver(v, logger);
             varObserver.Observe(compiler);
             declarationText += varObserver.DeclarationText;
             signalNames.Add(v.Identifier);
         }
     }
 }
Esempio n. 2
0
        //TODO: check if default values are equal
        //TODO: check if types match
        protected override void visitSignalDeclaration(SignalDeclaration declaration)
        {
            Signal signal = declaration.Objects[0];

            writer.Append(KeywordEnum.SIGNAL.ToString()).Append(' ');
            writer.AppendIdentifiers(declaration.Objects,", ");
            writer.Append(" : ");
            output.writeSubtypeIndication(signal.Type);
            if (signal.Kind != Signal.KindEnum.DEFAULT)
            {
                writer.Append(' ').Append(signal.Kind.ToString());
            }
            if (signal.DefaultValue != null)
            {
                writer.Append(" := ");
                output.writeExpression(signal.DefaultValue);
            }
            writer.Append(";").NewLine();
        }
Esempio n. 3
0
            public List <object> GetLocalListOfObjects()
            {
                List <object> res = new List <object>();

                foreach (E declaration in this)
                {
                    if (declaration is EnumerationType)
                    {
                        EnumerationType type = declaration as EnumerationType;
                        res.Add(type);


                        //TODO: support overloading
                        foreach (EnumerationLiteral literal in type.Literals)
                        {
                            res.Add(literal);
                        }
                    }
                    else if (declaration is RecordType)
                    {
                        RecordType type = declaration as RecordType;
                        res.Add(type);
                        foreach (VHDL.type.RecordType.ElementDeclaration el in type.Elements)
                        {
                            foreach (string name in el.Identifiers)
                            {
                                res.Add(name);
                            }
                        }
                    }
                    else if (declaration is PhysicalType)
                    {
                        PhysicalType type = declaration as PhysicalType;
                        res.Add(type);
                        res.Add(new PhysicalLiteral(null, type.PrimaryUnit, declaration as PhysicalType));

                        foreach (PhysicalType.Unit unit in type.Units)
                        {
                            res.Add(unit.Identifier);
                        }
                    }
                    else if (declaration is NamedEntity)
                    {
                        INamedEntity identElement = (NamedEntity)declaration;
                        res.Add(declaration);
                    }
                    else if (declaration is SignalDeclaration)
                    {
                        SignalDeclaration objDecl = declaration as SignalDeclaration;
                        foreach (var o in objDecl.Objects)
                        {
                            res.Add(o);
                        }
                    }
                    else if (declaration is ConstantDeclaration)
                    {
                        ConstantDeclaration objDecl = declaration as ConstantDeclaration;
                        foreach (var o in objDecl.Objects)
                        {
                            res.Add(o);
                        }
                    }
                    else if (declaration is VariableDeclaration)
                    {
                        VariableDeclaration objDecl = declaration as VariableDeclaration;
                        foreach (var o in objDecl.Objects)
                        {
                            res.Add(o);
                        }
                    }
                    else if (declaration is FileDeclaration)
                    {
                        FileDeclaration objDecl = declaration as FileDeclaration;
                        foreach (var o in objDecl.Objects)
                        {
                            res.Add(o);
                        }
                    }
                    else if (declaration is Alias)
                    {
                        res.Add(declaration);
                    }
                    else if (declaration is Subtype)
                    {
                        res.Add(declaration);
                    }
                    else if (declaration is UseClause)
                    {
                        UseClause use = declaration as UseClause;
                        res.AddRange(use.Scope.GetLocalListOfObjects());
                    }
                    else if (declaration.GetType().BaseType == typeof(ObjectDeclaration <>))
                    {
                        ObjectDeclaration <VhdlObject> objDecl = declaration as ObjectDeclaration <VhdlObject>;
                        foreach (VhdlObject o in objDecl.Objects)
                        {
                            res.Add(o);
                        }
                    }
                }
                return(res);
            }
Esempio n. 4
0
            public object Resolve(string identifier)
            {
                foreach (E declaration in this)
                {
                    if (declaration is EnumerationType)
                    {
                        EnumerationType type = declaration as EnumerationType;
                        if (identifier.EqualsIdentifier(type.Identifier))
                        {
                            return(type);
                        }

                        //TODO: support overloading
                        foreach (EnumerationLiteral literal in type.Literals)
                        {
                            if (identifier.EqualsIdentifier(literal.ToString()))
                            {
                                return(literal);
                            }
                        }
                    }
                    else if (declaration is RecordType)
                    {
                        RecordType type = declaration as RecordType;
                        if (identifier.EqualsIdentifier(type.Identifier))
                        {
                            return(type);
                        }
                        foreach (VHDL.type.RecordType.ElementDeclaration el in type.Elements)
                        {
                            foreach (string name in el.Identifiers)
                            {
                                if (identifier.EqualsIdentifier(name))
                                {
                                    return(new Variable(name, el.Type));
                                }
                            }
                        }
                    }
                    else if (declaration is PhysicalType)
                    {
                        PhysicalType type = declaration as PhysicalType;
                        if (identifier.EqualsIdentifier(type.Identifier))
                        {
                            return(type);
                        }

                        //TODO: don't use strings for the physical literals
                        if (identifier.EqualsIdentifier(type.PrimaryUnit))
                        {
                            return(new PhysicalLiteral(null, type.PrimaryUnit, declaration as PhysicalType));
                        }

                        foreach (PhysicalType.Unit unit in type.Units)
                        {
                            if (identifier.EqualsIdentifier(unit.Identifier))
                            {
                                return(new PhysicalLiteral(null, unit.Identifier, declaration as PhysicalType));
                            }
                        }
                    }
                    else if (declaration is NamedEntity)
                    {
                        INamedEntity identElement = (NamedEntity)declaration;
                        if (identifier.EqualsIdentifier(identElement.Identifier))
                        {
                            return(declaration);
                        }
                    }
                    else if (declaration is SignalDeclaration)
                    {
                        SignalDeclaration objDecl = declaration as SignalDeclaration;
                        foreach (var o in objDecl.Objects)
                        {
                            if (o.Identifier.EqualsIdentifier(identifier))
                            {
                                return(o);
                            }
                        }
                    }
                    else if (declaration is ConstantDeclaration)
                    {
                        ConstantDeclaration objDecl = declaration as ConstantDeclaration;
                        foreach (var o in objDecl.Objects)
                        {
                            if (o.Identifier.EqualsIdentifier(identifier))
                            {
                                return(o);
                            }
                        }
                    }
                    else if (declaration is VariableDeclaration)
                    {
                        VariableDeclaration objDecl = declaration as VariableDeclaration;
                        foreach (var o in objDecl.Objects)
                        {
                            if (o.Identifier.EqualsIdentifier(identifier))
                            {
                                return(o);
                            }
                        }
                    }
                    else if (declaration is FileDeclaration)
                    {
                        FileDeclaration objDecl = declaration as FileDeclaration;
                        foreach (var o in objDecl.Objects)
                        {
                            if (o.Identifier.EqualsIdentifier(identifier))
                            {
                                return(o);
                            }
                        }
                    }
                    else if (declaration is Alias)
                    {
                        Alias objDecl = declaration as Alias;
                        if (objDecl.Designator.EqualsIdentifier(identifier))
                        {
                            return(objDecl.Aliased);//new Variable(objDecl.Aliased, objDecl.SubtypeIndication);
                        }
                    }
                    else if (declaration is Subtype)
                    {
                        Subtype objDecl = declaration as Subtype;
                        if (objDecl.Identifier.EqualsIdentifier(identifier))
                        {
                            return(objDecl);
                        }
                    }
                    else if (declaration is UseClause)
                    {
                        UseClause use = declaration as UseClause;
                        object    res = use.Scope.resolve(identifier);
                        if (res != null)
                        {
                            return(res);
                        }
                    }
                    else if (declaration.GetType().BaseType == typeof(ObjectDeclaration <>))
                    {
                        ObjectDeclaration <VhdlObject> objDecl = declaration as ObjectDeclaration <VhdlObject>;
                        foreach (VhdlObject o in objDecl.Objects)
                        {
                            if (o.Identifier.EqualsIdentifier(identifier))
                            {
                                return(o);
                            }
                        }
                    }
                }

                return(null);
            }