class MachineCode

MachineCode is an abstract machine that has subclasses for each concrete machine type that you can write assembly language for. Right now this library only supports X86, so look at MachineCodeX86 for more details on how to use it.

Attributes

bits[RW]
cachedInstructions[RW]
instructions[W]
procedure[RW]
processors[R]
stream[RW]

Public Class Methods

new() click to toggle source
# File lib/wilson.rb, line 519
def initialize
  self.procedure  = nil
  self.bits       = self.defaultBits
  self.processors = self.defaultProcessors
  self.stream     = []

  self.setupMachine
end

Public Instance Methods

assemble(instruction) click to toggle source
# File lib/wilson.rb, line 565
def assemble instruction
  raise "no"
  #     aBlock on: MessageNotUnderstood do: [:ex |
  #         ex originator class = BlockClosure ifFalse: [ex pass].
  #         ex resume: (ex originator value m perform: ex parameter selector withArguments: ex parameter arguments)]</body>
end
future_label() click to toggle source
# File lib/wilson.rb, line 561
def future_label
  FutureLabel.on self
end
inspect() click to toggle source
# File lib/wilson.rb, line 528
def inspect
  "#{self.class}#{stream.inspect}"
end
instructionFromMessage(msg, *args) click to toggle source
# File lib/wilson.rb, line 553
def instructionFromMessage msg, *args
  Instruction.on_message self, [msg, *args]
end
instructions() click to toggle source
# File lib/wilson.rb, line 542
def instructions
  self.cachedInstructions ||= @instructions.select { |e|
    self.supportsProcessor e.processors
  }
  self.cachedInstructions
end
label() click to toggle source
# File lib/wilson.rb, line 557
def label
  Label.on_at(self, stream.size)
end
method_missing(msg, *args) click to toggle source
Calls superclass method
# File lib/wilson.rb, line 549
def method_missing msg, *args
  super unless self.instructionFromMessage(msg, *args).assemble
end
processors=(o) click to toggle source
# File lib/wilson.rb, line 532
def processors= o
  @processors = o
  @cachedInstructions = nil
end
supportsProcessor(instructionProcessors) click to toggle source
# File lib/wilson.rb, line 537
def supportsProcessor instructionProcessors
  # TODO: can still be improved. hashes, caching... something
  ! (processors & instructionProcessors).empty?
end