Ejemplo n.º 1
0
        public static UnboundReferences ParseBimlFiles(IEnumerable <BimlFile> bimlFiles, ISymbolTableProvider astRootNode, LanguageSettings languageSettings)
        {
            var unboundReferences = new UnboundReferences();

            foreach (BimlFile bimlFile in bimlFiles)
            {
                var xdocument = bimlFile.XDocument;
                if (xdocument != null && xdocument.Root != null)
                {
                    try
                    {
                        SideEffectManager.SideEffectMode = AstSideEffectMode.NoSideEffects;
                        ParseDocument(bimlFile, astRootNode, unboundReferences, languageSettings);
                        SideEffectManager.SideEffectMode = AstSideEffectMode.ConsistencySideEffects;

                        bimlFile.IsParseable = true;
                    }
                    catch (Exception)
                    {
                        bimlFile.IsParseable = false;
                    }
                }
            }

            unboundReferences.ResolveAll(astRootNode.SymbolTable);
            return(unboundReferences);
        }
Ejemplo n.º 2
0
        public static UnboundReferences ParseBimlFiles(IEnumerable<BimlFile> bimlFiles, ISymbolTableProvider astRootNode, LanguageSettings languageSettings)
        {
            var unboundReferences = new UnboundReferences();
            foreach (BimlFile bimlFile in bimlFiles)
            {
                var xdocument = bimlFile.XDocument;
                if (xdocument != null && xdocument.Root != null)
                {
                    try
                    {
                        SideEffectManager.SideEffectMode = AstSideEffectMode.NoSideEffects;
                        ParseDocument(bimlFile, astRootNode, unboundReferences, languageSettings);
                        SideEffectManager.SideEffectMode = AstSideEffectMode.ConsistencySideEffects;

                        bimlFile.IsParseable = true;
                    }
                    catch (Exception)
                    {
                        bimlFile.IsParseable = false;
                    }
                }
            }

            unboundReferences.ResolveAll(astRootNode.SymbolTable);
            return unboundReferences;
        }
Ejemplo n.º 3
0
        public IIR Execute(IIR predecessorIR)
        {
            var xmlIR = predecessorIR as XmlIR;

            if (xmlIR == null)
            {
                // Message.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, PredecessorIR.GetType().ToString(), this.Name);
            }

            var astIR = new AstIR(xmlIR)
            {
                AstRootNode = new AstRootNode(null)
            };

            var unboundReferences = new UnboundReferences();
            var languageSettings  = new LanguageSettings(_defaultXmlNamespace, typeof(AstNode));

            foreach (BimlFile bimlFile in astIR.BimlFiles)
            {
                if (bimlFile.XDocument.Root != null)
                {
                    AstParser.ParseDocument(bimlFile, astIR.AstRootNode, unboundReferences, languageSettings);
                }
            }

            unboundReferences.ResolveAll(astIR.AstRootNode.SymbolTable);
            CompileTimeResolver.ResolveAll(astIR.AstRootNode.SymbolTable, unboundReferences);

            if (unboundReferences.Count > 0)
            {
                foreach (var unboundReference in unboundReferences)
                {
                    string filename            = unboundReference.BimlFile.Name;
                    string refName             = unboundReference.XValue;
                    string refTypeFriendlyName = unboundReference.BoundProperty.PropertyType.Name;
                    string xml           = unboundReference.XObject.ToString();
                    int    line          = ((IXmlLineInfo)unboundReference.XObject).LineNumber;
                    int    offset        = ((IXmlLineInfo)unboundReference.XObject).LinePosition;
                    var    friendlyNames = (FriendlyNameAttribute[])unboundReference.BoundProperty.PropertyType.GetCustomAttributes(typeof(FriendlyNameAttribute), false);
                    if (friendlyNames != null && friendlyNames.Length > 0)
                    {
                        refTypeFriendlyName = friendlyNames[0].FriendlyName;
                    }

                    // TODO: Fatal Error
                    MessageEngine.Trace(filename, line, offset, Severity.Error, "V0101", null, "Could not resolve reference to '{0}' of type '{1}'. '{2}' is invalid.", refName, refTypeFriendlyName, xml);
                }

                throw new InvalidOperationException("Parsing was unsuccessful.");
            }

            return(astIR);
        }
Ejemplo n.º 4
0
        public IIR Execute(IIR predecessorIR)
        {
            var xmlIR = predecessorIR as XmlIR;
            if (xmlIR == null)
            {
                // Message.Trace(Severity.Error, Resources.ErrorPhaseWorkflowIncorrectInputIRType, PredecessorIR.GetType().ToString(), this.Name);
            }

            var astIR = new AstIR(xmlIR) { AstRootNode = new AstRootNode(null) };

            var unboundReferences = new UnboundReferences();
            var languageSettings = new LanguageSettings(_defaultXmlNamespace, typeof(AstNode));
            foreach (BimlFile bimlFile in astIR.BimlFiles)
            {
                if (bimlFile.XDocument.Root != null)
                {
                    AstParser.ParseDocument(bimlFile, astIR.AstRootNode, unboundReferences, languageSettings);
                }
            }

            unboundReferences.ResolveAll(astIR.AstRootNode.SymbolTable);
            CompileTimeResolver.ResolveAll(astIR.AstRootNode.SymbolTable, unboundReferences);

            if (unboundReferences.Count > 0)
            {
                foreach (var unboundReference in unboundReferences)
                {
                    string filename = unboundReference.BimlFile.Name;
                    string refName = unboundReference.XValue;
                    string refTypeFriendlyName = unboundReference.BoundProperty.PropertyType.Name;
                    string xml = unboundReference.XObject.ToString();
                    int line = ((IXmlLineInfo)unboundReference.XObject).LineNumber;
                    int offset = ((IXmlLineInfo)unboundReference.XObject).LinePosition;
                    var friendlyNames = (FriendlyNameAttribute[])unboundReference.BoundProperty.PropertyType.GetCustomAttributes(typeof(FriendlyNameAttribute), false);
                    if (friendlyNames != null && friendlyNames.Length > 0)
                    {
                        refTypeFriendlyName = friendlyNames[0].FriendlyName;
                    }

                    // TODO: Fatal Error
                    MessageEngine.Trace(filename, line, offset, Severity.Error, "V0101", null, "Could not resolve reference to '{0}' of type '{1}'. '{2}' is invalid.", refName, refTypeFriendlyName, xml);
                }

                throw new InvalidOperationException("Parsing was unsuccessful.");
            }

            return astIR;
        }
Ejemplo n.º 5
0
 private static void ResolveUnboundReferences(SymbolTable symbolTable, UnboundReferences unboundReferences)
 {
     unboundReferences.ResolveAll(symbolTable);
 }