convinius 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -45,6 +45,12 @@ A more realistic example:
45
45
  include Awesome
46
46
  end
47
47
 
48
+ Import constants from Rubinius
49
+ ------------------------------
50
+ in: `convinius/globals`
51
+
52
+ Defines global constants `Tuple` and `Fiber`.
53
+
48
54
  Convenience for Rubinius::Generator
49
55
  -----------------------------------
50
56
  in: `convinius/generator`
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'convinius'
3
- s.version = '0.1.1'
3
+ s.version = '0.2.0'
4
4
  s.date = '2011-01-26'
5
5
  s.description = 'Convenience library for Rubinius-only projects.'
6
6
  s.summary = s.description
@@ -1,3 +1,4 @@
1
1
  require 'convinius/asm'
2
2
  require 'convinius/generator'
3
+ require 'convinius/globals'
3
4
  require 'convinius/to_class'
@@ -2,33 +2,14 @@ module Convinius
2
2
  module ASM
3
3
  extend self
4
4
 
5
- def asm(file = "(asm)", line = 1, method = :call, &block)
6
- g = Rubinius::Generator.new
7
- g.name = method.to_sym
8
- g.file = file.to_sym
9
- g.set_line line
10
-
11
- g.required_args = 0
12
- g.total_args = 0
13
- g.splat_index = nil
14
-
15
- g.local_count = 0
16
- g.local_names = []
17
-
18
- block.arity > 0 ? yield(g) : g.instance_eval(&block)
19
-
20
- g.ret
21
- g.close
22
-
23
- g.encode
24
- cm = g.package Rubinius::CompiledMethod
25
- puts cm.decode if $DEBUG
26
-
27
- code = Object.new
28
- ss = Rubinius::StaticScope.new Object
29
- Rubinius.attach_method g.name, cm, ss, code
30
-
31
- code
5
+ def asm(opts = {}, &block)
6
+ object = opts[:object] || Object.new
7
+ opts = { :file => "(asm)", :line => 1, :method => :call }.merge! opts
8
+ Rubinius.object_metaclass(object).dynamic_method(opts[:method], opts[:file], opts[:line]) do |g|
9
+ block.arity > 0 ? yield(g) : g.instance_eval(&block)
10
+ g.ret
11
+ end
12
+ object
32
13
  end
33
14
 
34
15
  class << self
@@ -3,10 +3,16 @@ module Convinius
3
3
  append_features Rubinius::Generator
4
4
 
5
5
  def make_tuple(count)
6
- push_rubinius
7
- find_const :Tuple
8
- move_down count
9
- send :[], count
6
+ push count
7
+ invoke_primitive :tuple_allocate, 1
8
+ (count - 1).downto(0) do |i|
9
+ dup
10
+ rotate 3
11
+ push i
12
+ swap
13
+ invoke_primitive :tuple_put, 3
14
+ pop
15
+ end
10
16
  end
11
17
  end
12
18
  end
@@ -0,0 +1,4 @@
1
+ require 'fiber'
2
+
3
+ Tuple = Rubinius::Tuple unless defined? Tuple
4
+ Fiber = Rubinius::Fiber unless defined? Fiber
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: convinius
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Konstantin Haase
@@ -34,6 +34,7 @@ files:
34
34
  - lib/convinius.rb
35
35
  - lib/convinius/asm.rb
36
36
  - lib/convinius/generator.rb
37
+ - lib/convinius/globals.rb
37
38
  - lib/convinius/to_class.rb
38
39
  - spec/asm_spec.rb
39
40
  - spec/generator_spec.rb