Exemple #1
0
        private void AddDataMembers(string parentNodeName, AstStructure structure)
        {
            var dict = structure.GroupDataMembersByType();

            foreach (var pair in dict)
            {
                var nodeName = Graph.NewNodeName();

                Graph
                .AddNode(nodeName)
                .SetLabel(
                    Graph.Table(
                        Graph.SelectIconName(pair.Key),
                        Graph.SimpleTable(pair.Key.GMacTypeSignature, "Structure Members"),
                        pair.Value.Select(item => item.Name)
                        )
                    )
                .AddEdgeFrom(parentNodeName);

                if (pair.Key.IsValidStructureType)
                {
                    AddDataMembers(nodeName, pair.Key.ToStructure);
                }

                else if (pair.Key.IsValidMultivectorType)
                {
                    AddMultivectorCoefs(nodeName, pair.Key.ToFrameMultivector);
                }
            }
        }
        public string Visit(AstStructure item)
        {
            var composer = CreateColumnsComposer();

            composer
            .AppendToColumns("Structure Name:", item.AccessName)
            .AppendEmptyStringsToColumns()
            .AppendToColumns(
                "Data Members:",
                item
                    .DataMembers
                    .Select(t => t.AccessName + " : " + t.GMacTypeSignature)
                    .Concatenate(Environment.NewLine)
                )
            .AppendEmptyStringsToColumns()
            .AppendToColumns(
                "Types this structure depends on:",
                _typeDepGraph
                .GetAllUsedItems(item.GMacType)
                .Select(d => d.BaseItem.GMacTypeSignature)
                .Concatenate(Environment.NewLine)
                )
            .AppendEmptyStringsToColumns()
            .AppendToColumns(
                "Types depending on this structure:",
                _typeDepGraph
                .GetAllUserItems(item.GMacType)
                .Select(d => d.BaseItem.GMacTypeSignature)
                .Concatenate(Environment.NewLine)
                );

            return composer.GenerateText();
        }
Exemple #3
0
        public static DotGraph ToDependenciesGraphViz(this AstStructure astStruct)
        {
            var visitor = new TypeDependenciesToGraphViz();

            visitor.Visit(astStruct.GMacType);

            return(visitor.Graph);
        }
Exemple #4
0
        public static DotGraph ToGraphViz(this AstStructure structure)
        {
            var visitor = new StructureToGraphViz();

            structure.AcceptVisitor(visitor);

            return(visitor.Graph);
        }
Exemple #5
0
        public TreeNode Visit(AstStructure item)
        {
            var node = new TreeNode(item.Name)
            {
                Tag              = item,
                ImageKey         = @"Structure64.png",
                SelectedImageKey = @"Structure64.png"
            };

            return(node);
        }
Exemple #6
0
        public void Visit(AstStructure structure)
        {
            Graph
            .AddNode(structure.AccessName)
            .SetLabel(
                Graph.Table(
                    "Structure",
                    structure.AccessName
                    )
                );

            AddDataMembers(structure.AccessName, structure);
        }
