Bring submodule and stdlib to cpp master

This commit is contained in:
Dave Cunningham 2018-03-06 23:41:22 -05:00
parent cf6933d45b
commit 5cc426ed04
30 changed files with 42752 additions and 26892 deletions

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit 6b7f64c136156ca67371be6089d2b89d5f0dab9e Subproject commit 0759409780eec8cb3a7a8ced52f104c0d895ac38

View File

@ -155,7 +155,7 @@ const (
func (i *interpreter) newCall(trace *TraceElement, env environment, trimmable bool) error { func (i *interpreter) newCall(trace *TraceElement, env environment, trimmable bool) error {
s := &i.stack s := &i.stack
if s.calls >= s.limit { if s.calls >= s.limit {
return makeRuntimeError("Max stack frames exceeded.", i.getCurrentStackTrace(trace)) return makeRuntimeError("max stack frames exceeded.", i.getCurrentStackTrace(trace))
} }
s.stack = append(s.stack, &callFrame{ s.stack = append(s.stack, &callFrame{
isCall: true, isCall: true,
@ -571,7 +571,7 @@ func (i *interpreter) manifestJSON(trace *TraceElement, v value) (interface{}, e
return v.value, nil return v.value, nil
case *valueFunction: case *valueFunction:
return nil, makeRuntimeError("Couldn't manifest function in JSON output.", i.getCurrentStackTrace(trace)) return nil, makeRuntimeError("couldn't manifest function in JSON output.", i.getCurrentStackTrace(trace))
case *valueNumber: case *valueNumber:
return v.value, nil return v.value, nil
@ -625,7 +625,7 @@ func (i *interpreter) manifestJSON(trace *TraceElement, v value) (interface{}, e
default: default:
return nil, makeRuntimeError( return nil, makeRuntimeError(
fmt.Sprintf("Manifesting this value not implemented yet: %s", reflect.TypeOf(v)), fmt.Sprintf("manifesting this value not implemented yet: %s", reflect.TypeOf(v)),
i.getCurrentStackTrace(trace), i.getCurrentStackTrace(trace),
) )
@ -746,7 +746,7 @@ func (i *interpreter) manifestString(buf *bytes.Buffer, trace *TraceElement, v v
buf.WriteString(v.getString()) buf.WriteString(v.getString())
return nil return nil
default: default:
return makeRuntimeError(fmt.Sprintf("Expected string result, got: %s", v.getType().name), i.getCurrentStackTrace(trace)) return makeRuntimeError(fmt.Sprintf("expected string result, got: %s", v.getType().name), i.getCurrentStackTrace(trace))
} }
} }
@ -765,7 +765,7 @@ func (i *interpreter) manifestAndSerializeMulti(trace *TraceElement, v value) (r
r[filename] = buf.String() r[filename] = buf.String()
} }
default: default:
msg := fmt.Sprintf("Multi mode: Top-level object was a %s, "+ msg := fmt.Sprintf("multi mode: top-level object was a %s, "+
"should be an object whose keys are filenames and values hold "+ "should be an object whose keys are filenames and values hold "+
"the JSON for that file.", v.getType().name) "the JSON for that file.", v.getType().name)
return r, makeRuntimeError(msg, i.getCurrentStackTrace(trace)) return r, makeRuntimeError(msg, i.getCurrentStackTrace(trace))
@ -788,7 +788,7 @@ func (i *interpreter) manifestAndSerializeYAMLStream(trace *TraceElement, v valu
r = append(r, buf.String()) r = append(r, buf.String())
} }
default: default:
msg := fmt.Sprintf("Stream mode: Top-level object was a %s, "+ msg := fmt.Sprintf("stream mode: top-level object was a %s, "+
"should be an array whose elements hold "+ "should be an array whose elements hold "+
"the JSON for each document in the stream.", v.getType().name) "the JSON for each document in the stream.", v.getType().name)
return r, makeRuntimeError(msg, i.getCurrentStackTrace(trace)) return r, makeRuntimeError(msg, i.getCurrentStackTrace(trace))

View File

@ -535,7 +535,7 @@ func main() {
if config.cmd == commandEval { if config.cmd == commandEval {
if len(config.inputFiles) != 1 { if len(config.inputFiles) != 1 {
// Should already have been caught by processArgs. // Should already have been caught by processArgs.
panic(fmt.Sprintf("Internal error: Expected a single input file.")) panic(fmt.Sprintf("Internal error: expected a single input file."))
} }
filename := config.inputFiles[0] filename := config.inputFiles[0]
input, err := readInput(config, &filename) input, err := readInput(config, &filename)

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
RUNTIME ERROR: Assertion failed. {"x": 1} != {"x": 2} RUNTIME ERROR: Assertion failed. {"x": 1} != {"x": 2}
------------------------------------------------- -------------------------------------------------
<std>:706:13-56 function <anonymous> <std>:758:7-50 function <anonymous>
error "Assertion failed. " + a + " != " + b, error 'Assertion failed. ' + a + ' != ' + b,
------------------------------------------------- -------------------------------------------------
testdata/assert_equal4:1:1-32 $ testdata/assert_equal4:1:1-32 $

View File

@ -2,9 +2,9 @@ RUNTIME ERROR: Assertion failed.
!= !=
------------------------------------------------- -------------------------------------------------
<std>:706:13-56 function <anonymous> <std>:758:7-50 function <anonymous>
error "Assertion failed. " + a + " != " + b, error 'Assertion failed. ' + a + ' != ' + b,
------------------------------------------------- -------------------------------------------------
testdata/assert_equal5:1:1-29 $ testdata/assert_equal5:1:1-29 $

View File

@ -1,8 +1,8 @@
RUNTIME ERROR: Assertion failed.  != RUNTIME ERROR: Assertion failed.  !=
------------------------------------------------- -------------------------------------------------
<std>:706:13-56 function <anonymous> <std>:758:7-50 function <anonymous>
error "Assertion failed. " + a + " != " + b, error 'Assertion failed. ' + a + ' != ' + b,
------------------------------------------------- -------------------------------------------------
testdata/assert_equal6:1:1-34 $ testdata/assert_equal6:1:1-34 $

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Function expected 1 positional argument(s), but got 2 RUNTIME ERROR: function expected 1 positional argument(s), but got 2
------------------------------------------------- -------------------------------------------------
testdata/bad_function_call2:1:1-22 $ testdata/bad_function_call2:1:1-22 $

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Function expected 1 positional argument(s), but got 2 RUNTIME ERROR: function expected 1 positional argument(s), but got 2
------------------------------------------------- -------------------------------------------------
testdata/bad_function_call_and_error:1:1-38 $ testdata/bad_function_call_and_error:1:1-38 $

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Couldn't manifest function in JSON output. RUNTIME ERROR: couldn't manifest function in JSON output.
------------------------------------------------- -------------------------------------------------
testdata/error_function_fail:1:1-23 $ testdata/error_function_fail:1:1-23 $

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Couldn't manifest function in JSON output. RUNTIME ERROR: couldn't manifest function in JSON output.
------------------------------------------------- -------------------------------------------------
During manifestation During manifestation

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Couldn't manifest function in JSON output. RUNTIME ERROR: couldn't manifest function in JSON output.
------------------------------------------------- -------------------------------------------------
testdata/function_plus_string:1:1-24 $ testdata/function_plus_string:1:1-24 $

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Couldn't manifest function in JSON output. RUNTIME ERROR: couldn't manifest function in JSON output.
------------------------------------------------- -------------------------------------------------
testdata/native5:1:1-42 $ testdata/native5:1:1-42 $

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Function has no parameter y RUNTIME ERROR: function has no parameter y
------------------------------------------------- -------------------------------------------------
testdata/native7:1:1-33 $ testdata/native7:1:1-33 $

View File

@ -5,7 +5,7 @@ RUNTIME ERROR: Attempt to use super when there is no super class.
{ x: 5, assert super.x == 5 } { x: 5, assert super.x == 5 }
------------------------------------------------- -------------------------------------------------
<std>:1046:29-30 thunk from <thunk <ta> from <function <anonymous>>> <std>:1165:25-26 thunk from <thunk <ta> from <function <anonymous>>>
local ta = std.type(a); local ta = std.type(a);
@ -13,7 +13,7 @@ RUNTIME ERROR: Attempt to use super when there is no super class.
<builtin> builtin function <type> <builtin> builtin function <type>
------------------------------------------------- -------------------------------------------------
<std>:1048:33-35 thunk from <function <anonymous>> <std>:1167:29-31 thunk from <function <anonymous>>
if !std.primitiveEquals(ta, tb) then if !std.primitiveEquals(ta, tb) then
@ -21,7 +21,7 @@ RUNTIME ERROR: Attempt to use super when there is no super class.
<builtin> builtin function <primitiveEquals> <builtin> builtin function <primitiveEquals>
------------------------------------------------- -------------------------------------------------
<std>:1048:12-40 function <anonymous> <std>:1167:8-36 function <anonymous>
if !std.primitiveEquals(ta, tb) then if !std.primitiveEquals(ta, tb) then

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Function has no parameter y RUNTIME ERROR: function has no parameter y
------------------------------------------------- -------------------------------------------------
testdata/optional_args8:2:1-10 $ testdata/optional_args8:2:1-10 $

View File

@ -1,8 +1,8 @@
RUNTIME ERROR: Operator % cannot be used on types number and string. RUNTIME ERROR: Operator % cannot be used on types number and string.
------------------------------------------------- -------------------------------------------------
<std>:189:13-100 function <anonymous> <std>:205:7-94 function <anonymous>
error "Operator % cannot be used on types " + std.type(a) + " and " + std.type(b) + ".", error 'Operator % cannot be used on types ' + std.type(a) + ' and ' + std.type(b) + '.',
------------------------------------------------- -------------------------------------------------

View File

@ -1,21 +1,21 @@
RUNTIME ERROR: Too many values to format: 1, expected 0 RUNTIME ERROR: Too many values to format: 1, expected 0
------------------------------------------------- -------------------------------------------------
<std>:576:21-96 function <format_codes_arr> <std>:628:11-86 function <format_codes_arr>
error ("Too many values to format: " + std.length(arr) + ", expected " + j) error ('Too many values to format: ' + std.length(arr) + ', expected ' + j)
------------------------------------------------- -------------------------------------------------
<std>:582:21-69 function <format_codes_arr> <std>:634:11-59 function <format_codes_arr>
format_codes_arr(codes, arr, i + 1, j, v + code) tailstrict format_codes_arr(codes, arr, i + 1, j, v + code) tailstrict
------------------------------------------------- -------------------------------------------------
<std>:673:13-54 function <anonymous> <std>:725:7-48 function <anonymous>
format_codes_arr(codes, [vals], 0, 0, ""), format_codes_arr(codes, [vals], 0, 0, ''),
------------------------------------------------- -------------------------------------------------
<std>:187:13-29 function <anonymous> <std>:203:7-23 function <anonymous>
std.format(a, b) std.format(a, b)

View File

@ -1,8 +1,8 @@
RUNTIME ERROR: Operator % cannot be used on types function and number. RUNTIME ERROR: Operator % cannot be used on types function and number.
------------------------------------------------- -------------------------------------------------
<std>:189:13-100 function <anonymous> <std>:205:7-94 function <anonymous>
error "Operator % cannot be used on types " + std.type(a) + " and " + std.type(b) + ".", error 'Operator % cannot be used on types ' + std.type(a) + ' and ' + std.type(b) + '.',
------------------------------------------------- -------------------------------------------------

View File

@ -1,21 +1,21 @@
RUNTIME ERROR: Too many values to format: 2, expected 1 RUNTIME ERROR: Too many values to format: 2, expected 1
------------------------------------------------- -------------------------------------------------
<std>:576:21-96 function <format_codes_arr> <std>:628:11-86 function <format_codes_arr>
error ("Too many values to format: " + std.length(arr) + ", expected " + j) error ('Too many values to format: ' + std.length(arr) + ', expected ' + j)
------------------------------------------------- -------------------------------------------------
<std>:582:21-69 function <format_codes_arr> <std>:634:11-59 function <format_codes_arr>
format_codes_arr(codes, arr, i + 1, j, v + code) tailstrict format_codes_arr(codes, arr, i + 1, j, v + code) tailstrict
------------------------------------------------- -------------------------------------------------
<std>:669:13-52 function <anonymous> <std>:721:7-46 function <anonymous>
format_codes_arr(codes, vals, 0, 0, "") format_codes_arr(codes, vals, 0, 0, '')
------------------------------------------------- -------------------------------------------------
<std>:187:13-29 function <anonymous> <std>:203:7-23 function <anonymous>
std.format(a, b) std.format(a, b)

View File

@ -1,16 +1,16 @@
RUNTIME ERROR: Not enough values to format, got 1 RUNTIME ERROR: Not enough values to format, got 1
------------------------------------------------- -------------------------------------------------
<std>:609:29-88 thunk <val> from <function <format_codes_arr>> <std>:661:15-74 thunk <val> from <function <format_codes_arr>>
error "Not enough values to format, got " + std.length(arr); error 'Not enough values to format, got ' + std.length(arr);
------------------------------------------------- -------------------------------------------------
<std>:614:41-44 thunk from <thunk <s> from <function <format_codes_arr>>> <std>:666:27-30 thunk from <thunk <s> from <function <format_codes_arr>>>
format_code(val, code, tmp.fw, tmp2.prec, j2); format_code(val, code, tmp.fw, tmp2.prec, j2);
------------------------------------------------- -------------------------------------------------
<std>:511:30-33 thunk from <function <format_code>> <std>:536:22-25 thunk from <function <format_code>>
std.toString(val) std.toString(val)
@ -20,17 +20,17 @@ RUNTIME ERROR: Not enough values to format, got 1
------------------------------------------------- -------------------------------------------------
... (skipped 14 frames) ... (skipped 14 frames)
------------------------------------------------- -------------------------------------------------
<std>:625:21-74 function <format_codes_arr> <std>:677:11-64 function <format_codes_arr>
format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict; format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict;
------------------------------------------------- -------------------------------------------------
<std>:669:13-52 function <anonymous> <std>:721:7-46 function <anonymous>
format_codes_arr(codes, vals, 0, 0, "") format_codes_arr(codes, vals, 0, 0, '')
------------------------------------------------- -------------------------------------------------
<std>:187:13-29 function <anonymous> <std>:203:7-23 function <anonymous>
std.format(a, b) std.format(a, b)

View File

@ -1,16 +1,16 @@
RUNTIME ERROR: Not enough values to format, got 1 RUNTIME ERROR: Not enough values to format, got 1
------------------------------------------------- -------------------------------------------------
<std>:609:29-88 thunk <val> from <function <format_codes_arr>> <std>:661:15-74 thunk <val> from <function <format_codes_arr>>
error "Not enough values to format, got " + std.length(arr); error 'Not enough values to format, got ' + std.length(arr);
------------------------------------------------- -------------------------------------------------
<std>:614:41-44 thunk from <thunk <s> from <function <format_codes_arr>>> <std>:666:27-30 thunk from <thunk <s> from <function <format_codes_arr>>>
format_code(val, code, tmp.fw, tmp2.prec, j2); format_code(val, code, tmp.fw, tmp2.prec, j2);
------------------------------------------------- -------------------------------------------------
<std>:511:30-33 thunk from <function <format_code>> <std>:536:22-25 thunk from <function <format_code>>
std.toString(val) std.toString(val)
@ -20,17 +20,17 @@ RUNTIME ERROR: Not enough values to format, got 1
------------------------------------------------- -------------------------------------------------
... (skipped 14 frames) ... (skipped 14 frames)
------------------------------------------------- -------------------------------------------------
<std>:625:21-74 function <format_codes_arr> <std>:677:11-64 function <format_codes_arr>
format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict; format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict;
------------------------------------------------- -------------------------------------------------
<std>:673:13-54 function <anonymous> <std>:725:7-48 function <anonymous>
format_codes_arr(codes, [vals], 0, 0, ""), format_codes_arr(codes, [vals], 0, 0, ''),
------------------------------------------------- -------------------------------------------------
<std>:187:13-29 function <anonymous> <std>:203:7-23 function <anonymous>
std.format(a, b) std.format(a, b)

View File

@ -1,39 +1,39 @@
RUNTIME ERROR: Format required number at 0, got string RUNTIME ERROR: Format required number at 0, got string
------------------------------------------------- -------------------------------------------------
<std>:(514:21)-(515:57) function <format_code> <std>:(539:11)-(540:47) function <format_code>
error "Format required number at " error 'Format required number at '
+ i + ", got " + std.type(val) + i + ', got ' + std.type(val)
------------------------------------------------- -------------------------------------------------
<std>:614:29-74 thunk <s> from <function <format_codes_arr>> <std>:666:15-60 thunk <s> from <function <format_codes_arr>>
format_code(val, code, tmp.fw, tmp2.prec, j2); format_code(val, code, tmp.fw, tmp2.prec, j2);
------------------------------------------------- -------------------------------------------------
<std>:619:38-39 thunk from <thunk <s_padded> from <function <format_codes_arr>>> <std>:671:24-25 thunk from <thunk <s_padded> from <function <format_codes_arr>>>
pad_left(s, tmp.fw, " "); pad_left(s, tmp.fw, ' ');
------------------------------------------------- -------------------------------------------------
<std>:426:36-39 thunk from <thunk from <function <pad_left>>> <std>:451:30-33 thunk from <thunk from <function <pad_left>>>
padding(w - std.length(str), s) + str; padding(w - std.length(str), s) + str;
------------------------------------------------- -------------------------------------------------
... (skipped 11 frames) ... (skipped 11 frames)
------------------------------------------------- -------------------------------------------------
<std>:625:21-74 function <format_codes_arr> <std>:677:11-64 function <format_codes_arr>
format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict; format_codes_arr(codes, arr, i + 1, j3, v + s_padded) tailstrict;
------------------------------------------------- -------------------------------------------------
<std>:669:13-52 function <anonymous> <std>:721:7-46 function <anonymous>
format_codes_arr(codes, vals, 0, 0, "") format_codes_arr(codes, vals, 0, 0, '')
------------------------------------------------- -------------------------------------------------
<std>:187:13-29 function <anonymous> <std>:203:7-23 function <anonymous>
std.format(a, b) std.format(a, b)

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Function has no parameter blahblah RUNTIME ERROR: function has no parameter blahblah
------------------------------------------------- -------------------------------------------------
testdata/std.makeArrayNamed3:1:1-54 $ testdata/std.makeArrayNamed3:1:1-54 $

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Max stack frames exceeded. RUNTIME ERROR: max stack frames exceeded.
------------------------------------------------- -------------------------------------------------
testdata/std.makeArray_recursive_evalutation_order_matters:1:51-61 function <anonymous> testdata/std.makeArray_recursive_evalutation_order_matters:1:51-61 function <anonymous>

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Couldn't manifest function in JSON output. RUNTIME ERROR: couldn't manifest function in JSON output.
------------------------------------------------- -------------------------------------------------
testdata/string_plus_function:1:1-24 $ testdata/string_plus_function:1:1-24 $

View File

@ -1,4 +1,4 @@
RUNTIME ERROR: Function expected 3 positional argument(s), but got 4 RUNTIME ERROR: function expected 3 positional argument(s), but got 4
------------------------------------------------- -------------------------------------------------
testdata/too_many_arguments:1:1-35 $ testdata/too_many_arguments:1:1-35 $

View File

@ -4,7 +4,7 @@ set -e
[ "$1" = "--skip-go-test" ] || go test ./... [ "$1" = "--skip-go-test" ] || go test ./...
export IMPLEMENTATION=go export IMPLEMENTATION=golang
(cd jsonnet; go build) (cd jsonnet; go build)

View File

@ -279,7 +279,7 @@ func checkArguments(e *evaluator, args callArguments, params Parameters) error {
numExpected := len(params.required) + len(params.optional) numExpected := len(params.required) + len(params.optional)
if numPassed > numExpected { if numPassed > numExpected {
return e.Error(fmt.Sprintf("Function expected %v positional argument(s), but got %v", numExpected, numPassed)) return e.Error(fmt.Sprintf("function expected %v positional argument(s), but got %v", numExpected, numPassed))
} }
for _, param := range params.required { for _, param := range params.required {
@ -303,7 +303,7 @@ func checkArguments(e *evaluator, args callArguments, params Parameters) error {
return e.Error(fmt.Sprintf("Argument %v already provided", arg.name)) return e.Error(fmt.Sprintf("Argument %v already provided", arg.name))
} }
if _, present := accepted[arg.name]; !present { if _, present := accepted[arg.name]; !present {
return e.Error(fmt.Sprintf("Function has no parameter %v", arg.name)) return e.Error(fmt.Sprintf("function has no parameter %v", arg.name))
} }
received[arg.name] = true received[arg.name] = true
} }