code: func (l *State) SetMetaTable(index int) {
  	l.checkElementCount(1)
  	mt, ok := l.stack[l.top-1].(*table)
  	if apiCheck && !ok && l.stack[l.top-1] != nil {
  		panic("table expected")
  	}
  	switch v := l.indexToValue(index).(type) {
  	case *table:
  		v.metaTable = mt
  	case *userData:
  		v.metaTable = mt
  	default:
  		l.global.metaTables[l.TypeOf(index)] = mt
  	}
  	l.top--
  }
docs: // SetMetaTable pops a table from the stack and sets it as the new metatable
  // for the value at index.
  //
  // http://www.lua.org/manual/5.2/manual.html#lua_setmetatable