Skip to content

Commit 6de2e69

Browse files
committed
Cleanup compiler
1 parent ca8c768 commit 6de2e69

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

compiler/compiler.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ func Compile(tree *parser.Tree, config *conf.Config) (program *Program, err erro
4848
return
4949
}
5050

51+
const placeholder = MaxOpcode
52+
5153
type compiler struct {
5254
locations []file.Location
5355
constants []interface{}
@@ -116,10 +118,6 @@ func (c *compiler) addConstant(constant interface{}) Opcode {
116118
return p
117119
}
118120

119-
func (c *compiler) placeholder() Opcode {
120-
return 0
121-
}
122-
123121
func (c *compiler) patchJump(placeholder int) {
124122
offset := len(c.bytecode) - 1 - placeholder
125123
c.bytecode[placeholder] = Opcode(offset)
@@ -718,16 +716,3 @@ func kind(node ast.Node) reflect.Kind {
718716
}
719717
return t.Kind()
720718
}
721-
722-
func deref(t reflect.Type) reflect.Type {
723-
for t.Kind() == reflect.Ptr {
724-
t = t.Elem()
725-
}
726-
return t
727-
}
728-
729-
func isStruct(t reflect.Type) bool {
730-
return t.Kind() == reflect.Struct
731-
}
732-
733-
const placeholder = math.MaxUint32

vm/opcodes.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package vm
22

3+
import "math"
4+
35
type Opcode uint32
46

7+
const MaxOpcode = math.MaxUint32
8+
59
const (
610
OpPush Opcode = iota
711
OpPop

0 commit comments

Comments
 (0)