Module: FastRuby

Extended by:
SingletonLogger
Defined in:
lib/fastruby/logging.rb,
lib/fastruby.rb,
lib/fastruby/object.rb,
lib/fastruby/builder.rb,
lib/fastruby/modules.rb,
lib/fastruby/set_tree.rb,
lib/fastruby/getlocals.rb,
lib/fastruby_load_path.rb,
lib/fastruby/exceptions.rb,
lib/fastruby/cache/cache.rb,
lib/fastruby/fastruby_sexp.rb,
lib/fastruby/sexp_extension.rb,
lib/fastruby/builder/inliner.rb,
lib/fastruby/builder/pipeline.rb,
lib/fastruby/builder/reductor.rb,
lib/fastruby/method_extension.rb,
lib/fastruby/builder/lvar_type.rb,
lib/fastruby/builder/inferencer.rb,
lib/fastruby/modules/inliner/call.rb,
lib/fastruby/modules/inliner/defn.rb,
lib/fastruby/modules/reductor/for.rb,
lib/fastruby/sexp_extension_edges.rb,
lib/fastruby/modules/reductor/case.rb,
lib/fastruby/translator/translator.rb,
lib/fastruby/modules/lvar_type/call.rb,
lib/fastruby/modules/lvar_type/defn.rb,
lib/fastruby/modules/lvar_type/lasgn.rb,
lib/fastruby/modules/translator/call.rb,
lib/fastruby/modules/translator/defn.rb,
lib/fastruby/modules/translator/flow.rb,
lib/fastruby/modules/translator/iter.rb,
lib/fastruby/builder/locals_inference.rb,
lib/fastruby/modules/inferencer/infer.rb,
lib/fastruby/modules/reductor/nontree.rb,
lib/fastruby/modules/translator/block.rb,
lib/fastruby/builder/inference_updater.rb,
lib/fastruby/modules/inliner/recursive.rb,
lib/fastruby/modules/translator/static.rb,
lib/fastruby/modules/inferencer/literal.rb,
lib/fastruby/modules/reductor/recursive.rb,
lib/fastruby/modules/translator/literal.rb,
lib/fastruby/modules/translator/logical.rb,
lib/fastruby/modules/lvar_type/recursive.rb,
lib/fastruby/modules/translator/nonlocal.rb,
lib/fastruby/modules/translator/variable.rb,
lib/fastruby/modules/translator/directive.rb,
lib/fastruby/translator/scope_mode_helper.rb,
lib/fastruby/modules/translator/exceptions.rb,
lib/fastruby/translator/translator_modules.rb,
lib/fastruby/modules/reductor/fastruby_flag.rb,
lib/fastruby/modules/translator/method_group.rb

Overview

This file is part of the fastruby project, github.com/tario/fastruby

Copyright © 2011 Roberto Dario Seminara <[email protected]>

fastruby is free software: you can redistribute it and/or modify it under the terms of the gnu general public license as published by the free software foundation, either version 3 of the license, or (at your option) any later version.

fastruby is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. see the gnu general public license for more details.

you should have received a copy of the gnu general public license along with fastruby. if not, see <www.gnu.org/licenses/>.

Defined Under Namespace

Modules: BuilderModule, MethodExtension, Modules, SingletonLogger Classes: Cache, Context, FastRubySexp, GetLocalsProcessor, Graph, InferenceUpdater, Inferencer, Inliner, JumpTagException, LocalsInference, LvarType, Method, Pipeline, Reductor, ScopeModeHelper, TranslatorModules, TypeMismatchAssignmentException

Constant Summary collapse

VERSION =
"0.0.22"

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from SingletonLogger

logger

Class Attribute Details

.fastruby_load_pathObject

Returns the value of attribute fastruby_load_path.



24
25
26
# File 'lib/fastruby_load_path.rb', line 24

def fastruby_load_path
  @fastruby_load_path
end

.fastruby_script_pathObject

Returns the value of attribute fastruby_script_path.



23
24
25
# File 'lib/fastruby_load_path.rb', line 23

def fastruby_script_path
  @fastruby_script_path
end

Class Method Details

.cacheObject



26
27
28
29
# File 'lib/fastruby/cache/cache.rb', line 26

def self.cache
  @@cache = FastRuby::Cache.new(ENV['HOME']+"/.fastruby/") unless defined? @@cache
  @@cache
end

.encapsulate_tree(tree, method_name) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fastruby/object.rb', line 44

def self.encapsulate_tree(tree, method_name)
    generated_tree = tree

    if generated_tree[0] == :scope
      generated_tree = s(:defn, method_name.to_sym, s(:args),
              s(:scope, s(:block, generated_tree[1])))
    elsif generated_tree[0] == :block
      generated_tree = s(:defn, method_name.to_sym, s(:args),
                  s(:scope, generated_tree))
    else
      generated_tree = s(:defn, method_name.to_sym, s(:args),
                  s(:scope, s(:block, generated_tree)))
    end

    generated_tree.to_fastruby_sexp
end

.make_str_signature(method_name, signature) ⇒ Object



27
28
29
# File 'lib/fastruby/set_tree.rb', line 27

def self.make_str_signature(method_name, signature)
  "_" + method_name.to_s + signature.map(&:__id__).map(&:to_s).join
end

.set_builder_module(klass) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/fastruby/set_tree.rb', line 31

def self.set_builder_module(klass)
  klass.class_eval do
    class << self
      include FastRuby::BuilderModule
    end
  end
end

.set_tree(klass, method_name, tree, options = {}) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/fastruby/set_tree.rb', line 46

def self.set_tree(klass, method_name, tree, options = {})
  unless options[:skip_reduce]
    unless defined? Reductor
      require "fastruby/builder/reductor"
    end
    
    tree = Reductor.new.reduce(tree)
  end

  klass.class_eval do
    class << self
      include FastRuby::BuilderModule
    end
  end

  fastrubym = klass.fastruby_method(method_name)
  
  fastrubym.tree = tree
  fastrubym.options = options
  fastrubym.tree_changed

  nil
end

.unset_tree(klass, method_name) ⇒ Object



39
40
41
42
43
44
# File 'lib/fastruby/set_tree.rb', line 39

def self.unset_tree(klass, method_name)
  fastrubym = klass.fastruby_method(method_name)
  fastrubym.tree = nil
  fastrubym.tree_changed
  nil
end