Merge branch 'master' into 1.15

# Conflicts:
#	src/main/java/carpet/commands/ScriptCommand.java
This commit is contained in:
gnembon committed 2020-01-09 00:10:04 -04:00
commit 01273548b2
17 files changed
+490 -329

No files matched your search

@@ -6,7 +6,6 @@ import carpet.script.ExpressionInspector;
import carpet.script.Fluff;
import carpet.script.LazyValue;
import carpet.script.Tokenizer;
import carpet.script.bundled.ModuleInterface;
import carpet.script.exception.BreakStatement;
import carpet.script.exception.ContinueStatement;
import carpet.script.exception.ExitStatement;
@@ -24,17 +23,15 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
private Expression expression;
private Tokenizer.Token token;
private String name;
private String containedPackage;
private LazyValue body;
private Map<String, LazyValue> outerState;
private List<String> args;
private static long variantCounter = 1;
private long variant;
private FunctionValue(Expression expression, Tokenizer.Token token, String cpackage, String name, LazyValue body, List<String> args)
private FunctionValue(Expression expression, Tokenizer.Token token, String name, LazyValue body, List<String> args)
{
this.expression = expression;
this.containedPackage = cpackage;
this.token = token;
this.name = name;
this.body = body;
@@ -43,10 +40,9 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
variant = 0L;
}
public FunctionValue(Expression expression, Tokenizer.Token token, ModuleInterface code, String name, LazyValue body, List<String> args, Map<String, LazyValue> outerState)
public FunctionValue(Expression expression, Tokenizer.Token token, String name, LazyValue body, List<String> args, Map<String, LazyValue> outerState)
{
this.expression = expression;
this.containedPackage = code==null?null:code.getName();
this.token = token;
this.name = name;
this.body = body;
@@ -61,7 +57,7 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
return name;
}
public String fullName() {return containedPackage == null?name:name+"["+containedPackage+"]";}
public String fullName() {return expression.module == null?name:name+"["+expression.module.getName()+"]";}
@Override
public boolean getBoolean()
@@ -72,7 +68,7 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
@Override
protected Value clone()
{
FunctionValue ret = new FunctionValue(expression, token, containedPackage, name, body, args);
FunctionValue ret = new FunctionValue(expression, token, name, body, args);
ret.outerState = this.outerState;
ret.variant = this.variant;
return ret;
@@ -131,11 +127,9 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
public LazyValue callInContext(Expression callingExpression, Context c, Integer type, Expression e, Tokenizer.Token t, List<LazyValue> lazyParams)
{
// this hole thing might not be really needed (errata: needed to know the package to report with exceptions
Expression callContext = ExpressionInspector.Expression_cloneWithName(e, c, fullName(), t);
try
{
return lazyEval(c, type, callContext, t, lazyParams);
return lazyEval(c, type, e, t, lazyParams);
}
catch (ExpressionException exc)
{
@@ -145,12 +139,12 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
catch (InternalExpressionException exc)
{
exc.stack.add(this);
throw new ExpressionException(c, callContext, t, exc.getMessage(), exc.stack);
throw new ExpressionException(c, e, t, exc.getMessage(), exc.stack);
}
catch (ArithmeticException exc)
{
throw new ExpressionException(c, callContext, t, "Your math is wrong, "+exc.getMessage(), Collections.singletonList(this));
throw new ExpressionException(c, e, t, "Your math is wrong, "+exc.getMessage(), Collections.singletonList(this));
}
}
@@ -193,14 +187,10 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
retVal = throwStatement.retval;
rethrow = true;
}
catch (ArithmeticException | ExitStatement | ExpressionException | InternalExpressionException exc )
{
throw exc; // rethrow so could be contextualized if needed
}
catch (Exception exc)
{
throw new ExpressionException(c, e, t, "Error while evaluating expression: "+exc.getMessage());
}
//catch (ArithmeticException | ExitStatement | ExpressionException | InternalExpressionException exc )
//{
// throw exc; // rethrow so could be contextualized if needed
//}
if (rethrow)
{
throw new ThrowStatement(retVal);