     @_name
   label: ->
     @_def.label || @name()
+  _jsonDef: ->
+    @_def
   type: ->
     @_type
   isStruct: ->

    res

  toJson: ->
    @_data
  @fromJson: (json) ->
    new ReflectResult(json)


      res[field.name()] = field.visit(callback)
    res

  addOpenField: (name, type) ->
    console.error 'operation not support for non-open structs' unless @isOpen()
    new_field = if type == 'struct'
      new StructMemberField(@, name, {type: {kind: 'struct', open: true}})
    else
      new ValueMemberField(@, name, type, {type: type})

    @fields().push(new_field)

    new_field

  _jsonDef: ->
    res = super
    if @isOpen()
      # update members if the struct is open
      res.type.members = {}
      for f in @fields()
        res.type.members[f.name()] = f._jsonDef()
    res

class ReflectResult
  constructor: (@_data) ->
    @_args = []
