lazy functions with set parameter sizes will report an error if no properly specced. Fixes #1064

This commit is contained in:
gnembon committed 2021-09-06 23:05:13 -03:00
1 parent 229d0b037b
commit 36df542072
6 files changed
+45 -12

No files matched your search

@@ -38,7 +38,7 @@ public class ControlFlow {
// obvious lazy due to conditional evaluation of arguments
expression.addLazyFunction("if", -1, (c, t, lv) ->
expression.addLazyFunction("if", (c, t, lv) ->
{
if ( lv.size() < 2 )
throw new InternalExpressionException("'if' statement needs to have at least one condition and one case");
@@ -79,7 +79,7 @@ public class ControlFlow {
});
// needs to be lazy since execution of parameters but first one are conditional
expression.addLazyFunction("try", -1, (c, t, lv) ->
expression.addLazyFunction("try", (c, t, lv) ->
{
if (lv.size()==0)
throw new InternalExpressionException("'try' needs at least an expression block, and either a catch_epr, or a number of pairs of filters and catch_expr");
@@ -104,7 +104,7 @@ public class DataStructures {
});
// needs lazy cause sort function is reused
expression.addLazyFunction("sort_key", -1, (c, t, lv) -> //get working with iterators
expression.addLazyFunction("sort_key", (c, t, lv) -> //get working with iterators
{
if (lv.size() == 0)
throw new InternalExpressionException("First argument for 'sort_key' should be a List");
@@ -207,7 +207,7 @@ public class DataStructures {
});
// lazy cause conditional typing - questionable
expression.addLazyFunction("get", -1, (c, t, lv) ->
expression.addLazyFunction("get", (c, t, lv) ->
{
if (lv.size() == 0)
throw new InternalExpressionException("'get' requires parameters");
@@ -235,7 +235,7 @@ public class DataStructures {
});
// same as `get`
expression.addLazyFunction("has", -1, (c, t, lv) ->
expression.addLazyFunction("has", (c, t, lv) ->
{
if (lv.size() == 0)
throw new InternalExpressionException("'has' requires parameters");
@@ -263,7 +263,7 @@ public class DataStructures {
});
// same as `get`
expression.addLazyFunction("put", -1, (c, t, lv) ->
expression.addLazyFunction("put", (c, t, lv) ->
{
if(lv.size()<2)
{
@@ -302,7 +302,7 @@ public class DataStructures {
});
// same as `get`
expression.addLazyFunction("delete", -1, (c, t, lv) ->
expression.addLazyFunction("delete", (c, t, lv) ->
{
if (lv.size() == 0)
throw new InternalExpressionException("'delete' requires parameters");
@@ -423,7 +423,7 @@ public class Sys {
});
// lazy cause default expression may not be executed if not needed
expression.addLazyFunction("system_variable_get", -1, (c, t, lv) ->
expression.addLazyFunction("system_variable_get", (c, t, lv) ->
{
if (lv.size() == 0) throw new InternalExpressionException("'system_variable_get' expects at least a key to be fetched");
Value key = lv.get(0).evalValue(c);
@@ -67,7 +67,7 @@ public class Threading
});
// lazy cause expr is evaluated in the same type
expression.addLazyFunction("synchronize", -1, (c, t, lv) ->
expression.addLazyFunction("synchronize", (c, t, lv) ->
{
if (lv.size() == 0) throw new InternalExpressionException("'synchronize' require at least an expression to synchronize");
Value lockValue = Value.NULL;
@@ -85,7 +85,7 @@ public class Threading
});
// lazy since exception expression is very conditional
expression.addLazyFunction("sleep", -1, (c, t, lv) ->
expression.addLazyFunction("sleep", (c, t, lv) ->
{
long time = lv.isEmpty()?0L:NumericValue.asNumber(lv.get(0).evalValue(c)).getLong();
boolean interrupted = false;