Skip to content

Commit 09c7c8c

Browse files
committed
Pass through JSON
1 parent c3e4c80 commit 09c7c8c

File tree

8 files changed

+879
-66
lines changed

8 files changed

+879
-66
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*~
2+
.*.swp

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
This is a port of [jsonnet](http://jsonnet.org/) to go. It is very much a work in progress.
1313

1414
This implementation is largely based on the the [jsonnet C++ implementation](https://github.com/google/jsonnet).
15+
The precise revision is
16+
https://github.com/google/jsonnet/tree/27ddf2c2f7041c09316cf7c9ef13af9588fdd671 but when we reach
17+
feature parity with that revision, we will chase up all the recent changes on the C++ side.
1518

1619
## Implementation Notes
1720

ast.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,25 @@ type identifiers []identifier
3232

3333
type astNode interface {
3434
Loc() *LocationRange
35+
FreeVariables() identifiers
3536
}
3637
type astNodes []astNode
3738

3839
// ---------------------------------------------------------------------------
3940

4041
type astNodeBase struct {
41-
loc LocationRange
42+
loc LocationRange
43+
freeVariables identifiers
4244
}
4345

4446
func (n *astNodeBase) Loc() *LocationRange {
4547
return &n.loc
4648
}
4749

50+
func (n *astNodeBase) FreeVariables() identifiers {
51+
return n.freeVariables
52+
}
53+
4854
// ---------------------------------------------------------------------------
4955

5056
// +gen stringer
@@ -386,7 +392,15 @@ type astObjectField struct {
386392
expr2, expr3 astNode // In scope of the object (can see self).
387393
}
388394

389-
// TODO(jbeda): Add constructor helpers here
395+
// TODO(jbeda): Add the remaining constructor helpers here
396+
397+
func astObjectFieldLocal(methodSugar bool, id *identifier, ids identifiers, trailingComma bool, body astNode) astObjectField {
398+
return astObjectField{astObjectLocal, astObjectFieldVisible, false, methodSugar, nil, id, ids, trailingComma, body, nil}
399+
}
400+
401+
func astObjectFieldLocalNoMethod(id *identifier, body astNode) astObjectField {
402+
return astObjectField{astObjectLocal, astObjectFieldVisible, false, false, nil, id, identifiers{}, false, body, nil}
403+
}
390404

391405
type astObjectFields []astObjectField
392406

@@ -503,8 +517,7 @@ type astUnary struct {
503517
// astVar represents variables.
504518
type astVar struct {
505519
astNodeBase
506-
id identifier
507-
original identifier
520+
id identifier
508521
}
509522

510523
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)