<commit_before>package asm

import (
  "fmt"
  "bitbucket.org/yyuu/xtc/core"
)

type IndirectMemoryReference struct {
  ClassName string
  Offset core.ILiteral
  Base core.IRegister
  Fixed bool
}

func NewIndirectMemoryReference(offset core.ILiteral, base core.IRegister, fixed bool) *IndirectMemoryReference {
  return &IndirectMemoryReference { "asm.IndirectMemoryReference", offset, base, fixed }
}

func (self *IndirectMemoryReference) AsOperand() core.IOperand {
  return self
}

func (self *IndirectMemoryReference) AsMemoryReference() core.IMemoryReference {
  return self
}

func (self IndirectMemoryReference) IsRegister() bool {
  return false
}

func (self IndirectMemoryReference) IsMemoryReference() bool {
  return true
}

func (self *IndirectMemoryReference) FixOffset(diff int64) {
  if self.Fixed {
    panic("must not happedn: fixed = true")
  }
  curr := self.Offset.(*IntegerLiteral).GetValue()
  self.Offset = NewIntegerLiteral(int64(curr + diff))
  self.Fixed = true
}

func (self *IndirectMemoryReference) CollectStatistics(stats core.IStatistics) {
  self.Base.CollectStatistics(stats)
}

func (self *IndirectMemoryReference) ToSource(table core.ISymbolTable) string {
  if ! self.Fixed {
    panic("must not happen: writing unfixed variable")
  } else {
    if self.Offset.IsZero() {
      return fmt.Sprintf("%s(%s)", self.Offset.ToSource(table), self.Base.ToSource(table))
    } else {
      return fmt.Sprintf("(%s)", self.Base.ToSource(table))
    }
  }
}

func (self *IndirectMemoryReference) String() string {
  return self.ToSource(DummySymbolTable)
}<commit_msg>Fix wrong offset calculation of indirect memref<commit_after>package asm

import (
  "fmt"
  "bitbucket.org/yyuu/xtc/core"
)

type IndirectMemoryReference struct {
  ClassName string
  Offset core.ILiteral
  Base core.IRegister
  Fixed bool
}

func NewIndirectMemoryReference(offset core.ILiteral, base core.IRegister, fixed bool) *IndirectMemoryReference {
  return &IndirectMemoryReference { "asm.IndirectMemoryReference", offset, base, fixed }
}

func (self *IndirectMemoryReference) AsOperand() core.IOperand {
  return self
}

func (self *IndirectMemoryReference) AsMemoryReference() core.IMemoryReference {
  return self
}

func (self IndirectMemoryReference) IsRegister() bool {
  return false
}

func (self IndirectMemoryReference) IsMemoryReference() bool {
  return true
}

func (self *IndirectMemoryReference) FixOffset(diff int64) {
  if self.Fixed {
    panic("must not happedn: fixed = true")
  }
  curr := self.Offset.(*IntegerLiteral).GetValue()
  self.Offset = NewIntegerLiteral(int64(curr + diff))
  self.Fixed = true
}

func (self *IndirectMemoryReference) CollectStatistics(stats core.IStatistics) {
  self.Base.CollectStatistics(stats)
}

func (self *IndirectMemoryReference) ToSource(table core.ISymbolTable) string {
  if ! self.Fixed {
    panic("must not happen: writing unfixed variable")
  } else {
    if self.Offset.IsZero() {
      return fmt.Sprintf("(%s)", self.Base.ToSource(table))
    } else {
      return fmt.Sprintf("%s(%s)", self.Offset.ToSource(table), self.Base.ToSource(table))
    }
  }
}

func (self *IndirectMemoryReference) String() string {
  return self.ToSource(DummySymbolTable)
}
{'fraction_non_alphanumeric': 0.11097334159950403, 'fraction_numerical': 0.0024798512089274642, 'mean_word_length': 4.856624319419238, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5302356', 'n_tokens_mistral': 1000, 'n_tokens_neox': 1000, 'n_words': 236}