Exemple #1
0
        public void fill_memory(byte[] b, ref int dynamic_memory_start)
        {
            int elements_struct_size = this.list.Sum(l => l.struct_size());

            this.pointer_to_list = DataExtensions.FirstAvailableSize(b, dynamic_memory_start, elements_struct_size);

            Binary.BigEndian.Set(this.list.Count, b, address.Value);
            Binary.BigEndian.Set(this.pointer_to_list, b, address.Value + 4);


            DataExtensions.FillBytes(b, this.pointer_to_list, this.pointer_to_list + elements_struct_size);

            int curr_address = this.pointer_to_list;

            foreach (var item in list)
            {
                item.address  = curr_address;
                curr_address += item.struct_size();
            }
            if (curr_address > dynamic_memory_start)
            {
                dynamic_memory_start = curr_address;
            }
            foreach (var item in list)
            {
                item.fill_memory(b, ref dynamic_memory_start);
            }
        }
Exemple #2
0
        public void allocate_struct(byte[] b, int start_address)
        {
            this.address = start_address;//DataExtensions.FirstAvailableSize(b, start_address, struct_size());
            int curr_address = address.Value;

            foreach (var prop in properties)
            {
                prop.allocate_struct(b, curr_address);
                curr_address += prop.struct_size();
            }
            DataExtensions.FillBytes(b, this.address.Value, curr_address);
        }
Exemple #3
0
        public void fill_memory(byte[] b, ref int dynamic_memory_start)
        {
            int aligned_char_length = Program.GetAligned_u32(value.Length + 1);

            this.pointer_to_string = DataExtensions.FirstAvailableSize(b, dynamic_memory_start, aligned_char_length);
            DataExtensions.FillBytes(b, this.pointer_to_string, this.pointer_to_string + aligned_char_length);
            for (int i = 0; i < value.Length; i++)
            {
                b[i + this.pointer_to_string] = (byte)this.value[i];
            }
            b[value.Length + this.pointer_to_string] = (byte)'\0';

            Binary.BigEndian.Set(this.pointer_to_string, b, address.Value);
        }
Exemple #4
0
        public void fill_memory(byte[] b, ref int dynamic_memory_start)
        {
            int curr_address = this.address.Value;

            foreach (var prop in this.properties)
            {
                prop.address  = curr_address;
                curr_address += prop.struct_size();
            }
            DataExtensions.FillBytes(b, this.address.Value, curr_address);
            if (curr_address > dynamic_memory_start)
            {
                dynamic_memory_start = curr_address;
            }
            //dynamic_memory_start = curr_address;
            foreach (var prop in this.properties)
            {
                prop.fill_memory(b, ref dynamic_memory_start);
            }
        }
Exemple #5
0
 public void allocate_struct(byte[] b, int start_address)
 {
     this.address = start_address;
     DataExtensions.FillBytes(b, this.address.Value, this.address.Value + this.struct_size());
 }