Add an alloc.NewDynamic helper function
@@ -4,6 +4,7 @@ package eval
import (
"github.com/pulumi/coconut/pkg/compiler/symbols"
+ "github.com/pulumi/coconut/pkg/compiler/types"
"github.com/pulumi/coconut/pkg/diag"
"github.com/pulumi/coconut/pkg/eval/rt"
)
@@ -39,6 +40,13 @@ func (a *Allocator) NewArray(tree diag.Diagable, elem symbols.Type, arr *[]*rt.P
return obj
}
+// NewDynamic creates a new dynamic object, optionally using a set of existing properties.
+func (a *Allocator) NewDynamic(tree diag.Diagable, properties rt.PropertyMap) *rt.Object {
+ obj := rt.NewObject(types.Dynamic, nil, properties, nil)
+ a.onNewObject(tree, obj)
+ return obj
+}
+
// NewPrimitive creates a new primitive object with the given primitive type.
func (a *Allocator) NewPrimitive(tree diag.Diagable, t symbols.Type, v interface{}) *rt.Object {
obj := rt.NewPrimitiveObject(t, v)
