private void CreateLValuesForStruct(List <DeclarationNode> root, StructNode structNode) { foreach (DeclarationNode member in structNode.Members) { CreateLValuesForDeclaration(root, member); } }
public static StructBody TypeBodyDefinition(SourceCodeBody src, StructNode sn) { var body = new StructBody(src, sn.Name.Name); sn.Generics.Each(x => body.Generics.Add(new TypeGenericsParameter(x.Name))); FunctionBodyDefinition(body, sn.Statements); sn.Statements.Each(let => { switch (let) { case LetNode x: body.Members.Add(x.Var.Name, body.LexicalScope[x.Var.Name]); break; case LetTypeNode x: body.Members.Add(x.Var.Name, body.LexicalScope[x.Var.Name]); break; default: throw new Exception(); } }); if (sn.Generics.Count == 0) { body.SpecializationMapper[new GenericsMapper()] = new TypeMapper(); src.Functions.Add(new EmbeddedFunction(sn.Name.Name, sn.Name.Name) { OpCode = (args) => $"newobj instance void {sn.Name.Name}::.ctor()" }); } return(body); }
public BaseNode AddStruct(string id, string name, string file, string sz) { StructNode structn = new StructNode(id, name, file, sz); nodemap.Add(id, structn); return(structn); }
protected void VisitStructNode(StructNode node) { if (node == null) { return; } AppendIndentation(); Append(node.Visibility); if (node.IsReadOnly) { Append("readonly "); } Append("struct "); Append(node.Name); AppendTypeGeneric(node); AppendLine(); AppendLine("{"); ++this.indentLevel; base.VisitTypeStructClassNode(node); --this.indentLevel; AppendLine("}"); AppendLine(); if (this.settings.BlankLine.Type) { AppendLine(); } }
public void VisitStruct(StructNode node) { Print($"Struct (Name = {node.Name})"); foreach (DeclarationNode member in node.Members) { VisitSubnode(member); } }
protected override void InnerRead() { arr = Enumerable.Range(0, Length).Select(_ => { var node = new StructNode <T> { Bytes = Bytes }; node.Read(); return(node.t); }).ToArray(); }
public void VisitStruct(StructNode node) { for (int i = 0, ilen = node.FunctionAssociations.Count; i < ilen; ++i) { node.FunctionAssociations[i] = _processor.ProcessReplacement(node.FunctionAssociations[i]); } for (int i = 0, ilen = node.Members.Count; i < ilen; ++i) { node.Members[i] = _processor.ProcessReplacement(node.Members[i]); } }
private static IReadOnlyList <Node> PathToNode(List <string> path) { List <Node> list = new List <Node>(); foreach (string pathValue in path) { Attributes.Attribute attr = new Attributes.Attribute(Path, pathValue); Node node = StructNode.Create("node1", new Attributes(attr)); list.Add(node); } return(list.AsReadOnly()); }
public void VisitStruct(StructNode node) { _visitor.VisitTopLevelStatement(node); foreach (IStructFunctionAssociationNode functionAssociationNode in node.FunctionAssociations) { functionAssociationNode.AcceptSyntaxTreeVisitor(_childrenVisitor); } foreach (DeclarationNode member in node.Members) { member.AcceptSyntaxTreeVisitor(_childrenVisitor); } }
private Type EnsureStructRecursive(StructNode structNode, HashSet <StructNode> closedSet) { // Check if struct has already been created Type?llvmStructType = Context.LookupStructType(structNode.Name); if (llvmStructType != null) { return(llvmStructType.Value); } // Add this node to closed set to avoid cycles if (closedSet.Contains(structNode)) { throw new InvalidOperationException($"Cyclic struct member detected: {structNode.Name}"); } closedSet.Add(structNode); // Head recursion is necessary to resolve non-forward-declared struct types Type[] memberTypes = new Type[structNode.Members.Count]; for (int i = 0, ilen = structNode.Members.Count; i < ilen; ++i) { DeclarationNode member = structNode.Members[i]; IType tp = ((TypeSpecifierNode)member.Type).Type; Type? llvmTp = LookupType(tp); if (llvmTp != null) { memberTypes[i] = llvmTp.Value; } else if (tp is StructType structType) { memberTypes[i] = EnsureStructRecursive(structType.Struct, closedSet); } else { throw new InvalidOperationException("Unable to ensure type recursively"); } } // Actually create the LLVM type here Type newStructType = Context.CreateStruct(structNode.Name, memberTypes); ulong sizeInBits = TargetDataLayout.SizeOfTypeInBits(newStructType); uint alignInBits = TargetDataLayout.PreferredAlignmentOfType(newStructType); List <Metadata> diMemberTypes = structNode.Members.ConvertAll(d => LookupDiType(((TypeSpecifierNode)d.Type).Type) !.Value); // TODO: resolve declaration file and line DiBuilder.CreateStruct(structNode.Name, DiFile, 0, sizeInBits, alignInBits, diMemberTypes.ToArray()); return(newStructType); }
private static IReadOnlyList <Node> ResolutionToString(string resolution) { List <Node> list = new List <Node>(); string[] path = resolution.SplitLines(); foreach (string pathValue in path) { Attributes.Attribute attr = new Attributes.Attribute(Path, pathValue.NormalizeInclude());; Node node = StructNode.Create("node1", new Attributes(attr)); list.Add(node); } return(list.AsReadOnly()); }
public void Dump(BaseNode root) { if (root == null) { root = rootNode; } foreach (BaseNode node in root.childnodes) { if (node.Type() == typeof(EnumNode)) { EnumNode enode = node as EnumNode; Console.WriteLine("Enum: " + enode.name); } else if (node.Type() == typeof(StructNode)) { StructNode snode = node as StructNode; Console.WriteLine("Struct: " + snode.name); } else if (node.Type() == typeof(UnionNode)) { UnionNode unode = node as UnionNode; Console.WriteLine("Union: " + unode.name); } else if (node.Type() == typeof(ClassNode)) { ClassNode cnode = node as ClassNode; Console.WriteLine("Class: " + cnode.name); } else if (node.Type() == typeof(FieldNode)) { FieldNode fnode = node as FieldNode; BaseNode n; Console.WriteLine("Field: " + fnode.name + " type: " + ResolveType(fnode.type, out n, false) + " (" + fnode.type + ")"); } else if (node.Type() == typeof(MethodNode)) { MethodNode mnode = node as MethodNode; BaseNode n; Console.WriteLine("Method: " + mnode.name + " virtual: " + mnode.virt + " returns: " + ResolveType(mnode.ret, out n, true) + " (" + mnode.ret + ")"); } Dump(node); } }
public void Process(StructNode structNode, SemanticContext context, IErrorManager errors) { for (int i = 0, ilen = structNode.FunctionAssociations.Count; i < ilen; ++i) { IStructFunctionAssociationNode associationNode = structNode.FunctionAssociations[i]; if (associationNode is StructFunctionAssociationParseNode parseNode) { if (!context.Functions.TryGetValue(parseNode.FunctionName, out FunctionDefinitionNode function)) { errors.AddError($"Undefined function \"{parseNode.FunctionName}\"", parseNode); continue; } structNode.FunctionAssociations[i] = new StructFunctionAssociationNode(parseNode.Name, function); } } }
public void Analyze(StructNode node, IErrorManager errors) { foreach (IStructFunctionAssociationNode associationNode in node.FunctionAssociations) { if (!(associationNode is StructFunctionAssociationNode processedAssociationNode)) { continue; } if (processedAssociationNode.Name == Syntax.FUNCTION_ATTRIBUTE_DROP && !processedAssociationNode.FunctionDefinition.IsDrop) { errors.AddError( "Associated drop function is not defined with drop attribute.", processedAssociationNode); } } }
protected override void VisitStructNode(StructNode node) { AppendIndentation(); AppendAccesType(node.Visibility); Append("struct "); Append(node.Name); AppendLineEnding(); AppendLine("{"); ++_indentation; base.VisitStructNode(node); --_indentation; AppendLine("}"); AppendLineEnding(); }
public static Dictionary <string, object> GetGsaNodes(Design GSAFile) { List <string> listGUID = new List <string>(); List <string> listGSAid = new List <string>(); List <double> listNodeX = new List <double>(); List <double> listNodeY = new List <double>(); List <double> listNodeZ = new List <double>(); List <bool> isStructural = new List <bool>(); foreach (Node thisNode in GSAFile.Nodes) { listGUID.Add(thisNode.GUID); listNodeX.Add(thisNode.Position.X); listNodeY.Add(thisNode.Position.Y); listNodeZ.Add(thisNode.Position.Z); StructNode thisStructNode = new StructNode(); if (thisNode is StructNode) { thisStructNode = (StructNode)thisNode; isStructural.Add(true); listGSAid.Add(thisStructNode.AppIDs.GetAppIdByAppName("GSA").ItemID); } } return(new Dictionary <string, object> { { "Point.GUID", listGUID }, { "GSA.Id", listGSAid }, { "Point.isStructural", isStructural }, { "Point.X", listNodeX }, { "Point.Y", listNodeY }, { "Point.Z", listNodeZ } }); }
protected virtual void VisitStructNode(StructNode node) { WalkStructNode(node); }
public override void VisitStruct(StructNode node) { visitor.VisitStruct((IStructWithSymbols)node); }
public void EnsureStruct(StructNode structNode) { HashSet <StructNode> closedSet = new HashSet <StructNode>(); EnsureStructRecursive(structNode, closedSet); }
public override Node VisitStruct(StructNode node) { node.Children.ForEach(c => c.AcceptVisitor(this)); _nodes.Add(node); return(node); }
/// <summary> ///Method create model in proj environment /// </summary> private static void CreateModel(Structure model) { #region ---------- Geometry ----------- #region Create Materials Material concmat = new Material(Guid.NewGuid(), "conc", (int)Material_Type.Concrete, "C30/37"); Material steelmat = new Material(Guid.NewGuid(), "steel", (int)Material_Type.Steel, "S 355"); foreach (var x in new List <Material> { concmat, steelmat }) { model.CreateMaterial(x); } #endregion #region Create Cross Sections CrossSectionManufactured hea260 = new CrossSectionManufactured(Guid.NewGuid(), "steel.HEA", steelmat.Id, "HEA260", 1, 0); CrossSectionParametric rect300x300 = new CrossSectionParametric(Guid.NewGuid(), "r300x300", concmat.Id, 1, new double[] { 300.0, 300.0 }); model.CreateCrossSection(hea260); model.CreateCrossSection(rect300x300); #endregion #region Create Nodes double a = 5.0; double b = 6.0; double c = 4.0; StructNode n1 = new StructNode(Guid.NewGuid(), "n1", 0, 0, 0); StructNode n2 = new StructNode(Guid.NewGuid(), "n2", a, 0, 0); StructNode n3 = new StructNode(Guid.NewGuid(), "n3", a, b, 0); StructNode n4 = new StructNode(Guid.NewGuid(), "n4", 0, b, 0); StructNode n5 = new StructNode(Guid.NewGuid(), "n5", 0, 0, c); StructNode n6 = new StructNode(Guid.NewGuid(), "n6", a, 0, c); StructNode n7 = new StructNode(Guid.NewGuid(), "n7", a, b, c); StructNode n8 = new StructNode(Guid.NewGuid(), "n8", 0, b, c); foreach (var x in new List <StructNode> { n1, n2, n3, n4, n5, n6, n7, n8 }) { model.CreateNode(x); } #endregion #region Create Beams Beam b1 = new Beam(Guid.NewGuid(), beamName, hea260.Id, new Guid[2] { n1.Id, n5.Id }); Beam b2 = new Beam(Guid.NewGuid(), "b2", hea260.Id, new Guid[2] { n2.Id, n6.Id }); Beam b3 = new Beam(Guid.NewGuid(), "b3", hea260.Id, new Guid[2] { n3.Id, n7.Id }); Beam b4 = new Beam(Guid.NewGuid(), "b4", hea260.Id, new Guid[2] { n4.Id, n8.Id }); foreach (var x in new List <Beam> { b1, b2, b3, b4 }) { model.CreateBeam(x); } #endregion #region Create Slab double thickness = 0.30; Slab s1 = new Slab(Guid.NewGuid(), SlabName, (int)Slab_Type.Plate, concmat.Id, thickness, new Guid[4] { n5.Id, n6.Id, n7.Id, n8.Id }); model.CreateSlab(s1); #endregion #region Create Support - in Node PointSupport Su1 = new PointSupport(Guid.NewGuid(), "Su1", n1.Id) { ConstraintRx = eConstraintType.Free, ConstraintRy = eConstraintType.Free, ConstraintRz = eConstraintType.Free }; PointSupport Su2 = new PointSupport(Guid.NewGuid(), "Su2", n2.Id) { ConstraintZ = eConstraintType.Flexible, StiffnessZ = 10000.0 }; PointSupport Su3 = new PointSupport(Guid.NewGuid(), "Su3", n3.Id); PointSupport Su4 = new PointSupport(Guid.NewGuid(), "Su4", n4.Id); foreach (var x in new List <PointSupport> { Su1, Su2, Su3, Su4 }) { model.CreatePointSupport(x); } #endregion #region Create Support - on Beam & on Slab Edge LineSupport lineSupport_onBeam = new LineSupport(Guid.NewGuid(), "linSupBeam", b1.Id) { ConstraintRx = eConstraintType.Free, ConstraintRy = eConstraintType.Free, ConstraintRz = eConstraintType.Free, ConstraintX = eConstraintType.Flexible, StiffnessX = 10.0, ConstraintY = eConstraintType.Flexible, StiffnessY = 10.0, ConstraintZ = eConstraintType.Flexible, StiffnessZ = 10.0, }; LineSupport lineSupport_onEdge = new LineSupport(Guid.NewGuid(), "linSupEdge", s1.Id) { ConstraintRx = eConstraintType.Free, ConstraintRy = eConstraintType.Free, ConstraintRz = eConstraintType.Free, ConstraintX = eConstraintType.Flexible, StiffnessX = 10.0, ConstraintY = eConstraintType.Flexible, StiffnessY = 10.0, ConstraintZ = eConstraintType.Flexible, StiffnessZ = 10.0, EdgeIndex = 2 }; foreach (var x in new List <LineSupport> { lineSupport_onBeam, lineSupport_onEdge }) { model.CreateLineSupport(x); } #endregion #endregion #region ---------- Loads --------------- #region Create Load Group LoadGroup lgperm = new LoadGroup(Guid.NewGuid(), "lgperm", (int)eLoadGroup_Load.eLoadGroup_Load_Permanent); LoadGroup lgvar1 = new LoadGroup(Guid.NewGuid(), "lgvar1", (int)eLoadGroup_Load.eLoadGroup_Load_Variable); LoadGroup lgvar2 = new LoadGroup(Guid.NewGuid(), "lgvar2", (int)eLoadGroup_Load.eLoadGroup_Load_Variable); LoadGroup lgvar3 = new LoadGroup(Guid.NewGuid(), "lgvar3", (int)eLoadGroup_Load.eLoadGroup_Load_Variable); foreach (var x in new List <LoadGroup> { lgperm, lgvar1, lgvar2, lgvar3 }) { model.CreateLoadGroup(x); } #endregion #region Create Load Case LoadCase lc_sw = new LoadCase(Guid.NewGuid(), "lc_sw", (int)LoadCase_actionType.Permanent, lgperm.Id, (int)LoadCase_loadCaseType.SelfWeight); LoadCase lc_perm = new LoadCase(Lc1Id, "lc_perm", (int)LoadCase_actionType.Permanent, lgperm.Id, (int)LoadCase_loadCaseType.Standard); LoadCase lc_var1 = new LoadCase(Guid.NewGuid(), "lc_var1", (int)LoadCase_actionType.Variable, lgvar1.Id, (int)LoadCase_loadCaseType.Static); LoadCase lc_var2 = new LoadCase(Guid.NewGuid(), "lc_var2", (int)LoadCase_actionType.Variable, lgvar2.Id, (int)LoadCase_loadCaseType.Static); LoadCase lc_var3a = new LoadCase(Guid.NewGuid(), "lc_var3a", (int)LoadCase_actionType.Variable, lgvar3.Id, (int)LoadCase_loadCaseType.Static); LoadCase lc_var3b = new LoadCase(Guid.NewGuid(), "lc_var3b", (int)LoadCase_actionType.Variable, lgvar3.Id, (int)LoadCase_loadCaseType.Static); LoadCase lc_var3c = new LoadCase(Guid.NewGuid(), "lc_var3c", (int)LoadCase_actionType.Variable, lgvar3.Id, (int)LoadCase_loadCaseType.Static); foreach (var x in new List <LoadCase> { lc_sw, lc_perm }) { model.CreateLoadCase(x); } #endregion #region Create Load Combinations CombinationItem[] combinationItems = new CombinationItem[] { new CombinationItem(lc_sw.Id, 1.0), new CombinationItem(Lc1Id, 1.0), // new CombinationItem(lc_var1.Id, 1.0), new CombinationItem(lc_var2.Id, 1.0), // new CombinationItem(lc_var3a.Id, 1.0), new CombinationItem(lc_var3b.Id, 1.0), new CombinationItem(lc_var3c.Id, 1.0) }; Combination C_EnUlsB = new Combination(C1Id, "C_EnUlsB", combinationItems) { Category = eLoadCaseCombinationCategory.AccordingNationalStandard, NationalStandard = eLoadCaseCombinationStandard.EnUlsSetB, }; Combination C_EnUlsC = new Combination(Guid.NewGuid(), "C_EnUlsC", combinationItems) { Category = eLoadCaseCombinationCategory.AccordingNationalStandard, NationalStandard = eLoadCaseCombinationStandard.EnUlsSetC }; Combination C_EnSlsChar = new Combination(Guid.NewGuid(), "C_EnSlsChar", combinationItems) { Category = eLoadCaseCombinationCategory.AccordingNationalStandard, NationalStandard = eLoadCaseCombinationStandard.EnSlsCharacteristic }; Combination C_EnSlsFreq = new Combination(Guid.NewGuid(), "C_EnSlsFreq", combinationItems) { Category = eLoadCaseCombinationCategory.AccordingNationalStandard, NationalStandard = eLoadCaseCombinationStandard.EnSlsFrequent }; Combination C_EnSlsQP = new Combination(Guid.NewGuid(), "C_EnSlsQP", combinationItems) { Category = eLoadCaseCombinationCategory.AccordingNationalStandard, NationalStandard = eLoadCaseCombinationStandard.EnSlsQuasiPermanent }; Combination C_Acc1 = new Combination(Guid.NewGuid(), "C_Acc1", combinationItems) { //Category = eLoadCaseCombinationCategory.AccidentalLimitState, Category = eLoadCaseCombinationCategory.AccordingNationalStandard, NationalStandard = eLoadCaseCombinationStandard.EnAccidental1 }; Combination C_Acc2 = new Combination(Guid.NewGuid(), "C_Acc2", combinationItems) { //Category = eLoadCaseCombinationCategory.AccidentalLimitState, Category = eLoadCaseCombinationCategory.AccordingNationalStandard, NationalStandard = eLoadCaseCombinationStandard.EnAccidental2 }; Combination C_ULS = new Combination(Guid.NewGuid(), "C_ULS", combinationItems) { Category = eLoadCaseCombinationCategory.UltimateLimitState, }; Combination C_SLS = new Combination(Guid.NewGuid(), "C_SLS", combinationItems) { Category = eLoadCaseCombinationCategory.ServiceabilityLimitState }; foreach (var x in new List <Combination> { C_EnUlsB, C_EnUlsC, C_EnSlsChar, C_EnSlsFreq, C_EnSlsQP, C_Acc1, C_Acc2 }) { model.CreateCombination(x); } #endregion #region Create Load - Point Loads - in Node double loadValue; loadValue = -12500.0; PointLoadInNode pln1 = new PointLoadInNode(Guid.NewGuid(), "pln1", loadValue, lc_perm.Id, n4.Id, (int)eDirection.X); model.CreatePointLoadInNode(pln1); #endregion #region Create Load - Point Loads - Free loadValue = -12500.0; PointLoadFree plf1 = new PointLoadFree(Guid.NewGuid(), "plf1", lc_perm.Id, loadValue, a / 3.0, b / 3.0, c, (int)eDirection.Z, c - 1.0, c + 1.0); model.CreatePointLoadFree(plf1); #endregion #region Create Load - Surface Loads - on Slab loadValue = -12500.0; SurfaceLoad sf1 = new SurfaceLoad(Guid.NewGuid(), "sf1", loadValue, lc_perm.Id, s1.Id, (int)eDirection.Z); SurfaceLoad sf2 = new SurfaceLoad(Guid.NewGuid(), "sf2", loadValue, lc_var1.Id, s1.Id, (int)eDirection.Y); SurfaceLoad sf3 = new SurfaceLoad(Guid.NewGuid(), "sf3", loadValue, lc_var2.Id, s1.Id, (int)eDirection.X); SurfaceLoad sf4 = new SurfaceLoad(Guid.NewGuid(), "sf4", loadValue, lc_var3a.Id, s1.Id, (int)eDirection.X); SurfaceLoad sf5 = new SurfaceLoad(Guid.NewGuid(), "sf5", loadValue, lc_var3b.Id, s1.Id, (int)eDirection.Y); SurfaceLoad sf6 = new SurfaceLoad(Guid.NewGuid(), "sf6", loadValue, lc_var3c.Id, s1.Id, (int)eDirection.Z); foreach (var x in new List <SurfaceLoad> { sf1 }) { model.CreateSurfaceLoad(x); } #endregion #region Create Load - Line Load - on Beam & on Slab Edge var lin1 = new LineLoadOnBeam(Guid.NewGuid(), "lin1") { Member = b1.Id, LoadCase = lc_perm.Id, Distribution = eLineLoadDistribution.Trapez, Value1 = -12500, Value2 = -12500, CoordinateDefinition = eCoordinateDefinition.Relative, StartPoint = 0.01, EndPoint = 0.99, CoordinationSystem = eCoordinationSystem.GCS, Direction = eDirection.X, Origin = eLineOrigin.FromStart, Location = eLineLoadLocation.Length, EccentricityEy = 0.0, EccentricityEz = 0.0 }; var lin2 = new LineLoadOnBeam(Guid.NewGuid(), "lin2") { Member = b1.Id, LoadCase = lc_var1.Id, Distribution = eLineLoadDistribution.Trapez, Value1 = -12500, Value2 = 12500, CoordinateDefinition = eCoordinateDefinition.Relative, StartPoint = 0.01, EndPoint = 0.99, CoordinationSystem = eCoordinationSystem.GCS, Direction = eDirection.Y, Origin = eLineOrigin.FromStart, Location = eLineLoadLocation.Projection, EccentricityEy = 0.0, EccentricityEz = 0.0 }; var lin3a = new LineLoadOnSlabEdge(Guid.NewGuid(), "lin3a") { Member = s1.Id, LoadCase = lc_var3a.Id, EdgeIndex = 0, Distribution = eLineLoadDistribution.Trapez, Value1 = -12500, Value2 = 12500, CoordinateDefinition = eCoordinateDefinition.Relative, StartPoint = 0.01, EndPoint = 0.99, CoordinationSystem = eCoordinationSystem.GCS, Direction = eDirection.Z, Origin = eLineOrigin.FromStart, Location = eLineLoadLocation.Length }; var lin3b = new LineLoadOnSlabEdge(Guid.NewGuid(), "lin3b") { Member = s1.Id, LoadCase = lc_var3b.Id, EdgeIndex = 1, Distribution = eLineLoadDistribution.Trapez, Value1 = -12500, Value2 = 12500, CoordinateDefinition = eCoordinateDefinition.Relative, StartPoint = 0.01, EndPoint = 0.99, CoordinationSystem = eCoordinationSystem.GCS, Direction = eDirection.Z, Origin = eLineOrigin.FromStart, Location = eLineLoadLocation.Length }; var lin3c = new LineLoadOnSlabEdge(Guid.NewGuid(), "lin3c") { Member = s1.Id, LoadCase = lc_var3c.Id, EdgeIndex = 2, Distribution = eLineLoadDistribution.Trapez, Value1 = -12500, Value2 = 12500, CoordinateDefinition = eCoordinateDefinition.Relative, StartPoint = 0.01, EndPoint = 0.99, CoordinationSystem = eCoordinationSystem.GCS, Direction = eDirection.Z, Origin = eLineOrigin.FromStart, Location = eLineLoadLocation.Length }; var lin3d = new LineLoadOnSlabEdge(Guid.NewGuid(), "lin3d") { Member = s1.Id, LoadCase = lc_perm.Id, EdgeIndex = 3, Distribution = eLineLoadDistribution.Trapez, Value1 = -12500, Value2 = 12500, CoordinateDefinition = eCoordinateDefinition.Relative, StartPoint = 0.01, EndPoint = 0.99, CoordinationSystem = eCoordinationSystem.GCS, Direction = eDirection.Z, Origin = eLineOrigin.FromStart, Location = eLineLoadLocation.Length }; foreach (var x in new List <LineLoadOnBeam> { lin1 }) { model.CreateLineLoad(x); } foreach (var x in new List <LineLoadOnSlabEdge> { lin3d }) { model.CreateLineLoad(x); } //foreach (var x in new List<LineLoadOnBeam> { lin1, lin2 }) { model.CreateLineLoad(x); } //foreach (var x in new List<LineLoadOnSlabEdge> { lin3a, lin3b, lin3c, lin3d }) { model.CreateLineLoad(x); } #endregion #endregion }
public void VisitStruct(StructNode node) { _module.Structs.Add(node); }
public void WriteToFile(BaseNode root) { if (root == null) { root = rootNode; level = 1; sb = new StringBuilder(); sb.AppendLine("using System;"); sb.AppendLine("using System.Text;"); sb.AppendLine("using System.Runtime.InteropServices;"); sb.AppendLine("using Steam4NET;"); sb.AppendLine(""); sb.AppendLine("namespace Steam4NET"); sb.AppendLine("{"); } foreach (BaseNode node in root.childnodes) { if (node.Type() == typeof(EnumNode)) { EnumNode enode = node as EnumNode; if (files[enode.file].StartsWith(@"G:\dev\C++\Open Steamworks")) { if (root.Type() == typeof(StructNode) || root.Type() == typeof(ClassNode)) { foreach (EnumNode.EnumValue value in enode.values) { sb.AppendLine(new String('\t', level) + "public const int " + value.name + " = " + value.value + ";"); } } else { Console.WriteLine("Enum: " + enode.name); sb.AppendLine(new String('\t', level) + "public enum " + enode.name); sb.AppendLine(new String('\t', level) + "{"); level++; foreach (EnumNode.EnumValue value in enode.values) { sb.AppendLine(new String('\t', level) + value.name + " = " + value.value + ","); } level--; sb.AppendLine(new String('\t', level) + "}"); sb.AppendLine(new String('\t', level) + ""); } } } else if (node.Type() == typeof(StructNode)) { StructNode snode = node as StructNode; if (files[snode.file].StartsWith(@"G:\dev\C++\Open Steamworks") && !snode.name.StartsWith("EnumString")) { Console.WriteLine("Struct: " + snode.name); if (prefix != null) { sb.AppendLine(new String('\t', level) + prefix); } sb.AppendLine(new String('\t', level) + "[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi,Pack=8,Size=" + snode.size + ")]"); sb.AppendLine(new String('\t', level) + "public struct " + snode.name); sb.AppendLine(new String('\t', level) + "{"); string oldprefix = prefix; prefix = null; level++; WriteToFile(snode); level--; prefix = oldprefix; sb.AppendLine(new String('\t', level) + "}"); sb.AppendLine(new String('\t', level) + ""); } } else if (node.Type() == typeof(FieldNode)) { FieldNode fnode = node as FieldNode; Console.WriteLine("Field: " + fnode.name); ProcessType(fnode, fnode.type); } else if (node.Type() == typeof(ClassNode)) { ClassNode cnode = node as ClassNode; if (files[cnode.file].StartsWith(@"G:\dev\C++\Open Steamworks") && !cnode.name.StartsWith("EnumString")) { Console.WriteLine("Class: " + cnode.name); if (cnode.name.StartsWith("I")) { GenerateInterfaceWrapper(cnode); } else { if (prefix != null) { sb.AppendLine(new String('\t', level) + prefix); } sb.AppendLine(new String('\t', level) + "[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi,Pack=1,Size=" + cnode.size + ")]"); sb.AppendLine(new String('\t', level) + "public struct " + cnode.name); sb.AppendLine(new String('\t', level) + "{"); string oldprefix = prefix; prefix = null; level++; WriteToFile(cnode); level--; prefix = oldprefix; sb.AppendLine(new String('\t', level) + "}"); sb.AppendLine(new String('\t', level) + ""); } } } else if (node.Type() == typeof(MethodNode)) { } } if (level == 1) { sb.AppendLine("}"); File.WriteAllText(@"G:\dev\C++\Open Steamworks\Steam4NET\test.cs", sb.ToString()); } }
public BaseNode AddStruct(string id, string name, string file, string sz) { StructNode structn = new StructNode(id, name, file, sz); nodemap.Add(id, structn); return structn; }
public StructType(StructNode structNode) { Struct = structNode; }
protected void WalkStructNode(StructNode node) { node.Fields.ForEach(f => VisitFieldNode(f)); }
public virtual XzaarExpression Visit(StructNode node) { return(null); }
public virtual StructNode Visit(StructNode node) { return(node); }