Skip to content

Commit

Permalink
Rename SkylarkSemantics to StarlarkSemantics
Browse files Browse the repository at this point in the history
RELNOTES: None.
PiperOrigin-RevId: 234478524
  • Loading branch information
laurentlb authored and copybara-github committed Feb 18, 2019
1 parent aca1e87 commit 6659b4c
Show file tree
Hide file tree
Showing 95 changed files with 572 additions and 576 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import com.google.devtools.build.lib.syntax.FuncallExpression;
import com.google.devtools.build.lib.syntax.FunctionSignature;
import com.google.devtools.build.lib.syntax.MethodDescriptor;
import com.google.devtools.build.lib.syntax.SkylarkSemantics;
import com.google.devtools.build.lib.syntax.SkylarkSignatureProcessor;
import com.google.devtools.build.lib.syntax.SkylarkType;
import com.google.devtools.build.lib.syntax.StarlarkSemantics;
import com.google.devtools.common.options.OptionsParser;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -113,10 +113,10 @@ private static void appendBzlGlobals(
SkylarkModule typeModule = SkylarkInterfaceUtils.getSkylarkModule(obj.getClass());
if (typeModule != null) {
if (FuncallExpression.hasSelfCallMethod(
SkylarkSemantics.DEFAULT_SEMANTICS, obj.getClass())) {
StarlarkSemantics.DEFAULT_SEMANTICS, obj.getClass())) {
MethodDescriptor descriptor =
FuncallExpression.getSelfCallMethodDescriptor(
SkylarkSemantics.DEFAULT_SEMANTICS, obj);
StarlarkSemantics.DEFAULT_SEMANTICS, obj);

value = collectFunctionInfo(
descriptor.getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable;
import com.google.devtools.build.lib.skylarkinterface.SkylarkInterfaceUtils;
import com.google.devtools.build.lib.syntax.EvalUtils;
import com.google.devtools.build.lib.syntax.SkylarkSemantics.FlagIdentifier;
import com.google.devtools.build.lib.syntax.StarlarkSemantics.FlagIdentifier;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import com.google.devtools.build.lib.skylarkinterface.Param;
import com.google.devtools.build.lib.skylarkinterface.ParamType;
import com.google.devtools.build.lib.syntax.SkylarkSemantics.FlagIdentifier;
import com.google.devtools.build.lib.syntax.StarlarkSemantics.FlagIdentifier;

/**
* A class containing the documentation for a Skylark method parameter.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/google/devtools/build/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ java_library(
java_library(
name = "skylark_semantics",
srcs = [
"syntax/SkylarkSemantics.java",
"syntax/StarlarkSemantics.java",
],
deps = [
"//third_party:auto_value",
Expand Down Expand Up @@ -456,7 +456,7 @@ java_library(

java_library(
name = "skylark-semantics",
srcs = ["syntax/SkylarkSemantics.java"],
srcs = ["syntax/StarlarkSemantics.java"],
deps = [
"//third_party:auto_value",
"//third_party:guava",
Expand All @@ -469,7 +469,7 @@ java_library(
[
"syntax/**/*.java",
],
exclude = ["syntax/SkylarkSemantics.java"],
exclude = ["syntax/StarlarkSemantics.java"],
),
deps = [
":events",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoKey;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.events.ExtendedEventHandler;
import com.google.devtools.build.lib.syntax.SkylarkSemantics;
import com.google.devtools.build.lib.syntax.StarlarkSemantics;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.skyframe.SkyFunction;

Expand Down Expand Up @@ -123,7 +123,7 @@ public interface AnalysisEnvironment extends ActionRegistry {
* Returns the options that affect the Skylark interpreter used for evaluating Skylark rule
* implementation functions.
*/
SkylarkSemantics getSkylarkSemantics() throws InterruptedException;
StarlarkSemantics getSkylarkSemantics() throws InterruptedException;

/**
* Returns the Artifact that is used to hold the non-volatile workspace status for the current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import com.google.devtools.build.lib.skyframe.BuildInfoCollectionValue;
import com.google.devtools.build.lib.skyframe.PrecomputedValue;
import com.google.devtools.build.lib.skyframe.WorkspaceStatusValue;
import com.google.devtools.build.lib.syntax.SkylarkSemantics;
import com.google.devtools.build.lib.syntax.StarlarkSemantics;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.skyframe.SkyFunction;
import java.io.PrintWriter;
Expand Down Expand Up @@ -305,7 +305,7 @@ public SkyFunction.Environment getSkyframeEnv() {
}

@Override
public SkylarkSemantics getSkylarkSemantics() throws InterruptedException {
public StarlarkSemantics getSkylarkSemantics() throws InterruptedException {
return PrecomputedValue.SKYLARK_SEMANTICS.get(skyframeEnv);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
import com.google.devtools.build.lib.syntax.Environment.Extension;
import com.google.devtools.build.lib.syntax.Environment.GlobalFrame;
import com.google.devtools.build.lib.syntax.Mutability;
import com.google.devtools.build.lib.syntax.SkylarkSemantics;
import com.google.devtools.build.lib.syntax.SkylarkUtils;
import com.google.devtools.build.lib.syntax.SkylarkUtils.Phase;
import com.google.devtools.build.lib.syntax.StarlarkSemantics;
import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.common.options.OptionDefinition;
import com.google.devtools.common.options.OptionsProvider;
Expand Down Expand Up @@ -777,7 +777,7 @@ private static ImmutableMap<String, Class<?>> createFragmentMap(
private Environment createSkylarkRuleClassEnvironment(
Mutability mutability,
GlobalFrame globals,
SkylarkSemantics skylarkSemantics,
StarlarkSemantics starlarkSemantics,
EventHandler eventHandler,
String astFileContentHashCode,
Map<String, Extension> importMap,
Expand All @@ -792,7 +792,7 @@ private Environment createSkylarkRuleClassEnvironment(
Environment env =
Environment.builder(mutability)
.setGlobals(globals)
.setSemantics(skylarkSemantics)
.setSemantics(starlarkSemantics)
.setEventHandler(eventHandler)
.setFileContentHashCode(astFileContentHashCode)
.setStarlarkContext(context)
Expand All @@ -806,15 +806,15 @@ private Environment createSkylarkRuleClassEnvironment(
public Environment createSkylarkRuleClassEnvironment(
Label extensionLabel,
Mutability mutability,
SkylarkSemantics skylarkSemantics,
StarlarkSemantics starlarkSemantics,
EventHandler eventHandler,
String astFileContentHashCode,
Map<String, Extension> importMap,
ImmutableMap<RepositoryName, RepositoryName> repoMapping) {
return createSkylarkRuleClassEnvironment(
mutability,
globals.withLabel(extensionLabel),
skylarkSemantics,
starlarkSemantics,
eventHandler,
astFileContentHashCode,
importMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.syntax.Mutability;
import com.google.devtools.build.lib.syntax.SkylarkDict;
import com.google.devtools.build.lib.syntax.SkylarkSemantics;
import com.google.devtools.build.lib.syntax.StarlarkSemantics;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -106,7 +106,7 @@ public static StarlarkDefinedConfigTransition newRegularTransition(
BaseFunction impl,
List<String> inputs,
List<String> outputs,
SkylarkSemantics semantics,
StarlarkSemantics semantics,
StarlarkContext context) {
return new RegularTransition(impl, inputs, outputs, semantics, context);
}
Expand Down Expand Up @@ -162,14 +162,14 @@ public int hashCode() {

private static class RegularTransition extends StarlarkDefinedConfigTransition {
private final BaseFunction impl;
private final SkylarkSemantics semantics;
private final StarlarkSemantics semantics;
private final StarlarkContext starlarkContext;

public RegularTransition(
BaseFunction impl,
List<String> inputs,
List<String> outputs,
SkylarkSemantics semantics,
StarlarkSemantics semantics,
StarlarkContext context) {
super(inputs, outputs, impl.getLocation());
this.impl = impl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
import com.google.devtools.build.lib.syntax.SkylarkList;
import com.google.devtools.build.lib.syntax.SkylarkMutable;
import com.google.devtools.build.lib.syntax.SkylarkNestedSet;
import com.google.devtools.build.lib.syntax.SkylarkSemantics;
import com.google.devtools.build.lib.syntax.StarlarkSemantics;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.protobuf.GeneratedMessage;
import java.nio.charset.StandardCharsets;
Expand All @@ -81,17 +81,15 @@
/** Provides a Skylark interface for all action creation needs. */
public class SkylarkActionFactory implements SkylarkActionFactoryApi {
private final SkylarkRuleContext context;
private final SkylarkSemantics skylarkSemantics;
private final StarlarkSemantics starlarkSemantics;
private RuleContext ruleContext;
/** Counter for actions.run_shell helper scripts. Every script must have a unique name. */
private int runShellOutputCounter = 0;

public SkylarkActionFactory(
SkylarkRuleContext context,
SkylarkSemantics skylarkSemantics,
RuleContext ruleContext) {
SkylarkRuleContext context, StarlarkSemantics starlarkSemantics, RuleContext ruleContext) {
this.context = context;
this.skylarkSemantics = skylarkSemantics;
this.starlarkSemantics = starlarkSemantics;
this.ruleContext = ruleContext;
}

Expand Down Expand Up @@ -198,7 +196,7 @@ public void write(FileApi output, Object content, Boolean isExecutable, Location
action =
new ParameterFileWriteAction(
ruleContext.getActionOwner(),
skylarkSemantics.incompatibleExpandDirectories()
starlarkSemantics.incompatibleExpandDirectories()
? args.getDirectoryArtifacts()
: ImmutableList.of(),
(Artifact) output,
Expand Down Expand Up @@ -459,7 +457,7 @@ private void registerSpawnAction(
}
} else {
// Users didn't pass 'tools', kick in compatibility modes
if (skylarkSemantics.incompatibleNoSupportToolsInActionInputs()) {
if (starlarkSemantics.incompatibleNoSupportToolsInActionInputs()) {
// In this mode we error out if we find any tools among the inputs
List<Artifact> tools = null;
for (Artifact artifact : inputArtifacts) {
Expand Down Expand Up @@ -594,7 +592,7 @@ private static String convertLatin1ToUtf8(String latin1) {
@VisibleForTesting
public static class Args extends SkylarkMutable implements CommandLineArgsApi {
private final Mutability mutability;
private final SkylarkSemantics skylarkSemantics;
private final StarlarkSemantics starlarkSemantics;
private final SkylarkCustomCommandLine.Builder commandLine;
private List<NestedSet<Object>> potentialDirectoryArtifacts = new ArrayList<>();
private final Set<Artifact> directoryArtifacts = new HashSet<>();
Expand Down Expand Up @@ -627,7 +625,7 @@ public CommandLineArgsApi addArgument(
commandLine.add(argName);
}
if (value instanceof SkylarkNestedSet || value instanceof SkylarkList) {
if (skylarkSemantics.incompatibleDisallowOldStyleArgsAdd()) {
if (starlarkSemantics.incompatibleDisallowOldStyleArgsAdd()) {
throw new EvalException(
loc,
"Args#add no longer accepts vectorized arguments when "
Expand All @@ -645,12 +643,12 @@ public CommandLineArgsApi addArgument(
/* formatJoined= */ null,
/* omitIfEmpty= */ false,
/* uniquify= */ false,
skylarkSemantics.incompatibleExpandDirectories(),
starlarkSemantics.incompatibleExpandDirectories(),
/* terminateWith= */ null,
loc);

} else {
if (mapFn != Runtime.NONE && skylarkSemantics.incompatibleDisallowOldStyleArgsAdd()) {
if (mapFn != Runtime.NONE && starlarkSemantics.incompatibleDisallowOldStyleArgsAdd()) {
throw new EvalException(
loc,
"Args#add no longer accepts map_fn when"
Expand Down Expand Up @@ -709,7 +707,7 @@ public CommandLineArgsApi addAll(
omitIfEmpty,
uniquify,
expandDirectories == Runtime.UNBOUND
? skylarkSemantics.incompatibleExpandDirectories()
? starlarkSemantics.incompatibleExpandDirectories()
: (Boolean) expandDirectories,
terminateWith != Runtime.NONE ? (String) terminateWith : null,
loc);
Expand Down Expand Up @@ -753,7 +751,7 @@ public CommandLineArgsApi addJoined(
omitIfEmpty,
uniquify,
expandDirectories == Runtime.UNBOUND
? skylarkSemantics.incompatibleExpandDirectories()
? starlarkSemantics.incompatibleExpandDirectories()
: (Boolean) expandDirectories,
/* terminateWith= */ null,
loc);
Expand Down Expand Up @@ -850,7 +848,7 @@ private void validateMapEach(@Nullable BaseFunction mapEach, Location loc)
private void validateFormatString(String argumentName, @Nullable String formatStr, Location loc)
throws EvalException {
if (formatStr != null
&& skylarkSemantics.incompatibleDisallowOldStyleArgsAdd()
&& starlarkSemantics.incompatibleDisallowOldStyleArgsAdd()
&& !SingleStringArgFormatter.isValid(formatStr)) {
throw new EvalException(
loc,
Expand All @@ -874,7 +872,7 @@ private void addScalarArg(Object value, String format, BaseFunction mapFn, Locat
}

private void validateNoDirectory(Object value, Location loc) throws EvalException {
if (skylarkSemantics.incompatibleExpandDirectories() && isDirectory(value)) {
if (starlarkSemantics.incompatibleExpandDirectories() && isDirectory(value)) {
throw new EvalException(
loc,
"Cannot add directories to Args#add since they may expand to multiple values. "
Expand Down Expand Up @@ -928,10 +926,10 @@ public CommandLineArgsApi setParamFileFormat(String format) throws EvalException
return this;
}

private Args(@Nullable Mutability mutability, SkylarkSemantics skylarkSemantics) {
private Args(@Nullable Mutability mutability, StarlarkSemantics starlarkSemantics) {
this.mutability = mutability != null ? mutability : Mutability.IMMUTABLE;
this.skylarkSemantics = skylarkSemantics;
this.commandLine = new SkylarkCustomCommandLine.Builder(skylarkSemantics);
this.starlarkSemantics = starlarkSemantics;
this.commandLine = new SkylarkCustomCommandLine.Builder(starlarkSemantics);
}

public SkylarkCustomCommandLine build() {
Expand Down Expand Up @@ -976,7 +974,7 @@ private void scanForDirectories(Iterable<?> objects) {

@Override
public Args args(Environment env) {
return new Args(env.mutability(), skylarkSemantics);
return new Args(env.mutability(), starlarkSemantics);
}

@Override
Expand Down
Loading

0 comments on commit 6659b4c

Please sign in to comment.