-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean nested struct from Class/SingletonClass/Module struct
- Loading branch information
Showing
4 changed files
with
121 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package mruby | ||
|
||
var _ RClass = &SingletonClass{} | ||
|
||
type SingletonClass struct { | ||
super RClass | ||
class RClass | ||
flags uint32 | ||
mt methodTable | ||
iv ivTable | ||
} | ||
|
||
func (c *SingletonClass) Class() RClass { | ||
return c.class | ||
} | ||
|
||
func (c *SingletonClass) Flags() uint32 { | ||
return c.flags | ||
} | ||
|
||
func (c *SingletonClass) ivPut(sym Symbol, val Value) { | ||
if c.iv == nil { | ||
c.iv = make(ivTable) | ||
} | ||
|
||
c.iv[sym] = val | ||
} | ||
|
||
func (c *SingletonClass) ivGet(sym Symbol) Value { | ||
if c.iv == nil { | ||
return nil | ||
} | ||
|
||
return c.iv[sym] | ||
} | ||
|
||
func (c *SingletonClass) mtPut(sym Symbol, method Method) { | ||
if c.mt == nil { | ||
c.mt = make(methodTable) | ||
} | ||
|
||
c.mt[sym] = method | ||
} | ||
|
||
func (c *SingletonClass) mtGet(sym Symbol) Method { | ||
if c.mt == nil { | ||
return nil | ||
} | ||
|
||
return c.mt[sym] | ||
} | ||
|
||
func (c *SingletonClass) Super() RClass { | ||
return c.super | ||
} |