Browse Source

compiler: create eval vm lazily

Denys Smirnov 8 years ago
parent
commit
2e54e35d67
2 changed files with 3 additions and 1 deletions
  1. 0 1
      compiler.go
  2. 3 0
      compiler_expr.go

+ 0 - 1
compiler.go

@@ -129,7 +129,6 @@ func newCompiler() *compiler {
 
 
 	c.newScope()
 	c.newScope()
 	c.scope.dynamic = true
 	c.scope.dynamic = true
-	c.evalVM = New().vm
 	return c
 	return c
 }
 }
 
 

+ 3 - 0
compiler_expr.go

@@ -995,6 +995,9 @@ func (c *compiler) evalConst(expr compiledExpr) (Value, *Exception) {
 	if expr, ok := expr.(*compiledLiteral); ok {
 	if expr, ok := expr.(*compiledLiteral); ok {
 		return expr.val, nil
 		return expr.val, nil
 	}
 	}
+	if c.evalVM == nil {
+		c.evalVM = New().vm
+	}
 	var savedPrg *Program
 	var savedPrg *Program
 	createdPrg := false
 	createdPrg := false
 	if c.evalVM.prg == nil {
 	if c.evalVM.prg == nil {