Merge branch 'master' into 1.15
This commit is contained in:
commit
c8b29b0674
4 files changed
+29
-12
No files matched your search
@@ -3338,11 +3338,11 @@ public class Expression
|
|||||||
}
|
}
|
||||||
catch (InternalExpressionException exc)
|
catch (InternalExpressionException exc)
|
||||||
{
|
{
|
||||||
throw new ExpressionException(c, this, "Your expression result is incorrect:"+exc.getMessage());
|
throw new ExpressionException(c, this, "Your expression result is incorrect: "+exc.getMessage());
|
||||||
}
|
}
|
||||||
catch (ArithmeticException exc)
|
catch (ArithmeticException exc)
|
||||||
{
|
{
|
||||||
throw new ExpressionException(c, this, "The final result is incorrect, "+exc.getMessage());
|
throw new ExpressionException(c, this, "The final result is incorrect: "+exc.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public abstract class ScriptHost
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
targetData.functionImports.put(identifier, sourceData);
|
targetData.futureImports.put(identifier, sourceData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ public abstract class ScriptHost
|
|||||||
|
|
||||||
private ModuleData findModuleDataFromFunctionImports(String name, ModuleData source, int ttl)
|
private ModuleData findModuleDataFromFunctionImports(String name, ModuleData source, int ttl)
|
||||||
{
|
{
|
||||||
if (ttl > 10) throw new InternalExpressionException("Cannot import "+name+", either your imports are too deep or too loopy");
|
if (ttl > 64) throw new InternalExpressionException("Cannot import "+name+", either your imports are too deep or too loopy");
|
||||||
if (source.globalFunctions.containsKey(name))
|
if (source.globalFunctions.containsKey(name))
|
||||||
return source;
|
return source;
|
||||||
if (source.functionImports.containsKey(name))
|
if (source.functionImports.containsKey(name))
|
||||||
@@ -202,7 +202,7 @@ public abstract class ScriptHost
|
|||||||
|
|
||||||
private ModuleData findModuleDataFromGlobalImports(String name, ModuleData source, int ttl)
|
private ModuleData findModuleDataFromGlobalImports(String name, ModuleData source, int ttl)
|
||||||
{
|
{
|
||||||
if (ttl > 10) throw new InternalExpressionException("Cannot import "+name+", either your imports are too deep or too loopy");
|
if (ttl > 64) throw new InternalExpressionException("Cannot import "+name+", either your imports are too deep or too loopy");
|
||||||
if (source.globalVariables.containsKey(name))
|
if (source.globalVariables.containsKey(name))
|
||||||
return source;
|
return source;
|
||||||
if (source.globalsImports.containsKey(name))
|
if (source.globalsImports.containsKey(name))
|
||||||
@@ -251,18 +251,18 @@ public abstract class ScriptHost
|
|||||||
|
|
||||||
public Stream<String> globaVariableNames(Module module, Predicate<String> predicate)
|
public Stream<String> globaVariableNames(Module module, Predicate<String> predicate)
|
||||||
{
|
{
|
||||||
return Stream.concat(
|
return Stream.concat(Stream.concat(
|
||||||
moduleData.get(module).globalVariables.keySet().stream(),
|
moduleData.get(module).globalVariables.keySet().stream(),
|
||||||
moduleData.get(module).globalsImports.keySet().stream()
|
moduleData.get(module).globalsImports.keySet().stream()
|
||||||
).filter(predicate);
|
), moduleData.get(module).futureImports.keySet().stream().filter(s -> s.startsWith("global_"))).filter(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream<String> globaFunctionNames(Module module, Predicate<String> predicate)
|
public Stream<String> globaFunctionNames(Module module, Predicate<String> predicate)
|
||||||
{
|
{
|
||||||
return Stream.concat(
|
return Stream.concat(Stream.concat(
|
||||||
moduleData.get(module).globalFunctions.keySet().stream(),
|
moduleData.get(module).globalFunctions.keySet().stream(),
|
||||||
moduleData.get(module).functionImports.keySet().stream()
|
moduleData.get(module).functionImports.keySet().stream()
|
||||||
).filter(predicate);
|
),moduleData.get(module).futureImports.keySet().stream().filter(s -> !s.startsWith("global_"))).filter(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptHost retrieveForExecution(String /*Nullable*/ user)
|
public ScriptHost retrieveForExecution(String /*Nullable*/ user)
|
||||||
@@ -279,7 +279,7 @@ public abstract class ScriptHost
|
|||||||
// fixing imports
|
// fixing imports
|
||||||
userHost.moduleData.forEach((module, data) ->
|
userHost.moduleData.forEach((module, data) ->
|
||||||
{
|
{
|
||||||
data.setImportsBasedOn(this, this.moduleData.get(data.parent));
|
data.setImportsBasedOn(userHost, this.moduleData.get(data.parent));
|
||||||
});
|
});
|
||||||
userHosts.put(user, userHost);
|
userHosts.put(user, userHost);
|
||||||
return userHost;
|
return userHost;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package carpet.script.value;
|
|||||||
|
|
||||||
import carpet.script.Context;
|
import carpet.script.Context;
|
||||||
import carpet.script.Expression;
|
import carpet.script.Expression;
|
||||||
import carpet.script.ExpressionInspector;
|
|
||||||
import carpet.script.Fluff;
|
import carpet.script.Fluff;
|
||||||
import carpet.script.LazyValue;
|
import carpet.script.LazyValue;
|
||||||
import carpet.script.Tokenizer;
|
import carpet.script.Tokenizer;
|
||||||
@@ -14,9 +13,11 @@ import carpet.script.exception.InternalExpressionException;
|
|||||||
import carpet.script.exception.ReturnStatement;
|
import carpet.script.exception.ReturnStatement;
|
||||||
import carpet.script.exception.ThrowStatement;
|
import carpet.script.exception.ThrowStatement;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class FunctionValue extends Value implements Fluff.ILazyFunction
|
public class FunctionValue extends Value implements Fluff.ILazyFunction
|
||||||
{
|
{
|
||||||
@@ -57,6 +58,16 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrettyString()
|
||||||
|
{
|
||||||
|
List<String> stringArgs= new ArrayList<>(args);
|
||||||
|
if (outerState != null)
|
||||||
|
stringArgs.addAll(outerState.entrySet().stream().map(e ->
|
||||||
|
"outer("+e.getKey()+") = "+e.getValue().evalValue(null).getPrettyString()).collect(Collectors.toList()));
|
||||||
|
return (name.equals("_")?"<lambda>":name) +"("+String.join(", ",stringArgs)+")";
|
||||||
|
}
|
||||||
|
|
||||||
public String fullName() {return expression.module == null?name:name+"["+expression.module.getName()+"]";}
|
public String fullName() {return expression.module == null?name:name+"["+expression.module.getName()+"]";}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -107,6 +118,12 @@ public class FunctionValue extends Value implements Fluff.ILazyFunction
|
|||||||
throw new InternalExpressionException("Function value has no numeric value");
|
throw new InternalExpressionException("Function value has no numeric value");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getTypeString()
|
||||||
|
{
|
||||||
|
return "function";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Value slice(long from, long to)
|
public Value slice(long from, long to)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class NumericValue extends Value
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return String.format("%.3f..", getDouble());
|
return String.format("%.1f..", getDouble());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user