Skip to content

Instantly share code, notes, and snippets.

View sunho's full-sized avatar
🐈
math is beutiful

Sunho Kim sunho

🐈
math is beutiful
View GitHub Profile
if len(gobyRoot) == 0 {
fmt.Sprintf("/usr/local/Cellar/goby/%s", Version)
path, _ := filepath.Abs("$GOPATH/src/github.com/goby-lang/goby")
func (vm *VM) newThread() *thread {
s := &stack{RWMutex: new(sync.RWMutex)}
cfs := &callFrameStack{callFrames: []callFrame{}}
t := &thread{stack: s, callFrameStack: cfs, sp: 0, cfp: 0}
s.thread = t
cfs.thread = t
t.vm = vm
return t
}
package classes
const (
ObjectClass = "Object"
ClassClass = "Class"
IntegerClass = "Integer"
FloatClass = "Float"
StringClass = "String"
ArrayClass = "Array"
HashClass = "Hash"
func (it *instructionTranslator) transferInstructionSets(sets []*bytecode.InstructionSet) []*instructionSet {
iss := []*instructionSet{}
for _, set := range sets {
it.transferInstructionSet(iss, set)
}
return iss
}
fmt.Errorf("Can't find anchor on action %s", i.Action)
switch p := param.(type) {
case string:
ps = append(ps, p)
case *anchor:
i.anchor = p
case int:
ps = append(ps, fmt.Sprint(p))
case bool:
ps = append(ps, fmt.Sprint(p))
}
type path []byte
func (p path) ToUpper() {
for i, b := range p {
if 'a' <= b && b <= 'z' {
p[i] = b + 'A' - 'a'
}
}
}
slice := make([]int, 10, 15)
fmt.Printf("len: %d, cap: %d\n", len(slice), cap(slice))
newSlice := make([]int, len(slice), 2*cap(slice))
for i := range slice {
newSlice[i] = slice[i]
}
slice = newSlice
func Extend(slice []int, element int) []int {
n := len(slice)