brandjon | 9db98c4 | 2020-08-24 08:43:55 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | package com.google.devtools.build.lib.packages; |
| 16 | |
adonovan | 0afdecf | 2020-09-28 14:56:33 -0700 | [diff] [blame] | 17 | import com.google.devtools.build.docgen.annot.DocCategory; |
brandjon | 9db98c4 | 2020-08-24 08:43:55 -0700 | [diff] [blame] | 18 | import net.starlark.java.annot.StarlarkBuiltin; |
adonovan | 450c7ad | 2020-09-14 13:00:21 -0700 | [diff] [blame] | 19 | import net.starlark.java.eval.Printer; |
| 20 | import net.starlark.java.eval.StarlarkValue; |
brandjon | 9db98c4 | 2020-08-24 08:43:55 -0700 | [diff] [blame] | 21 | |
| 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", |
adonovan | 0afdecf | 2020-09-28 14:56:33 -0700 | [diff] [blame] | 27 | category = DocCategory.BUILTIN, |
brandjon | 9db98c4 | 2020-08-24 08:43:55 -0700 | [diff] [blame] | 28 | 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.") |
| 33 | public 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 | } |