Merge remote-tracking branch 'origin/topic/jsiwek/misc-lambda-fixes'

* origin/topic/jsiwek/misc-lambda-fixes:
  GH-725: fix logic for finding a lambda's usage of outer IDs
  Change record field anonymous functions to use lambda expressions
This commit is contained in:
Johanna Amann 2020-03-31 15:34:52 -07:00
commit 3ce1c9ffd6
12 changed files with 103 additions and 58 deletions

View file

@ -0,0 +1,2 @@
106
106

View file

@ -0,0 +1 @@
helloworld

View file

@ -39,7 +39,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -134,7 +134,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -241,7 +241,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -468,7 +468,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -593,7 +593,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -718,7 +718,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -843,7 +843,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -968,7 +968,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -1198,7 +1198,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -1251,7 +1251,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -1304,7 +1304,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -1357,7 +1357,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -1410,7 +1410,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;
@ -1463,7 +1463,7 @@ print A::outfile, Left;
print A::outfile, A::left;
print A::outfile, Right;
print A::outfile, A::right;
}, pred=anonymous-function
}, pred=lambda_<10906653936191056190>
{
print A::outfile, ============PREDICATE============;
print A::outfile, A::typ;

View file

@ -0,0 +1,19 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
local outer = 100;
local lambda = function()
{
local inner = function(a: count, b: count, c: count, d: count, e: count, f: count)
{
print outer + f;
};
inner(1, 2, 3, 4, 5, 6);
};
lambda();
local copyLambda = copy(copy(copy(lambda)));
copyLambda();

View file

@ -0,0 +1,13 @@
# @TEST-EXEC: zeek -b %INPUT >out
# @TEST-EXEC: btest-diff out
type myrec: record {
foo: function(a: string);
};
event zeek_init()
{
local w = "world";
local mr = myrec($foo(a: string) = { print a + w; });
mr$foo("hello");
}