rubinius-bridge 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2dbb2ca6500e8c06f2c9358506a5d69a652c49f4
4
+ data.tar.gz: dcf67697ecbc7b3114dd90e525cdc9552ab420c7
5
+ SHA512:
6
+ metadata.gz: ce9bbb99ddcd60c4c919c8742f0e678c3e6566eb1efab2ca036e9fccc986943a7b99ee47132d46ca550c60723df4666fc3f519714d37614c4ca4cd0ed08efee2
7
+ data.tar.gz: e955cbb8816cabf02a40457e4ebffcc2c4141b43dfbeeb9c6cdb776cd5ce06fc1b9d9ab81f8da939bbd91c4f2cb40a2fe9c09ef8dd8ce61b3303cd0010c150a8
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rubinius-bridge.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2013, Brian Shirai
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ 3. Neither the name of the library nor the names of its contributors may be
13
+ used to endorse or promote products derived from this software without
14
+ specific prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT,
20
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Rubinius::Bridge
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rubinius-bridge'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rubinius-bridge
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ class Array
2
+ def to_tuple
3
+ Rubinius::Tuple.new self
4
+ end
5
+ end
@@ -0,0 +1,63 @@
1
+ module Rubinius
2
+ class CompiledCode
3
+
4
+ attr_accessor :hints # added by the VM to indicate how it's being used.
5
+ attr_accessor :metadata # [Tuple] extra data
6
+ attr_accessor :name # [Symbol] name of the method
7
+ attr_accessor :iseq # [Tuple] instructions to execute
8
+ attr_accessor :stack_size # [Integer] size of stack at compile time
9
+ attr_accessor :local_count # [Integer] number of local vars
10
+ attr_accessor :required_args # [Integer] number of required args
11
+ attr_accessor :post_args # [Integer] number of args after splat
12
+ attr_accessor :total_args # [Integer] number of total args
13
+ attr_accessor :splat # [Integer] POSITION of the splat arg
14
+ attr_accessor :literals # [Tuple] tuple of the literals
15
+ attr_accessor :lines # [Tuple] tuple of the lines where its found
16
+ attr_accessor :file # [Symbol] the file where this comes from
17
+ attr_accessor :local_names # [Array<Symbol>] names of the local vars
18
+ attr_accessor :scope
19
+ attr_accessor :primitive
20
+ attr_accessor :block_index
21
+
22
+ def add_metadata(key, val)
23
+ raise TypeError, "key must be a symbol" unless key.kind_of? Symbol
24
+
25
+ case val
26
+ when true, false, Symbol, Fixnum, String
27
+ # ok
28
+ else
29
+ raise TypeError, "invalid type of value"
30
+ end
31
+
32
+ @metadata ||= nil # to deal with MRI seeing @metadata as not set
33
+
34
+ unless @metadata
35
+ @metadata = Tuple.new(2)
36
+ @metadata[0] = key
37
+ @metadata[1] = val
38
+ return val
39
+ end
40
+
41
+ i = 0
42
+ fin = @metadata.size
43
+
44
+ while i < fin
45
+ if @metadata[i] == key
46
+ @metadata[i + 1] = val
47
+ return val
48
+ end
49
+
50
+ i += 2
51
+ end
52
+
53
+ tup = Tuple.new(fin + 2)
54
+ tup.copy_from @metadata, 0, fin, 0
55
+ tup[fin] = key
56
+ tup[fin + 1] = val
57
+
58
+ @metadata = tup
59
+
60
+ return val
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,6 @@
1
+ class SyntaxError
2
+ def self.from(message, column, line, code, file)
3
+ message << " #{file}:#{line}:#{column}\n #{code}"
4
+ SyntaxError.new message
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Rubinius
2
+ class Executable
3
+ attr_accessor :primitive
4
+ end
5
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: us-ascii -*-
2
+
3
+ module Rubinius
4
+ class InstructionSequence
5
+ def initialize(size)
6
+ if size.kind_of? Tuple
7
+ @opcodes = size
8
+ else
9
+ @opcodes = Tuple.new(size)
10
+ end
11
+ end
12
+
13
+ attr_reader :opcodes
14
+
15
+ def ==(other)
16
+ other.kind_of?(InstructionSequence) and @opcodes == other.opcodes
17
+ end
18
+
19
+ def []=(idx, val)
20
+ @opcodes[idx] = val
21
+ end
22
+
23
+ def [](idx)
24
+ @opcodes[idx]
25
+ end
26
+
27
+ def size
28
+ @opcodes.size
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ module Rubinius
2
+ LookupTable = Hash
3
+ end
@@ -0,0 +1,18 @@
1
+ class Object
2
+ def StringValue(obj)
3
+ return obj if obj.kind_of?(String)
4
+
5
+ begin
6
+ obj.to_str
7
+ rescue Exception => orig
8
+ raise TypeError,
9
+ "Coercion error: #{obj.inspect}.to_str => String failed",
10
+ orig
11
+ end
12
+
13
+ return ret if ret.kind_of?(String)
14
+
15
+ msg = "Coercion error: obj.to_st did NOT return a String (was #{ret.class})"
16
+ raise TypeError, msg
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ module Rubinius
2
+ Config = { 'eval.cache' => false }
3
+
4
+ def synchronize(obj)
5
+ yield
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ class String
2
+ alias_method :append, :<<
3
+ alias_method :bytesize, :size unless method_defined?(:bytesize)
4
+ end
@@ -0,0 +1,9 @@
1
+ module Rubinius
2
+ class Tuple < Array
3
+ def copy_from(other, start, length, dest)
4
+ length.times do |i|
5
+ self[dest + i] = other[start + i]
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Rubinius
2
+ module Bridge
3
+ VERSION = "1.0.3"
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ require "redcard"
2
+ require "rubinius/bridge/version"
3
+
4
+ unless RedCard.check :rubinius
5
+ require "rubinius/bridge/object"
6
+ require "rubinius/bridge/array"
7
+ require "rubinius/bridge/string"
8
+ require "rubinius/bridge/rubinius"
9
+ require "rubinius/bridge/compiled_code"
10
+ require "rubinius/bridge/exception"
11
+ require "rubinius/bridge/executable"
12
+ require "rubinius/bridge/iseq"
13
+ require "rubinius/bridge/lookup_table"
14
+ require "rubinius/bridge/tuple"
15
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ require './lib/rubinius/bridge/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "rubinius-bridge"
6
+ spec.version = Rubinius::Bridge::VERSION
7
+ spec.authors = ["Brian Shirai"]
8
+ spec.email = ["brixen@gmail.com"]
9
+ spec.description = <<-EOD
10
+ Classes and methods to run other Rubinius tools under MRI.
11
+
12
+ Rubinius needs to bootstrap building its core library and code tools
13
+ because they are written in Ruby. One way to do this is to run the
14
+ code tools under MRI. To do so requires adding some classes and methods
15
+ that are built into Rubinius.
16
+ EOD
17
+ spec.summary = %q{Classes and methods to run other Rubinius tools under MRI.}
18
+ spec.homepage = ""
19
+ spec.license = "MIT"
20
+
21
+ spec.files = `git ls-files`.split($/)
22
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
23
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_runtime_dependency "redcard", "~> 1.0"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.3"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubinius-bridge
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Brian Shirai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: redcard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: |
56
+ Classes and methods to run other Rubinius tools under MRI.
57
+
58
+ Rubinius needs to bootstrap building its core library and code tools
59
+ because they are written in Ruby. One way to do this is to run the
60
+ code tools under MRI. To do so requires adding some classes and methods
61
+ that are built into Rubinius.
62
+ email:
63
+ - brixen@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".gitignore"
69
+ - Gemfile
70
+ - LICENSE
71
+ - README.md
72
+ - Rakefile
73
+ - lib/rubinius/bridge.rb
74
+ - lib/rubinius/bridge/array.rb
75
+ - lib/rubinius/bridge/compiled_code.rb
76
+ - lib/rubinius/bridge/exception.rb
77
+ - lib/rubinius/bridge/executable.rb
78
+ - lib/rubinius/bridge/iseq.rb
79
+ - lib/rubinius/bridge/lookup_table.rb
80
+ - lib/rubinius/bridge/object.rb
81
+ - lib/rubinius/bridge/rubinius.rb
82
+ - lib/rubinius/bridge/string.rb
83
+ - lib/rubinius/bridge/tuple.rb
84
+ - lib/rubinius/bridge/version.rb
85
+ - rubinius-bridge.gemspec
86
+ homepage: ''
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.0.7
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Classes and methods to run other Rubinius tools under MRI.
110
+ test_files: []
111
+ has_rdoc: