public void UnifyUnionMem() { TypeVariable tv1 = new TypeVariable(1); TypeVariable tv2 = new TypeVariable(2); DataType dt = un.Unify( new StructureType { Fields = { { 0, tv1 } } }, new StructureType { Fields = { { 4, tv1 } } }); StructureType mem = (StructureType)dt; Assert.AreEqual(2, mem.Fields.Count); Assert.IsNotNull((TypeVariable)mem.Fields[0].DataType); Assert.IsNotNull((TypeVariable)mem.Fields[1].DataType); dt = un.Unify( dt, new StructureType { Fields = { { 0, PrimitiveType.Word32 } } }); mem = (StructureType)dt; Assert.AreEqual("(struct (0 word32 dw0000) (4 T_1 t0004))", mem.ToString()); }
[TabGroup("Towers")] public int numFragmentsPickedUpOnTap = 1; // Done public int GetTowerCost(StructureType structureType) { int cost = 0; switch (structureType) { case StructureType.ABA_TOWER: cost = abaTowerCost; break; case StructureType.PPC2_TOWER: cost = ppc2TowerCost; break; case StructureType.CHLOROPLAST: cost = chloroplastTowerCost; break; case StructureType.MITOCHONDRIA: cost = mitoTowerCost; break; default: Debug.Log("Unable to find structure type:" + structureType.ToString()); break; } return(cost); }
public void MergeStaggeredArrays2() { StructureType s = new StructureType(null, 0); AddArrayField(s, 0, 8, PrimitiveType.Int32); AddArrayField(s, 4, 8, PrimitiveType.Int32); trans.MergeStaggeredArrays(s); Assert.AreEqual("(struct (0 (arr (struct 0008 (0 int32 dw0000) (4 int32 dw0004))) a0000))", s.ToString()); }
/// <summary> /// Builds a complex type with all BuiltInTypes as properties. /// </summary> public Type BuildComplexTypeWithAllBuiltInTypes( ServiceMessageContext context, StructureType structureType, string testFunc, out ExpandedNodeId nodeId) { uint typeId = (uint)Interlocked.Add(ref NodeIdCount, 100); var complexTypeStructure = new StructureDefinition() { BaseDataType = structureType == StructureType.Union ? DataTypeIds.Union : DataTypeIds.Structure, DefaultEncodingId = null, Fields = GetAllBuiltInTypesFields(), StructureType = structureType }; var fieldBuilder = ComplexTypeBuilder.AddStructuredType( structureType.ToString() + "." + testFunc, complexTypeStructure); nodeId = new ExpandedNodeId(typeId++, ComplexTypeBuilder.TargetNamespace); var binaryEncodingId = new ExpandedNodeId(typeId++, ComplexTypeBuilder.TargetNamespace); var xmlEncodingId = new ExpandedNodeId(typeId++, ComplexTypeBuilder.TargetNamespace); fieldBuilder.AddTypeIdAttribute( nodeId, binaryEncodingId, xmlEncodingId ); int i = 1; foreach (var field in complexTypeStructure.Fields) { Type fieldType = TypeInfo.GetSystemType(field.DataType, null); field.IsOptional = structureType == StructureType.StructureWithOptionalFields; fieldBuilder.AddField(field, fieldType, i++); } var complexType = fieldBuilder.CreateType(); if (context != null) { context.Factory.AddEncodeableType(nodeId, complexType); context.Factory.AddEncodeableType(binaryEncodingId, complexType); context.Factory.AddEncodeableType(xmlEncodingId, complexType); } return(complexType); }
override public async Task ImportStructure(StructureType structure_command, string data_file, bool phantom_fix, bool release, bool useFast, bool autoFBX) { if (autoFBX) { await AutoFBX.Structure(this, data_file, false); } ToolType tool = useFast ? ToolType.ToolFast : ToolType.Tool; string tool_command = structure_command.ToString().Replace("_", "-"); string data_path = data_file; if (structure_command == StructureType.structure_seams) { data_path = Path.GetDirectoryName(Path.GetDirectoryName(data_file)); } await RunTool(tool, new() { tool_command, data_path }, true); }
public void StructureSizeInHex() { StructureType s = new StructureType(null, 0x42); Assert.AreEqual("(struct 0042)", s.ToString()); }
public void StrFldMerger_Merge() { StructureType str = new StructureType("foo", 0); UnionType u = new UnionType(null, null, PrimitiveType.Ptr32, PrimitiveType.Word16); EquivalenceClass eq = Eqv(u); str.Fields.Add(2, eq); str.Fields.Add(4, PrimitiveType.SegmentSelector); StructureType strNew = sfm.Merge(str); Assert.AreEqual("(struct \"foo\" (2 (union (ptr32 u0) ((struct (0 word16 w0000) (2 selector pseg0002)) u1)) u0002))", strNew.ToString()); }
public void MergeDistinctArrays() { StructureType s = BuildDistinctArrays(); trans.MergeStaggeredArrays(s); Assert.AreEqual("(struct (0 (arr (struct 0014 (0 int32 dw0000) (4 int32 dw0004))) a0000) (28 (arr (struct 0014 (0 real32 r0000) (4 real32 r0004))) a0028))", s.ToString()); }
public void MergeStaggeredArrays() { StructureType s = BuildStaggeredArrays(); trans.MergeStaggeredArrays(s); Assert.AreEqual("(struct (4 (arr (struct 0014 (0 int32 dw0000) (4 real64 r0004) (8 byte b0008))) a0004))", s.ToString()); }
public override string GetDescription() { return("Building structure " + type.ToString() + " at position " + position.ToString()); }