Example #1
0
        public FatExceptionHandlerTableImpl(HexBufferSpan span)
            : base(span)
        {
            if (span.Length < 4)
            {
                throw new ArgumentOutOfRangeException(nameof(span));
            }
            var buffer = span.Buffer;
            var pos    = span.Start.Position;

            SectFat = new StructField <FatSection>("SectFat", new FatSectionImpl(buffer, pos));

            var startPos = pos + 4;
            int elements = (int)((span.End.Position - startPos).ToUInt64() / 24);
            var fields   = new ArrayField <FatExceptionClause> [elements];
            var currPos  = startPos;

            for (int i = 0; i < fields.Length; i++)
            {
                var field = new ArrayField <FatExceptionClause>(new FatExceptionClauseImpl(buffer, currPos), (uint)i);
                fields[i] = field;
                currPos   = field.Data.Span.End;
            }
            Clauses = new StructField <ArrayData <FatExceptionClause> >("Clauses", new ArrayData <FatExceptionClause>("Clauses", new HexBufferSpan(buffer, HexSpan.FromBounds(startPos, currPos)), fields));

            Fields = new BufferField[] {
                SectFat,
                Clauses,
            };
        }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="buffer">Buffer</param>
 /// <param name="stringSpan">Span of string, not including the terminating zero</param>
 /// <param name="hasTerminatingZero">true if there's a terminating zero, false if there's no terminating zero
 /// or if the string is too long</param>
 /// <param name="heap">Owner heap</param>
 /// <param name="tokens">Tokens of records referencing this string</param>
 public StringsHeapRecordData(HexBuffer buffer, HexSpan stringSpan, bool hasTerminatingZero, StringsHeap heap, uint[] tokens)
     : base(NAME, new HexBufferSpan(buffer, HexSpan.FromBounds(stringSpan.Start, stringSpan.End + (hasTerminatingZero ? 1 : 0))))
 {
     if (tokens == null)
     {
         throw new ArgumentNullException(nameof(tokens));
     }
     Heap   = heap ?? throw new ArgumentNullException(nameof(heap));
     Tokens = new ReadOnlyCollection <uint>(tokens);
     String = new StructField <StringData>("String", new StringData(new HexBufferSpan(buffer, stringSpan), Encoding.UTF8));
     if (hasTerminatingZero)
     {
         Terminator = new StructField <ByteData>("Terminator", new ByteData(buffer, stringSpan.End));
     }
     if (Terminator != null)
     {
         Fields = new BufferField[] {
             String,
             Terminator,
         };
     }
     else
     {
         Fields = new BufferField[] {
             String,
         };
     }
 }
