-
Notifications
You must be signed in to change notification settings - Fork 1
/
proc.go
58 lines (45 loc) · 809 Bytes
/
proc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package mruby
import "github.com/elct9620/mruby-go/insn"
func AspecReq(n int) int {
return (((n) >> 18) & 0x1f)
}
func AspecOpt(n int) int {
return (((n) >> 13) & 0x1f)
}
func AspecRest(n int) int {
return (((n) >> 12) & 0x1)
}
type RProc interface {
IsGoFunction() bool
Body() any
}
var _ RProc = &proc{}
var _ RBasic = &proc{}
type proc struct {
Object
body any
}
func (p *proc) IsGoFunction() bool {
if _, ok := p.body.(Function); ok {
return true
}
return false
}
func (p *proc) Body() any {
return p.body
}
func newMethodFromFunc(function Function) Method {
return &method{
Function: function,
}
}
func newMethodFromProc(proc RProc) Method {
return &method{
RProc: proc,
}
}
func (mrb *State) procNew(irep *insn.Representation) RProc {
return &proc{
body: irep,
}
}