Skip to content

Commit

Permalink
Index and slice calls are implemented as separate AST nodes rather th…
Browse files Browse the repository at this point in the history
…an special

function calls.

--
MOS_MIGRATED_REVID=133262955
  • Loading branch information
vladmos authored and dslomov committed Sep 15, 2016
1 parent 8d610c6 commit 4ce70d2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ public String toString() {
Object doEval(Environment env) throws EvalException, InterruptedException {
Object objValue = obj.eval(env);
Object keyValue = key.eval(env);
return eval(objValue, keyValue, getLocation(), env);
}

/**
* Returns the field of the given key of the struct objValue, or null if no such field exists.
*/
private Object eval(Object objValue, Object keyValue, Location loc, Environment env)
throws EvalException {
Location loc = getLocation();

if (objValue instanceof SkylarkIndexable) {
Object result = ((SkylarkIndexable) objValue).getIndex(keyValue, loc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ private static void validate(ValidationEnvironment env, Location loc, Expression
return;
}
if (expr instanceof IndexExpression) {
expr.validate(env);
return;
}
throw new EvalException(loc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,8 @@ Object doEval(Environment env) throws EvalException, InterruptedException {
Object startValue = start.eval(env);
Object endValue = end.eval(env);
Object stepValue = step.eval(env);
return eval(objValue, startValue, endValue, stepValue, getLocation(), env);
}
Location loc = getLocation();

/**
* Returns the result of the given slice, or null if no such slice is supported.
*/
private Object eval(Object objValue, Object startValue, Object endValue, Object stepValue,
Location loc, Environment env) throws EvalException {
if (objValue instanceof SkylarkList) {
SkylarkList<Object> list = (SkylarkList<Object>) objValue;
Object slice = list.getSlice(startValue, endValue, stepValue, loc);
Expand Down

0 comments on commit 4ce70d2

Please sign in to comment.