package rts

type ModObj struct {
	name string
	exp  map[string]Value
}

func NewModObj(name string, exp map[string]Value) *ModObj {
	return &ModObj{name: name, exp: CloneDict(exp)}
}

func (m *ModObj) TypeName() string { return "module:" + m.name }

func (m *ModObj) GetMember(name string) (Value, bool) {
	v, ok := m.exp[name]
	return v, ok
}

func (m *ModObj) Index(key Value) (Value, error) {
	k, err := Key(Pos{}, key)
	if err != nil {
		return Null(), err
	}

	v, ok := m.exp[k]
	if !ok {
		return Null(), nil
	}
	return v, nil
}