Example #3
0
        public static void BuildAssertions(ClassesProcessor.ClassNode node)
        {
            ClassWrapper wrapper = node.GetWrapper();
            StructField  field   = FindAssertionField(node);

            if (field != null)
            {
                string key = InterpreterUtil.MakeUniqueKey(field.GetName(), field.GetDescriptor()
                                                           );
                bool res = false;
                foreach (MethodWrapper meth in wrapper.GetMethods())
                {
                    RootStatement root = meth.root;
                    if (root != null)
                    {
                        res |= ReplaceAssertions(root, wrapper.GetClassStruct().qualifiedName, key);
                    }
                }
                if (res)
                {
                    // hide the helper field
                    wrapper.GetHiddenMembers().Add(key);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="span">Data span</param>
        public GuidData(HexBufferSpan span)
            : base(NAME, span)
        {
            if (span.Length != 16)
            {
                throw new ArgumentOutOfRangeException(nameof(span));
            }
            var buffer = span.Buffer;
            var pos    = span.Span.Start;

            A      = new StructField <UInt32Data>("A", new UInt32Data(buffer, pos));
            B      = new StructField <UInt16Data>("B", new UInt16Data(buffer, pos + 4));
            C      = new StructField <UInt16Data>("C", new UInt16Data(buffer, pos + 6));
            D      = new StructField <ByteData>("D", new ByteData(buffer, pos + 8));
            E      = new StructField <ByteData>("E", new ByteData(buffer, pos + 9));
            F      = new StructField <ByteData>("F", new ByteData(buffer, pos + 0x0A));
            G      = new StructField <ByteData>("G", new ByteData(buffer, pos + 0x0B));
            H      = new StructField <ByteData>("H", new ByteData(buffer, pos + 0x0C));
            I      = new StructField <ByteData>("I", new ByteData(buffer, pos + 0x0D));
            J      = new StructField <ByteData>("J", new ByteData(buffer, pos + 0x0E));
            K      = new StructField <ByteData>("K", new ByteData(buffer, pos + 0x0F));
            Fields = new BufferField[] {
                A,
                B,
                C,
                D,
                E,
                F,
                G,
                H,
                I,
                J,
                K,
            };
        }
Example #5
0
        PeSectionDataImpl(HexBufferSpan span)
            : base(span)
        {
            var buffer = span.Buffer;
            var pos    = span.Start.Position;

            SectionName          = new StructField <StringData>("Name", new StringData(buffer, pos, 8, Encoding.ASCII));
            VirtualSize          = new StructField <UInt32Data>("VirtualSize", new UInt32Data(buffer, pos + 8));
            VirtualAddress       = new StructField <RvaData>("VirtualAddress", new RvaData(buffer, pos + 0x0C));
            SizeOfRawData        = new StructField <UInt32Data>("SizeOfRawData", new UInt32Data(buffer, pos + 0x10));
            PointerToRawData     = new StructField <FileOffsetData>("PointerToRawData", new FileOffsetData(buffer, pos + 0x14));
            PointerToRelocations = new StructField <FileOffsetData>("PointerToRelocations", new FileOffsetData(buffer, pos + 0x18));
            PointerToLinenumbers = new StructField <FileOffsetData>("PointerToLinenumbers", new FileOffsetData(buffer, pos + 0x1C));
            NumberOfRelocations  = new StructField <UInt16Data>("NumberOfRelocations", new UInt16Data(buffer, pos + 0x20));
            NumberOfLinenumbers  = new StructField <UInt16Data>("NumberOfLinenumbers", new UInt16Data(buffer, pos + 0x22));
            Characteristics      = new StructField <UInt32FlagsData>("Characteristics", new UInt32FlagsData(buffer, pos + 0x24, characteristicsFlagInfos));
            Fields = new BufferField[] {
                SectionName,
                VirtualSize,
                VirtualAddress,
                SizeOfRawData,
                PointerToRawData,
                PointerToRelocations,
                PointerToLinenumbers,
                NumberOfRelocations,
                NumberOfLinenumbers,
                Characteristics,
            };
        }
 private static string IsClass14Invocation(Exprent exprent, ClassWrapper wrapper,
                                           MethodWrapper meth)
 {
     if (exprent.type == Exprent.Exprent_Function)
     {
         FunctionExprent fexpr = (FunctionExprent)exprent;
         if (fexpr.GetFuncType() == FunctionExprent.Function_Iif)
         {
             if (fexpr.GetLstOperands()[0].type == Exprent.Exprent_Function)
             {
                 FunctionExprent headexpr = (FunctionExprent)fexpr.GetLstOperands()[0];
                 if (headexpr.GetFuncType() == FunctionExprent.Function_Eq)
                 {
                     if (headexpr.GetLstOperands()[0].type == Exprent.Exprent_Field && headexpr.GetLstOperands
                             ()[1].type == Exprent.Exprent_Const && ((ConstExprent)headexpr.GetLstOperands()[
                                                                         1]).GetConstType().Equals(VarType.Vartype_Null))
                     {
                         FieldExprent field = (FieldExprent)headexpr.GetLstOperands()[0];
                         ClassesProcessor.ClassNode fieldnode = DecompilerContext.GetClassProcessor().GetMapRootClasses
                                                                    ().GetOrNull(field.GetClassname());
                         if (fieldnode != null && fieldnode.classStruct.qualifiedName.Equals(wrapper.GetClassStruct
                                                                                                 ().qualifiedName))
                         {
                             // source class
                             StructField fd = wrapper.GetClassStruct().GetField(field.GetName(), field.GetDescriptor
                                                                                    ().descriptorString);
                             // FIXME: can be null! why??
                             if (fd != null && fd.HasModifier(ICodeConstants.Acc_Static) && (fd.IsSynthetic() ||
                                                                                             DecompilerContext.GetOption(IFernflowerPreferences.Synthetic_Not_Set)))
                             {
                                 if (fexpr.GetLstOperands()[1].type == Exprent.Exprent_Assignment && fexpr.GetLstOperands
                                         ()[2].Equals(field))
                                 {
                                     AssignmentExprent asexpr = (AssignmentExprent)fexpr.GetLstOperands()[1];
                                     if (asexpr.GetLeft().Equals(field) && asexpr.GetRight().type == Exprent.Exprent_Invocation)
                                     {
                                         InvocationExprent invexpr = (InvocationExprent)asexpr.GetRight();
                                         if (invexpr.GetClassname().Equals(wrapper.GetClassStruct().qualifiedName) && invexpr
                                             .GetName().Equals(meth.methodStruct.GetName()) && invexpr.GetStringDescriptor().
                                             Equals(meth.methodStruct.GetDescriptor()))
                                         {
                                             if (invexpr.GetLstParameters()[0].type == Exprent.Exprent_Const)
                                             {
                                                 wrapper.GetHiddenMembers().Add(InterpreterUtil.MakeUniqueKey(fd.GetName(), fd.GetDescriptor
                                                                                                                  ()));
                                                 // hide synthetic field
                                                 return(((ConstExprent)invexpr.GetLstParameters()[0]).GetValue().ToString());
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
 public override bool Equals(object o)
 {
     if (o == null || o.GetType() != GetType())
     {
         return(false);
     }
     else if (o == this)
     {
         return(true);
     }
     else
     {
         IList <StructField> other = ((OrcStructInspector)o).fields;
         if (other.Count != fields.Count)
         {
             return(false);
         }
         for (int i = 0; i < fields.Count; ++i)
         {
             StructField left  = other[i];
             StructField right = fields[i];
             if (!string.Equals(left.getFieldName(), right.getFieldName(), StringComparison.OrdinalIgnoreCase) &&
                 left.getFieldObjectInspector().Equals(right.getFieldObjectInspector()))
             {
                 return(false);
             }
         }
         return(true);
     }
 }
Example #8
0
        DotNetCor20DataImpl(HexBufferSpan span)
            : base(span)
        {
            var buffer = span.Buffer;
            var pos    = span.Start.Position;

            Cb = new StructField <UInt32Data>("cb", new UInt32Data(buffer, pos));
            MajorRuntimeVersion = new StructField <UInt16Data>("MajorRuntimeVersion", new UInt16Data(buffer, pos + 4));
            MinorRuntimeVersion = new StructField <UInt16Data>("MinorRuntimeVersion", new UInt16Data(buffer, pos + 6));
            Metadata            = new StructField <DataDirectoryData>("MetaData", new DataDirectoryData(buffer, pos + 8));
            Flags = new StructField <UInt32FlagsData>("Flags", new UInt32FlagsData(buffer, pos + 0x10, flagsFlagInfos));
            EntryPointTokenOrRVA    = new StructField <UInt32Data>("EntryPointTokenOrRVA", new UInt32Data(buffer, pos + 0x14));
            Resources               = new StructField <DataDirectoryData>("Resources", new DataDirectoryData(buffer, pos + 0x18));
            StrongNameSignature     = new StructField <DataDirectoryData>("StrongNameSignature", new DataDirectoryData(buffer, pos + 0x20));
            CodeManagerTable        = new StructField <DataDirectoryData>("CodeManagerTable", new DataDirectoryData(buffer, pos + 0x28));
            VTableFixups            = new StructField <DataDirectoryData>("VTableFixups", new DataDirectoryData(buffer, pos + 0x30));
            ExportAddressTableJumps = new StructField <DataDirectoryData>("ExportAddressTableJumps", new DataDirectoryData(buffer, pos + 0x38));
            ManagedNativeHeader     = new StructField <DataDirectoryData>("ManagedNativeHeader", new DataDirectoryData(buffer, pos + 0x40));
            Fields = new StructField[] {
                Cb,
                MajorRuntimeVersion,
                MinorRuntimeVersion,
                Metadata,
                Flags,
                EntryPointTokenOrRVA,
                Resources,
                StrongNameSignature,
                CodeManagerTable,
                VTableFixups,
                ExportAddressTableJumps,
                ManagedNativeHeader,
            };
        }
Example #9
0
        internal static void DFTextFileLoadDataFrameSample()
        {
            var requestsSchema = StructType.CreateStructType(
                new List <StructField>
            {
                StructField.CreateStructField("guid", "string", false),
                StructField.CreateStructField("datacenter", "string", false),
                StructField.CreateStructField("abtestid", "string", false),
                StructField.CreateStructField("traffictype", "string", false),
            }
                );

            var requestsDateFrame = GetSqlContext().TextFile(SparkCLRSamples.Configuration.GetInputDataPath(RequestsLog), requestsSchema);

            requestsDateFrame.RegisterTempTable("requests");
            var guidFilteredDataFrame = GetSqlContext().Sql("SELECT guid, datacenter FROM requests where guid = '4628deca-139d-4121-b540-8341b9c05c2a'");

            guidFilteredDataFrame.Show();

            requestsDateFrame.ShowSchema();
            requestsDateFrame.Show();
            var count = requestsDateFrame.Count();

            guidFilteredDataFrame.ShowSchema();
            guidFilteredDataFrame.Show();
            var filteredCount = guidFilteredDataFrame.Count();

            if (SparkCLRSamples.Configuration.IsValidationEnabled)
            {
                Assert.AreEqual(10, count);
                Assert.AreEqual(1, filteredCount);
            }
        }
Example #10
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="buffer">Buffer</param>
 /// <param name="span">Span</param>
 /// <param name="lengthSpan">Span of length</param>
 /// <param name="data">Data</param>
 /// <param name="tokens">Tokens referencing this blob or an empty collection</param>
 /// <param name="heap">Owner heap</param>
 public BlobHeapRecordData(HexBuffer buffer, HexSpan span, HexSpan lengthSpan, BufferData data, ReadOnlyCollection <uint> tokens, BlobHeap heap)
     : base(NAME, new HexBufferSpan(buffer, span))
 {
     if (lengthSpan.Start != span.Start)
     {
         throw new ArgumentOutOfRangeException(nameof(lengthSpan));
     }
     if (data == null)
     {
         throw new ArgumentNullException(nameof(data));
     }
     if (tokens == null)
     {
         throw new ArgumentNullException(nameof(tokens));
     }
     if (heap == null)
     {
         throw new ArgumentNullException(nameof(heap));
     }
     Heap   = heap;
     Tokens = tokens;
     Length = new StructField <BlobEncodedUInt32Data>("Length", new BlobEncodedUInt32Data(new HexBufferSpan(buffer, lengthSpan)));
     Data   = new StructField <BufferData>("Data", data);
     Fields = new BufferField[] {
         Length,
         Data,
     };
 }
Example #11
0
        private void TagBlock_CreateChildBlocks(ITagBlock block, long baseOffset, ref long offset)
        {
            //Loop through fields
            foreach (Field field in block)
            {
                switch (field.Type)
                {
                case FieldType.FieldStruct:
                    StructField structField = (StructField)field;
                    TagBlock_CreateChildBlocks((ITagBlock)structField.Value, baseOffset, ref offset);
                    break;

                case FieldType.FieldBlock:
                    BlockField blockField = (BlockField)field;
                    BlockField_CreateDataBlock(blockField, baseOffset, ref offset);
                    break;

                case FieldType.FieldData:
                    DataField dataField   = (DataField)field;
                    int       localOffset = (int)(dataField.DataAddress - baseOffset);
                    tagBlockView.Blocks.Add(localOffset, dataField.BufferLength, block.BlockName);
                    offset = dataField.DataAddress + dataField.BufferLength;
                    break;
                }
            }
        }
Example #12
0
        public static StructType ConvertFromCellDescriptor(ICellDescriptor cd)
        {
            if (cd == null)
            {
                return(null);
            }

            var fields = new List <StructField>();

            fields.Add(new StructField
            {
                Name = "CellID",
                Type = new DataType {
                    TypeName = typeof(long).FullName
                },
                Nullable = false
            });

            fields.AddRange(cd.GetFieldDescriptors().Select(fd => StructField.ConvertFromFieldDescriptor(fd)));

            return(new StructType
            {
                TypeName = typeof(StructType).Name,
                Fields = fields
            });
        }
        // Find the record identifier column (if there) and return a possibly new ObjectInspector that
        // will strain out the record id for the underlying writer.
        private ObjectInspector findRecId(ObjectInspector inspector, int rowIdColNum)
        {
            if (!(inspector is StructObjectInspector))
            {
                throw new InvalidOperationException("Serious problem, expected a StructObjectInspector, but got a " +
                                                    inspector.GetType().FullName);
            }
            if (rowIdColNum < 0)
            {
                return(inspector);
            }
            else
            {
                RecIdStrippingObjectInspector newInspector =
                    new RecIdStrippingObjectInspector(inspector, rowIdColNum);
                recIdField = newInspector.getRecId();
                List <StructField> fields =
                    ((StructObjectInspector)recIdField.getFieldObjectInspector()).getAllStructFieldRefs();
                // Go by position, not field name, as field names aren't guaranteed.  The order of fields
                // in RecordIdentifier is transactionId, bucketId, rowId
                originalTxnField = fields[0];
                origTxnInspector = (LongObjectInspector)originalTxnField.getFieldObjectInspector();
                rowIdField       = fields[2];
                rowIdInspector   = (LongObjectInspector)rowIdField.getFieldObjectInspector();


                recIdInspector = (StructObjectInspector)recIdField.getFieldObjectInspector();
                return(newInspector);
            }
        }
 public void WriteAll(StructField data)
 {
     foreach (JceField field in data.Data)
     {
         Write(field);
     }
 }
        public Field CreateSchemaElement(IList <Thrift.SchemaElement> schema, ref int index, out int ownedChildCount)
        {
            Thrift.SchemaElement container = schema[index++];

            ownedChildCount = container.Num_children; //make then owned to receive in .Assign()
            return(StructField.CreateWithNoElements(container.Name));
        }
Example #16
0
 public BlobCell(StructField def, Stream baseStream, int offset, int baseSize, BlobDecoder decoder, int decodedSize)
     : base(def, null, offset)
 {
     _baseStream  = baseStream;
     _baseSize    = baseSize;
     _decoder     = decoder;
     _decodedSize = decodedSize;
 }
Example #17
0
 public static UInt32HexField TryCreate(StructField <UInt32Data>?field, bool useDecimal = false)
 {
     if (field is not null)
     {
         return(new UInt32HexField(field, useDecimal));
     }
     return(new UInt32HexField());
 }
Example #18
0
        [Test] public void Alias()
        {
            StructFile  structFile = new StructParser().LoadStructs("alias str [len=8] resref; struct A { resref r; }");
            StructField field      = structFile.Structs [0].Fields [0];

            Assert.IsInstanceOfType(typeof(StrField), field);
            Assert.AreEqual(8, field.GetExpressionAttribute("len").EvaluateInt(null));
        }
Example #19
0
 public BlobCell(StructField def, Stream baseStream, int offset, int baseSize, BlobDecoder decoder, int decodedSize)
     : base(def, null, offset)
 {
     _baseStream = baseStream;
     _baseSize = baseSize;
     _decoder = decoder;
     _decodedSize = decodedSize;
 }
 public void Write(StructField val)
 {
     WriteHeader(Type_StructBegin, val.Tag);
     foreach (JceField field in val.Data)
     {
         Write(field);
     }
     WriteHeader(Type_StructEnd, 0);
 }
Example #21
0
        protected override void VisitStructField(StructDefinition @struct, StructField field)
        {
            base.VisitStructField(@struct, field);

            if (field.FieldType.Name == "bool")
            {
                field.FieldType.Name = "bool_t";
            }
        }
Example #22
0
		public FatSectionImpl(HexBuffer buffer, HexPosition pos)
			: base(new HexBufferSpan(buffer, new HexSpan(pos, 4))) {
			Kind = new StructField<ByteFlagsData>("Kind", new ByteFlagsData(buffer, pos, SmallSectionImpl.methodSectionKindFlagInfos));
			DataSize = new StructField<UInt24Data>("DataSize", new UInt24Data(buffer, pos + 1));
			Fields = new BufferField[] {
				Kind,
				DataSize,
			};
		}
        private Row CreateRow(string parentPath, JObject jo, IEnumerable <Field> fields)
        {
            var values = new List <object>();

            foreach (Field field in fields)
            {
                //string path = GetJsonPath(parentPath, field);
                string path = "$." + field.Name;
                object value;

                switch (field.SchemaType)
                {
                case SchemaType.Data:
                    JToken vt = jo.SelectToken(path);
                    if (vt == null)
                    {
                        value = null;
                    }
                    else
                    {
                        value = vt.Type == JTokenType.Array
                        ? GetValues((JArray)vt, (DataField)field)
                        : GetValue(((JValue)vt)?.Value, (DataField)field);
                    }
                    break;

                case SchemaType.Struct:
                    JToken vtStruct = jo.SelectToken(path);
                    value = CreateRow(path, (JObject)vtStruct, ((StructField)field).Fields);
                    break;

                case SchemaType.List:
                    JToken vtList = jo.SelectToken(path);
                    //it's always a struct in a list
                    ListField   listField   = (ListField)field;
                    StructField structField = (StructField)listField.Item;
                    var         rows        = new List <Row>();
                    if (vtList.Type == JTokenType.Array) //the value may be null or just not matching the schema
                    {
                        foreach (JObject vtListItem in ((JArray)vtList).Children())
                        {
                            Row row = CreateRow(null, vtListItem, structField.Fields);
                            rows.Add(row);
                        }
                    }
                    value = rows;
                    break;

                default:
                    throw new NotImplementedException();
                }

                values.Add(value);
            }

            return(new Row(values));
        }
Example #24
0
            public static StructField From(FieldInfo field)
            {
                var ret = new StructField();

                ret.Name = field.Name;
                ret.Type = TypeRef.From(field.FieldType);

                return(ret);
            }
Example #25
0
        public InvalidMethodBodyImpl(DotNetMethodProvider methodProvider, HexBufferSpan span, ReadOnlyCollection <uint> tokens)
            : base(methodProvider, span, tokens)
        {
            var buffer = span.Buffer;
            var pos    = span.Start.Position;

            Instructions = new StructField <VirtualArrayData <ByteData> >(TinyMethodBodyImpl.InstructionsFieldName, ArrayData.CreateVirtualByteArray(HexBufferSpan.FromBounds(span.Start, span.End), TinyMethodBodyImpl.InstructionsFieldName));
            Fields       = new BufferField[] {
                Instructions,
            };
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="resourceProvider">Owner</param>
 /// <param name="buffer">Buffer</param>
 /// <param name="lengthSpan">Span of 7-bit encoded length</param>
 /// <param name="stringSpan">Span of string data</param>
 public MultiResourceUnicodeNameAndOffsetData(DotNetMultiFileResources resourceProvider, HexBuffer buffer, HexSpan lengthSpan, HexSpan stringSpan)
     : base(NAME, new HexBufferSpan(buffer, HexSpan.FromBounds(lengthSpan.Start, stringSpan.End + 4)))
 {
     ResourceProvider = resourceProvider ?? throw new ArgumentNullException(nameof(resourceProvider));
     ResourceName     = new StructField <Bit7EncodedStringData>("ResourceName", new Bit7EncodedStringData(buffer, lengthSpan, stringSpan, Encoding.Unicode));
     DataOffset       = new StructField <UInt32Data>("DataOffset", new UInt32Data(buffer, stringSpan.End));
     Fields           = new BufferField[] {
         ResourceName,
         DataOffset,
     };
 }
Example #27
0
        private void FormatValue(object v, StringBuilder sb, StringFormat sf, Field f, int level, bool appendPropertyName = true)
        {
            if (appendPropertyName)
            {
                sb.AppendPropertyName(sf, f);
            }

            bool first = true;

            if (v == null)
            {
                sb.AppendNull(sf);
            }
            else if (f != null)
            {
                switch (f.SchemaType)
                {
                case SchemaType.Data:
                    DataField df = (DataField)f;
                    if (df.IsArray)
                    {
                        sb.StartArray(sf, level);
                        foreach (object vb in (IEnumerable)v)
                        {
                            if (first)
                            {
                                first = false;
                            }
                            else
                            {
                                sb.DivideObjects(sf, level);
                            }

                            sb.Append(sf, vb);
                        }
                        sb.EndArray(sf, level);
                    }
                    else
                    {
                        sb.Append(sf, v);
                    }
                    break;

                case SchemaType.Struct:
                    StructField stf = (StructField)f;
                    if (!(v is Row sRow))
                    {
                        //throw new FormatException($"expected {typeof(Row)} at {f.Path} but found {v.GetType()}");
                    }
                    else
                    {
                        ToString(sb, sRow.Values, sf, level + 1, stf.Fields);
                    }
                    break;
Example #28
0
        public TinyMethodBodyImpl(DotNetMethodProvider methodProvider, HexBufferSpan span, ReadOnlyCollection <uint> tokens)
            : base(methodProvider, span, tokens)
        {
            var buffer = span.Buffer;
            var pos    = span.Start.Position;

            Flags_CodeSize = new StructField <ByteFlagsData>("Flags_CodeSize", new ByteFlagsData(buffer, pos, flagsCodeSizeFlagInfos));
            Instructions   = new StructField <VirtualArrayData <ByteData> >(InstructionsFieldName, ArrayData.CreateVirtualByteArray(HexBufferSpan.FromBounds(span.Start + 1, span.End), InstructionsFieldName));
            Fields         = new BufferField[] {
                Flags_CodeSize,
                Instructions,
            };
        }
            public object setStructFieldData(object @struct, StructField field, object fieldValue)
            {
                OrcStruct orcStruct = (OrcStruct)@struct;
                int       offset    = ((Field)field).offset;

                // if the offset is bigger than our current number of fields, grow it
                if (orcStruct.getNumFields() <= offset)
                {
                    orcStruct.setNumFields(offset + 1);
                }
                orcStruct.setFieldValue(offset, fieldValue);
                return(@struct);
            }
        // Delete Method Implementation
        public StructField DeleteStructField(int id)
        {
            StructField structFieldDb = context.StructFields.Find(id);

            if (structFieldDb != null)
            {
                context.StructFields.Remove(structFieldDb);
            }

            context.SaveChanges();

            return(structFieldDb);
        }
Example #31
0
 private static void LiftConstructor(ClassWrapper wrapper)
 {
     foreach (MethodWrapper method in wrapper.GetMethods())
     {
         if (ICodeConstants.Init_Name.Equals(method.methodStruct.GetName()) && method.root
             != null)
         {
             Statement firstData = Statements.FindFirstData(method.root);
             if (firstData == null)
             {
                 return;
             }
             int            index       = 0;
             List <Exprent> lstExprents = firstData.GetExprents();
             foreach (Exprent exprent in lstExprents)
             {
                 int action = 0;
                 if (exprent.type == Exprent.Exprent_Assignment)
                 {
                     AssignmentExprent assignExpr = (AssignmentExprent)exprent;
                     if (assignExpr.GetLeft().type == Exprent.Exprent_Field && assignExpr.GetRight().type
                         == Exprent.Exprent_Var)
                     {
                         FieldExprent fExpr = (FieldExprent)assignExpr.GetLeft();
                         if (fExpr.GetClassname().Equals(wrapper.GetClassStruct().qualifiedName))
                         {
                             StructField structField = wrapper.GetClassStruct().GetField(fExpr.GetName(), fExpr
                                                                                         .GetDescriptor().descriptorString);
                             if (structField != null && structField.HasModifier(ICodeConstants.Acc_Final))
                             {
                                 action = 1;
                             }
                         }
                     }
                 }
                 else if (index > 0 && exprent.type == Exprent.Exprent_Invocation && Statements.IsInvocationInitConstructor
                              ((InvocationExprent)exprent, method, wrapper, true))
                 {
                     // this() or super()
                     lstExprents.Add(0, lstExprents.RemoveAtReturningValue(index));
                     action = 2;
                 }
                 if (action != 1)
                 {
                     break;
                 }
                 index++;
             }
         }
     }
 }
Example #32
0
 protected internal override bool CanLinkField(StructField nextField)
 {
     return nextField is ElseField || nextField is ElseIfField;
 }
Example #33
0
 public ImageCell(StructField def, Image value, int offset)
     : base(def, null, offset)
 {
     _image = value;
 }
Example #34
0
        /// <summary>
        /// Construct a StructMemberExpr with a struct field instance.
        /// </summary>
        /// <param name="value">StructType instance.</param>
        /// <param name="field">StructType's StructField instance.</param>
        public StructMemberExpr(Value value, StructField field)
        {
            if (!(value.ValueType is StructType))
                throw new HlslDomException("StructMemberExpr only valid on structs!");

            FieldValue = new Value(field.FieldType, value.Name + "." + field.FieldName);
        }