Closed kojix2 closed 7 years ago
Thank you for your report. The first example is working on my computer. Can you use the current master and see if it still works? Also can you write the commands that you used over here?
As for the second example:
lib "<math.h>"
double cos(double)
end
def stray_cos
return cos(4.5)
end
class A
def cos
return cos(4.5)
end
end
The A.new.cos
is not working because Rubex is assuming that cos
is a C method. Since C methods are not namespaced, it is currently not possible to use the same name as the C method for the Ruby method. So if you write code like this:
lib "<math.h>"
double cos(double)
end
def stray_cos
return cos(4.5)
end
class A
def ruby_cos
return cos(4.5)
end
end
It will work with A.new.ruby_cos
. I will write the namespacing feature in the future work soon.
A.new.ruby_cos
works good!
The first example still not work. I will think about it for a while. Thank you.
If there are any updates please post in this thread. Closing for now.
I tried experiment
m1.rubex
lib "<math.h>"
double sin(doublue)
end
def top_sin(x)
sin(x)
end
class RMath
def ruby_sin(x)
sin(x)
end
end
m2.rubex
lib "<math.h>"
double sin(doublue)
end
class RMath
def ruby_sin(x)
sin(x)
end
end
change rubex-0.0.1/lib/rubex/symbol_table/scope.rb
172 private
173 def recursive_find name, scope
174 if scope
175 require 'rainbow'
176 if scope.has_entry?(name)
177 puts Rainbow("+" << name.to_s << " in " << scope.name.to_s).green
178 return scope[name]
179 else
180 puts Rainbow("- " << name.to_s << " in " << scope.name.to_s).red
181 return recursive_find(name, scope.outer_scope)
182 end
183 end
184
185 return nil
186 end
rubex m1.rubex
+ Object in Object
+ Object in Object
+ top_sin in Object
+ x in top_sin
- sin in top_sin
+ sin in Object
- sin in top_sin
+ sin in Object
- sin in top_sin
+ sin in Object
- top_sin in top_sin
+ top_sin in Object
+ RMath in Object
+ ruby_sin in RMath
+ x in ruby_sin
- sin in ruby_sin
- sin in RMath
+ sin in Object
- sin in ruby_sin
- sin in RMath
+ sin in Object
- sin in ruby_sin
- sin in RMath
+ sin in Object
- ruby_sin in ruby_sin
+ ruby_sin in RMath
- sin in top_sin
+ sin in Object
- sin in ruby_sin
- sin in RMath
+ sin in Object
+ RMath in Object
+ Object in Object
+ Object in Object
+ RMath in Object
Succeeded
rubex m2.rubex
- Object in Object
+ RMath in Object
+ ruby_sin in RMath
+ x in ruby_sin
- sin in ruby_sin
- sin in RMath
- sin in Object
- sin in ruby_sin
- sin in RMath
- sin in Object
+ sin in ruby_sin
- ruby_sin in ruby_sin
+ ruby_sin in RMath
+ sin in ruby_sin
+ sin in ruby_sin
error
2.4.0/gems/rubex-0.0.1/lib/rubex/ast/expression.rb:694:in `code_for_ruby_method_call': undefined method `c_code' for nil:NilClass (NoMethodError)
Well. I do not know whether it is correct or wrong. Mr. v0dro, do you understand something?
Investigating.
Has been fixed in https://github.com/v0dro/rubex/commit/c9793b605855521c724d11de50ca09d4cc3020bb
Thank you for your report! Do send more :)
Hello. I tried the sample code. https://github.com/v0dro/rubex/pull/4#issuecomment-322530853
However, the following error occured on my computer.
The following code can be executed without error. But it shows me a bit strange behavior.
This is C file.
Perhaps the setting and the execution environment are not sufficient, and that may be the reason it does not work. However, as it may be useful for something, I will report it as it is. Thank you.