Exemple #7
0
        private void GenerateStructureCode(AstStructure structureInfo)
        {
            CodeFilesComposer.InitalizeFile(structureInfo.Name + ".cs", GenerateCodeFileStartCode);

            ActiveFileTextComposer.AppendAtNewLine(@"public sealed class ");
            ActiveFileTextComposer.AppendLine(structureInfo.Name);
            ActiveFileTextComposer.AppendLineAtNewLine("{");
            ActiveFileTextComposer.IncreaseIndentation();

            foreach (var memberInfo in structureInfo.DataMembers)
            {
                ActiveFileTextComposer.AppendAtNewLine("public ");
                GenerateTypeName(memberInfo.GMacType);
                ActiveFileTextComposer.Append(" ");
                ActiveFileTextComposer.Append(memberInfo.Name);
                ActiveFileTextComposer.AppendLine(" { get; set; }");
                ActiveFileTextComposer.AppendLine();
            }

            ActiveFileTextComposer.AppendLine();

            ActiveFileTextComposer.AppendAtNewLine("public ");
            ActiveFileTextComposer.Append(structureInfo.Name);
            ActiveFileTextComposer.AppendLine("()");
            ActiveFileTextComposer.Append("{");
            ActiveFileTextComposer.IncreaseIndentation();

            foreach (var memberInfo in structureInfo.DataMembers.Where(memberInfo => !memberInfo.GMacType.IsValidPrimitiveType))
            {
                ActiveFileTextComposer.AppendAtNewLine(memberInfo.Name);
                ActiveFileTextComposer.Append(" = ");
                GenerateTypeDefaultValue(memberInfo.GMacType);
                ActiveFileTextComposer.AppendLine(";");
            }

            ActiveFileTextComposer.DecreaseIndentation();
            ActiveFileTextComposer.Append("}");

            ActiveFileTextComposer.DecreaseIndentation();
            ActiveFileTextComposer.AppendLineAtNewLine("}");

            CodeFilesComposer.UnselectActiveFile(GenerateCodeFileEndCode);
        }
Exemple #8
0
        public AstStructure CompileStructure(string codeText)
        {
            if (InitializeCompiler(codeText, GMacSourceParser.ParseStructure, RefResContext) == false)
            {
                this.ReportNormal(
                    "Initializing Compile Temp Structure",
                    codeText,
                    ProgressEventArgsResult.Failure
                    );

                return(null);
            }

            this.ReportNormal(
                "Initializing Compile Temp Structure",
                codeText,
                ProgressEventArgsResult.Success
                );

            try
            {
                var compiledSymbol =
                    new AstStructure(GMacStructureGenerator.Translate(Context, RootParseNode));

                CompiledStructures.Add(compiledSymbol.AccessName, compiledSymbol);

                this.ReportNormal(
                    "Compiling Temp Structure",
                    compiledSymbol.AccessName,
                    ProgressEventArgsResult.Success
                    );

                return(compiledSymbol);
            }
            catch (Exception e)
            {
                this.ReportError("Error Compiling Temp Structure", e);

                return(null);
            }
        }
Exemple #9
0
        /// <summary>
        /// Find a structure given a text reference starting at the current scope information
        /// </summary>
        /// <param name="symbolName"></param>
        /// <returns></returns>
        public AstStructure Structure(string symbolName)
        {
            symbolName = symbolName.Trim();

            AstStructure symbolInfo;

            LanguageSymbol symbol;

            if (_symbolsCache.TryGetValue(symbolName, out symbol))
            {
                symbolInfo = new AstStructure(symbol as GMacStructure);
            }
            else
            {
                symbolInfo = _expressionCompiler.GetStructure(symbolName);

                AddToSymbolsCache(symbolName, symbolInfo.AssociatedStructure);
            }

            this.ReportNormal("Request Structure " + symbolName.DoubleQuote(), symbolInfo.IsNotNullAndValid());

            return(symbolInfo);
        }
Exemple #10
0
 /// <summary>
 /// True if this is a valid type exactly like the given structure type
 /// </summary>
 /// <param name="astType"></param>
 /// <returns></returns>
 public bool IsSameType(AstStructure astType)
 {
     return(IsValid && astType.IsNotNullAndValid() && AssociatedType.IsSameType(astType.AssociatedStructure));
 }
Exemple #11
0
 public static GMacStructureBinding Create(AstStructure patternType)
 {
     return(new GMacStructureBinding(patternType));
 }
Exemple #12
0
 private GMacStructureBinding(AstStructure patternType)
 {
     BaseStructure = patternType;
 }
Exemple #13
0
 public AstAttribute(Type type, AstStructure structure, string expression)
 {
     Type      = type;
     Condition = expression;
     Structure = structure;
 }