Sha256: 522d107d82029f00e2bc983bab113314ce0397bdcbdc53bbbd86080a7b75f1fe

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

class @InstructionNode extends Node
  constructor: (data, map) ->
    super
    @blocks = Object.extended()

  linkBlock: (block) ->
    @blocks[block.id] = block
    @operands?.each (x) => x.linkBlock(block) if x['linkBlock']?

  unlinkBlock: (block) ->
    delete @blocks[block.id]
    @operands?.each (x) => x.unlinkBlock(block) if x['unlinkBlock']?

  attachedFunctions: ->
    result = {}
    @blocks.values().each (x) -> Object.merge result, x.attachedFunctions()
    result

  update: (data, map) ->
    @type       = @locate(data['type'], map)
    @name       = data['name']
    @opcode     = data['opcode']
    @parameters = data['parameters']

    if data['operand_ids']
      @updateOperands(data['operand_ids'], map)
    else
      @operands = null

  updateOperands: (data, map) ->
    @operands = data.map (x) => @locate(x, map)

  title: ->
    if @type && !@type.void()
      JST['nodes/instruction']
        type: @type.title()
        name: @name
        opcode: @opcode
        parameters: @parameters
        operands: @titleizeOperands()
    else
      JST['nodes/instruction_void']
        opcode: @opcode
        parameters: @parameters
        operands: @titleizeOperands()

  titleizeOperands: ->
    return "<DETACHED>" unless @operands
    @operands.map((x) -> x.operandTitle()).join(', ')

  operandTitle: ->
    JST['nodes/operands/instruction']
      name: @name

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
furnace-xray-1.1.0.pre2 lib/furnace-xray/app/assets/javascripts/lib/nodes/instruction.js.coffee