Permalink
Browse files

Fuck up everything.

  • Loading branch information...
1 parent 62f98e2 commit 7d29b74512a93a38346e12b87cda38761b5d127b @grindars grindars committed Jan 8, 2012
View
@@ -1,4 +1,6 @@
source "http://rubygems.org"
gem "bindata"
-gem "furnace", :git => "git://github.com/whitequark/furnace.git"
+gem "furnace", :git => "git://github.com/whitequark/furnace.git"
+
+gem "trollop"
View
@@ -8,10 +8,12 @@ GEM
remote: http://rubygems.org/
specs:
bindata (1.4.3)
+ trollop (1.16.2)
PLATFORMS
ruby
DEPENDENCIES
bindata
furnace!
+ trollop
View
Binary file not shown.
View
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+
+require "rubygems"
+require "bundler/setup"
+
+$: << File.join(File.dirname(__FILE__), '..', 'lib')
+
+require "trollop"
+require "avm2"
+
+require 'trollop'
+
+opts = Trollop::options do
+ opt :input, "Input file"
+end
+
+abc = nil
+File.open(opts[:input]) do |file|
+ abc = AVM2::ABC::File.read(file)
+end
+
+p abc
View
@@ -1,35 +0,0 @@
-#!/usr/bin/env ruby
-
-require "rubygems"
-require "bundler/setup"
-
-$: << File.join(File.dirname(__FILE__), '..', 'lib')
-
-require "as3"
-
-lines = []
-function = nil
-
-ARGF.each do |line|
- if line =~ /^{ (.*)/
- function = $1
- lines = []
- elsif line =~ /^}/
- stream = AS3::Stream.new
- stream.parse_assembly(lines)
-
- transforms = [
- AS3::Transforms::DeadCodeElimination.new
- ]
-
- transforms.each do |transform|
- transform.run(stream)
- end
-
- puts "{ #{function}"
- puts stream.to_assembly
- puts "}"
- else
- lines << line
- end
-end
View
@@ -1,18 +0,0 @@
-require "bindata"
-
-require "furnace/cfg/node"
-require "furnace/cfg/edge"
-require "furnace/cfg/graph"
-
-require "furnace/graphviz"
-
-require "as3/opcode"
-
-require "as3/opcodes/unknown"
-require "as3/opcodes/branch"
-require "as3/opcodes/switch"
-require "as3/opcodes/nop"
-
-require "as3/transforms/dead_code_elimination"
-
-require "as3/stream"
View
@@ -1,50 +0,0 @@
-module AS3
- class Opcode
- attr_reader :stream, :record
-
- def initialize(stream)
- @stream = stream
- end
-
- def length
- @record.num_bytes
- end
-
- def bytes
- @record.to_binary_s.bytes.to_a
- end
-
- def description
- "undefined"
- end
-
- def serial
- @stream.serial_for self
- end
-
- def offset
- @stream.offset_for self
- end
-
- def prepare!
- end
-
- def update!
- end
-
- def redundant?
- false
- end
-
- def replace_with_nops!
- position = self.serial
-
- @stream.opcodes.delete_at(position)
- @stream.opcodes.insert(position, *self.length.times.map { Opcodes::NOP.new(@stream) } )
- end
-
- def to_s
- "#{serial} #{description}"
- end
- end
-end
View
@@ -1,40 +0,0 @@
-module AS3
- module Opcodes
- class Branch < Opcode
- class Record < BinData::Record
- endian :little
-
- uint8 :type
- int24 :target
- end
-
- attr_reader :target
-
- def initialize(stream, bytes)
- super(stream)
-
- @record = Record.read(bytes)
- end
-
- def prepare!
- @target = @stream.opcode_at_offset(offset + length + @record.target)
- end
-
- def update!
- @record.target = target.offset - offset - length
- end
-
- def description
- "_as3_X_BRANCH to:~#{@target.serial}"
- end
-
- def conditional?
- @record.type != 0x10
- end
-
- def redundant?
- @record.target == 0
- end
- end
- end
-end
View
@@ -1,26 +0,0 @@
-module AS3
- module Opcodes
- class NOP < Opcode
- class Record < BinData::Record
- endian :little
-
- uint8 :type
- end
-
- def initialize(stream, bytes=nil)
- super(stream)
-
- if bytes
- @record = Record.read(bytes)
- else
- @record = Record.new
- @record.type = 0x2
- end
- end
-
- def description
- "_as3_nop"
- end
- end
- end
-end
View
@@ -1,39 +0,0 @@
-module AS3
- module Opcodes
- class Switch < Opcode
- class Record < BinData::Record
- endian :little
-
- uint8 :type
- int24 :default_target
- bit30 :case_count, :value => lambda { case_targets.length - 1 }
- array :case_targets, :initial_length => lambda { case_count + 1 } do
- int24
- end
- end
-
- attr_reader :default_target, :case_targets
-
- def initialize(stream, bytes)
- super(stream)
-
- @record = Record.read(bytes)
- end
-
- def prepare!
- @default_target = @stream.opcode_at_offset(offset + @record.default_target)
- @case_targets = @record.case_targets.map { |off| @stream.opcode_at_offset off }
- end
-
- def update!
- @record.default_target = @default_target.offset - offset
- @record.case_targets = @case_targets.map { |target| target.offset - offset }
- end
-
- def description
- "_as3_lookupswitch ~#{@default_target.serial}(#{@case_targets.count - 1})" +
- "[#{@case_targets.map { |target| "~#{target.serial}" }.join ", "}]"
- end
- end
- end
-end
View
@@ -1,18 +0,0 @@
-module AS3
- module Opcodes
- class Unknown < Opcode
- attr_reader :bytes, :description
-
- def initialize(stream, bytes, description)
- super stream
-
- @bytes = bytes
- @description = description
- end
-
- def length
- @bytes.length
- end
- end
- end
-end
Oops, something went wrong.

0 comments on commit 7d29b74

Please sign in to comment.