Module: Nydp::Builtin::Base
- Includes:
- Helper
- Included in:
- Abs, Apply, CdrSet, Comment, Date, Divide, Ensuring, Error, Eval, GreaterThan, HandleError, Hash, HashGet, HashKeyPresent, HashKeys, HashMerge, HashSet, HashSlice, Inspect, IsEqual, LessThan, MathCeiling, MathFloor, MathPower, MathRound, Minus, Modulo, Parse, ParseInString, Plus, PreCompile, Puts, Quit, Rand, RandomString, Regexp, ScriptRun, SetIntersection, SetUnion, Sort, Sqrt, StringLength, StringMatch, StringPadLeft, StringPadRight, StringReplace, StringSplit, Sym, ThreadLocals, Time, Times, ToInteger, ToString, TypeOf, VmInfo
- Defined in:
- lib/nydp/builtin.rb
Instance Method Summary
collapse
-
#builtin_invoke(vm, args) ⇒ Object
-
#builtin_invoke_1(vm) ⇒ Object
-
#builtin_invoke_2(vm, a) ⇒ Object
-
#builtin_invoke_3(vm, a0, a1) ⇒ Object
-
#builtin_invoke_4(vm, a0, a1, a2) ⇒ Object
-
#handle_error(e, *args) ⇒ Object
-
#inspect ⇒ Object
-
#invoke(vm, args) ⇒ Object
called from ‘apply (among others).
-
#invoke_1(vm) ⇒ Object
-
#invoke_2(vm, arg) ⇒ Object
-
#invoke_3(vm, arg_0, arg_1) ⇒ Object
-
#invoke_4(vm, arg_0, arg_1, arg_2) ⇒ Object
-
#name ⇒ Object
-
#nydp_type ⇒ Object
-
#to_s ⇒ Object
Methods included from Helper
#cons, #list, #literal?, #pair?, #sig, #sym, #sym?
Methods included from Converter
#n2r, #r2n
Instance Method Details
#builtin_invoke(vm, args) ⇒ Object
5
|
# File 'lib/nydp/builtin.rb', line 5
def builtin_invoke vm, args ; raise "#{self.class.name} : please implement #builtin_invoke" ; end
|
#builtin_invoke_1(vm) ⇒ Object
6
|
# File 'lib/nydp/builtin.rb', line 6
def builtin_invoke_1 vm ; builtin_invoke vm, Nydp::NIL ; end
|
#builtin_invoke_2(vm, a) ⇒ Object
7
|
# File 'lib/nydp/builtin.rb', line 7
def builtin_invoke_2 vm, a ; builtin_invoke vm, cons(a) ; end
|
#builtin_invoke_3(vm, a0, a1) ⇒ Object
8
|
# File 'lib/nydp/builtin.rb', line 8
def builtin_invoke_3 vm, a0, a1 ; builtin_invoke vm, cons(a0, cons(a1)) ; end
|
#builtin_invoke_4(vm, a0, a1, a2) ⇒ Object
9
|
# File 'lib/nydp/builtin.rb', line 9
def builtin_invoke_4 vm, a0, a1, a2 ; builtin_invoke vm, cons(a0, cons(a1, cons(a2))) ; end
|
#handle_error(e, *args) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/nydp/builtin.rb', line 42
def handle_error e, *args
case e
when Nydp::Error
raise e
else
arg_msg = args.map { |a| " #{a.inspect}"}.join("\n")
new_msg = "Called #{self.inspect}\nwith args\n#{arg_msg}"
raise new_msg
end
end
|
60
|
# File 'lib/nydp/builtin.rb', line 60
def inspect ; "builtin/#{name}" ; end
|
#invoke(vm, args) ⇒ Object
called from ‘apply (among others)
36
37
38
39
40
|
# File 'lib/nydp/builtin.rb', line 36
def invoke vm, args
builtin_invoke vm, args
rescue StandardError => e
handle_error e, *(args.to_a)
end
|
#invoke_1(vm) ⇒ Object
11
12
13
14
15
|
# File 'lib/nydp/builtin.rb', line 11
def invoke_1 vm
builtin_invoke_1 vm
rescue StandardError => e
handle_error e
end
|
#invoke_2(vm, arg) ⇒ Object
17
18
19
20
21
|
# File 'lib/nydp/builtin.rb', line 17
def invoke_2 vm, arg
builtin_invoke_2 vm, arg
rescue StandardError => e
handle_error e, arg
end
|
#invoke_3(vm, arg_0, arg_1) ⇒ Object
23
24
25
26
27
|
# File 'lib/nydp/builtin.rb', line 23
def invoke_3 vm, arg_0, arg_1
builtin_invoke_3 vm, arg_0, arg_1
rescue StandardError => e
handle_error e, arg_0, arg_1
end
|
#invoke_4(vm, arg_0, arg_1, arg_2) ⇒ Object
29
30
31
32
33
|
# File 'lib/nydp/builtin.rb', line 29
def invoke_4 vm, arg_0, arg_1, arg_2
builtin_invoke_4 vm, arg_0, arg_1, arg_2
rescue StandardError => e
handle_error e, arg_0, arg_1, arg_2
end
|
53
54
55
56
57
58
|
# File 'lib/nydp/builtin.rb', line 53
def name
cname = self.class.name.split("::").last
cname = cname.gsub(/([a-z])([A-Z])/) { |m| "#{m[0]}-#{m[1].downcase}" }
cname = cname.gsub(/^([A-Z])/) { |m| m.downcase }
cname
end
|
#nydp_type ⇒ Object
62
|
# File 'lib/nydp/builtin.rb', line 62
def nydp_type ; "fn" ; end
|
61
|
# File 'lib/nydp/builtin.rb', line 61
def to_s ; name ; end
|