diff options
author | 2015-11-06 13:15:59 +0000 | |
---|---|---|
committer | 2015-11-06 16:40:03 +0000 | |
commit | b2e8e9ec5cc72ebdefebdb5f8459e768bd927e28 (patch) | |
tree | fcde31db007e849a93990ce6c05bc7c9cdca3e88 /src | |
parent | 37349a05513f9277d4e0200b07cfe3623da2a35c (diff) |
Compile identifiers to byte code
--
MOS_MIGRATED_REVID=107225693
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/Identifier.java | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/Identifier.java b/src/main/java/com/google/devtools/build/lib/syntax/Identifier.java index d675be3d56..0f1fc18a6f 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/Identifier.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/Identifier.java @@ -14,6 +14,12 @@ package com.google.devtools.build.lib.syntax; +import com.google.devtools.build.lib.syntax.compiler.DebugInfo; +import com.google.devtools.build.lib.syntax.compiler.Variable.SkylarkVariable; +import com.google.devtools.build.lib.syntax.compiler.VariableScope; + +import net.bytebuddy.implementation.bytecode.ByteCodeAppender; + import javax.annotation.Nullable; // TODO(bazel-team): for extra performance: @@ -33,14 +39,14 @@ public final class Identifier extends Expression { public Identifier(String name) { this.name = name; } - + /** * Returns the name of the Identifier. */ public String getName() { return name; } - + public boolean isPrivate() { return name.startsWith("_"); } @@ -58,12 +64,12 @@ public final class Identifier extends Expression { } return false; } - + @Override public int hashCode() { return name.hashCode(); } - + @Override Object doEval(Environment env) throws EvalException { try { @@ -90,4 +96,10 @@ public final class Identifier extends Expression { ? new EvalException(getLocation(), "contains syntax error(s)", true) : new EvalException(getLocation(), "name '" + name + "' is not defined"); } + + @Override + ByteCodeAppender compile(VariableScope scope, DebugInfo debugInfo) { + SkylarkVariable variable = scope.getVariable(this); + return variable.load(scope, debugInfo.add(this)); + } } |