Skip to content

Commit

Permalink
(fix) trace NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed Jan 10, 2019
1 parent e583498 commit 5e53bcd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static AviatorObject eval(Map<String, Object> env, AviatorObject[] args,
AviatorFunction func = RuntimeUtils.getInstance(env).getOpFunction(opType);
AviatorObject ret = eval0(env, args, opType, func);
if (RuntimeUtils.isTracedEval(env)) {
trace(null, opType, ret, args);
trace(env, opType, ret, args);
}
return ret;
}
Expand Down Expand Up @@ -166,7 +166,7 @@ private static void trace(Map<String, Object> env, OperatorType opType, AviatorO
case 3:
RuntimeUtils.printTrace(env,
TRACE_PREFIX + args[0].desc(env) + WHITE_SPACE + "?" + WHITE_SPACE + args[0].desc(env)
+ WHITE_SPACE + ":" + WHITE_SPACE + args[1].desc(env) + " => " + result.desc(env));
+ WHITE_SPACE + ":" + WHITE_SPACE + args[1].desc(env) + " => " + result.desc(env));
break;
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/googlecode/aviator/utils/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ public Env() {

@Override
public Env clone() {
return new Env(this.mDefaults == EMPTY_ENV ? EMPTY_ENV : new HashMap<>(this.mDefaults),
Env ret = new Env(this.mDefaults == EMPTY_ENV ? EMPTY_ENV : new HashMap<>(this.mDefaults),
new HashMap<>(this.mOverrides));
ret.instance = this.instance;
return ret;
}

/**
Expand Down Expand Up @@ -280,8 +282,8 @@ public Collection<Object> values() {
public String toString() {
StringBuffer buf = new StringBuffer(32 * size());
buf.append(super.toString()).append("{"). //
append(Variable.INSTANCE_VAR).append("=").append(this.instance).append(", ").//
append(Variable.ENV_VAR).append("=").append("<this>");
append(Variable.INSTANCE_VAR).append("=").append(this.instance).append(", ").//
append(Variable.ENV_VAR).append("=").append("<this>");

Iterator<String> it = keySet().iterator();
boolean hasNext = it.hasNext();
Expand Down

0 comments on commit 5e53bcd

Please sign in to comment.