array literals
This commit is contained in:
@@ -194,6 +194,16 @@ func (c *Compiler) Compile(node ast.Node) error {
|
||||
str := &object.String{Value: node.Value}
|
||||
c.emit(code.OpConstant, c.addConstant(str))
|
||||
|
||||
case *ast.ArrayLiteral:
|
||||
for _, el := range node.Elements {
|
||||
err := c.Compile(el)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
c.emit(code.OpArray, len(node.Elements))
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user