blob: 3069e1aa1acdc445223a52f2dcdb515c9c01d05b [file] [log] [blame]
brandjon9db98c42020-08-24 08:43:55 -07001// Copyright 2020 The Bazel Authors. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package com.google.devtools.build.lib.packages;
16
adonovan0afdecf2020-09-28 14:56:33 -070017import com.google.devtools.build.docgen.annot.DocCategory;
brandjon9db98c42020-08-24 08:43:55 -070018import net.starlark.java.annot.StarlarkBuiltin;
adonovan450c7ad2020-09-14 13:00:21 -070019import net.starlark.java.eval.Printer;
20import net.starlark.java.eval.StarlarkValue;
brandjon9db98c42020-08-24 08:43:55 -070021
22// TODO(#11437): Factor an API out into skylarkbuildapi, for stardoc's benefit. Otherwise, stardoc
23// can't run on @builtins bzls.
24/** The {@code _internal} Starlark object, visible only to {@code @builtins} .bzls. */
25@StarlarkBuiltin(
26 name = "_internal",
adonovan0afdecf2020-09-28 14:56:33 -070027 category = DocCategory.BUILTIN,
brandjon9db98c42020-08-24 08:43:55 -070028 documented = false,
29 doc =
30 "A module accessible only to @builtins .bzls, that permits access to the original "
31 + "(uninjected) native builtins, as well as internal-only symbols not accessible to "
32 + "users.")
33public class InternalModule implements StarlarkValue {
34
35 // TODO(#11437): Can't use a singleton once we're re-exporting fields of the native object.
36 public static final InternalModule INSTANCE = new InternalModule();
37
38 private InternalModule() {}
39
40 @Override
41 public void repr(Printer printer) {
42 printer.append("<_internal module>");
43 }
44
45 @Override
46 public boolean isImmutable() {
47 return true;
48 }
49
50 @Override
51 public boolean isHashable() {
52 return true;
53 }
54}