Commit Graph

190 Commits

Author SHA1 Message Date
Erik Arvidsson e4544a4e49 NomDL: Remove extra write of the Package type refs
When writing a Package we were writing the type refs describing the
types in Package. These are never referenced from anywhere and the
information is embedded into the Package chunk.
2015-10-27 16:05:04 -04:00
Erik Arvidsson 8f7661e873 NomDL: Read Package from ChunkSource when decoding
Packages usually gets registered using RegisterPackage which is called
by generated code. However, if the data in the data store was created
using another binary it is unlikely that the current binary registered
the same Package.

When writing values that depends on Packages we write the Package to
the ChunkStore...

When we read a value that depends on a Package and the Package has
not been registered we now read the Package out of the the ChunkStore
and register it for future uses.
2015-10-27 09:49:59 -04:00
Erik Arvidsson cb233b0f68 Make sure we write packages to the store
When we write a value that has a TypeRef with a package we need to
write that package.

When we write a package that has dependencies we need to write the
dependent packages too.
2015-10-26 19:21:47 -04:00
Erik Arvidsson cdcf952270 Update TypeRef comment and get rid of useless param
The name param of MakeCompoundTypeRef is always the empty string.

I didn't change the underlying storage or serialization.

Fixes #436, #477
2015-10-26 15:35:45 -04:00
Erik Arvidsson 1d13a878c4 Fix types.Ref and RefKind objects
Ref Values now have a TargetRef() method that returns the ref.Ref of
the target the Value is referencing.

Note: This is a breaking change. In old code the Ref() of the Value was
the Ref of the underlying target.

Fixes #464
2015-10-26 11:18:02 -04:00
Erik Arvidsson d9a93a4751 Remove compound list 2015-10-26 09:57:53 -04:00
Erik Arvidsson 6c7864edbe Change List to not use futures
This disables the compound list creation and its related tests
2015-10-26 09:34:54 -04:00
Erik Arvidsson e365b25dc4 Revert "Test travis ci GitHub integration" 2015-10-23 17:10:04 -04:00
Erik Arvidsson 40a3cda40b Test travis ci GitHub integration 2015-10-23 16:59:53 -04:00
Erik Arvidsson 91e7ffb8e1 NomDL Codegen: Parameterize the types package
This allows us to use the codegen from types/ without manual touchups
2015-10-23 11:04:30 -04:00
Chris Masone 1486d84487 Make generated Enum types implement types.Value
Fixes #391
2015-10-22 09:56:26 -07:00
Erik Arvidsson d668d05801 WriteValue minor fix 2015-10-22 12:36:15 -04:00
Erik Arvidsson 8c4bc79fcd NomDL: Remove $type from struct impl
The implementation of structs is a Map and we used to reserve a key
with the name "$type" for the TypeRef. This is no longer needed since
the TypeRef is a constant per struct and needs no storage.

Fixes #450
2015-10-22 12:33:39 -04:00
Erik Arvidsson 3a5bb571fb NomDL: Remove NomsValue() 2015-10-22 10:47:14 -04:00
Erik Arvidsson 16353f38f8 NomDL: Make the new serialization default
This makes the new typed serialization the default (the old
serialization is not used but the code has not been cleaned up yet).

Some things are no working in the new world:

Chunking -  The compound list is not working correctly any more. The
Chunks method is having issues because it assumed things based on the
old implicit chunking.

Commit - uses a `Set(Commit)` which means that the parent commit is
embedded. We need to change that to be `Set(Ref(Commit))` so that the
parent commit is referenced instead.
2015-10-21 19:04:22 -04:00
Dan Willhite bb2f983446 Add IsEmpty() function on ref.Ref.
Fixes #337.
2015-10-21 12:07:34 -07:00
Erik Arvidsson c217ffc74a NomDL Serialization: Need to handle Name and Namespace
MakeUnresolvedTypeRef has a Name and a Namespace and we should
serialize these too or we break Ref equality
2015-10-20 15:24:33 -04:00
Erik Arvidsson d6869cef35 NomDL: Make Package a primitive type
This solves the bootstrapping problems we are encountering.

Previously Package was a Struct but structs depend on Package.
2015-10-20 10:26:00 -04:00
Chris Masone 9b225dce9b Introduce UnresolvedKind, so TypeRefKind isn't overloaded.
We'd wound up in a spot where serialization code used 'TypeRefKind' to
mean one of two very different things...either an actual value that
describes some Noms type, or a reference to a type definition that
lives somewhere else. To get rid of this ambiguity, we introduce
'UnresolvedKind' to take over the latter meaning. Now, TypeRefKind
means _only_ a value that describes a type. If you want to point off
to a type definition elsewhere in the type package, or in another
type package, use UnresolvedKind.
2015-10-19 09:58:27 -07:00
Erik Arvidsson e445d8a240 NomDL: Rename SetOrderedType to SetTypes
I missed this when I renamed the field previously
2015-10-19 10:33:57 -04:00
Erik Arvidsson f064d35253 NomDL: Move pkgRef to UnresolvedDesc
Only unresolved type refs should have a package ref.
2015-10-16 19:39:49 -04:00
Erik Arvidsson 36d9362628 NomDL: Use ordinal for unresolved type refs
Instead of using the name of the type we now use the index of the type
in the Package that defines it.
2015-10-16 17:46:15 -04:00
Benjamin Kalman a1b824e114 Make List embed the Value interface rather than redefining all methods. 2015-10-16 12:26:29 -07:00
Erik Arvidsson 6185ea1ddb NomDL: Use a list for the types in the package
This does not yet update the serialization to use the ordinal.
2015-10-14 14:49:04 -04:00
Erik Arvidsson 8565f175ee Make sure Chunks includes type.Refs and the TypeRef
Chunks shold return the futures for types.Ref values.

For typed values that have a TypeRef which has a package ref, also
include that.
2015-10-13 11:00:51 -04:00
Erik Arvidsson e29d9eeb95 NomDL Blob: Remove redundant test 2015-10-12 17:53:51 -04:00
Erik Arvidsson 0d6f8be3e8 NomDL: Use base64 for Blobs for now
Encode embedded blobs as base64 encoded strings.
2015-10-12 17:47:28 -04:00
Chris Masone cc15992778 Initial support for importing type pacakges by ref
Towards #294
2015-10-09 15:19:06 -07:00
Erik Arvidsson 1180d2aacb Fix build bustage 2015-10-09 14:35:33 -07:00
Erik Arvidsson 9795d49074 Always wrap list, map and set in an array 2015-10-09 14:10:05 -07:00
Erik Arvidsson 37336f41be NomDL serializing
This now handles serializing TypeRef values
2015-10-09 14:09:49 -07:00
Erik Arvidsson 9cb7596409 NomDL: Make NomsValue a Value
This means that when we ReadValue we can now return a NomsValue

Towards #281
2015-10-06 16:38:11 -07:00
Erik Arvidsson 2dec53453e NomDL: Add new serialization format
The new serialization format use "t " as in typed. The rest of the
message is a JSON array describing the typed data. The type is
described by types.TypeRef

Fixes #384
Issues #281, #304
2015-10-06 15:56:10 -07:00
cmasone-attic e64e313498 Merge pull request #383 from cmasone-attic/issue294
Add functions to codegen.go for generating dependency code
2015-10-06 09:06:43 -07:00
Chris Masone 646519131c Address comments 2015-10-05 15:40:35 -07:00
Chris Masone 3dc61b673c Add functions to codegen.go for generating dependency code
This adds code for finding imported type packages and generating
code for them, but does not yet handle generating code that uses
those types.

Towards issue #294
2015-10-04 18:05:50 -04:00
Dan Willhite b3ae2f89a9 Issue #379 - Add IterAllP function to types.go. 2015-10-02 11:29:08 -07:00
Erik Arvidsson 096ac4a224 Add index to List Iter, IterAll, Map, MapP
Fixes #376
2015-10-01 17:53:21 -04:00
Erik Arvidsson 8c2caa3b27 NomDL Codegen: Add TypeRef method to typed objects 2015-09-30 17:48:32 -04:00
Erik Arvidsson ede5f43204 Value should also have a TypeRef
This is so that we can get the runtime type of a value
2015-09-30 16:15:13 -04:00
Chris Masone 9168a902f9 Modify codegen to include pacakge refs for unresolved types
Also, switch to using a ref.Ref when getting/setting the package
ref in a TypeRef. Using a types.Ref just led to lots of manual
boxing and unboxing every time I wanted to use the reference.

Toward issue #294
2015-09-29 12:58:56 -07:00
Chris Masone 5ce93dad2e Beginning of import support in NomDL
This patch mostly merges parse.Package and types.Package, though it
can't quite go all the way. A types.Package doesn't have 'using'
declarations, while the parsed representation of a .noms file needs to
have that information. Hence, the parse package is moved to the 'pkg'
package, and pkg.Parsed is introduced. This type embeds types.Package
and adds the necessary additional information.

To make inroads on handling imports, I enhanced ParsePackage() (now
called ParseNomDL()) to actually process the 'alias' and 'import'
statements in the input and go replace namespaced type names in the
package with refs of imported packages. For example, the TypeRef for
'Bar' generated in the following package

alias Foo = import "sha1-ffffffff"

struct Bar {
  f: Foo.RockinStruct
}

will actually return types.Ref{sha1-ffffffff} when you call PackageRef()
on it.

In addition, I've added a function to the new 'pkg' package,
which allows the caller to get the dependencies of a type package
from a chunk store.

Fixes issue #353, towards issue #294
2015-09-28 16:08:22 -07:00
Rafael Weinstein 6c5b2eb6f4 Avoid Excess Ref Computation 2015-09-26 11:33:04 -07:00
Chris Masone 6a125243ff Clean up some comments, early return in CompoundDesc.Equals 2015-09-25 16:05:38 -07:00
Chris Masone c80a1c55b3 Merge parse.TypeRef and types.TypeRef
These were two representations of, essentially, the same information.
They were separate because they provided different APIs to similar
information, but the APIs became more similar once we started using
native types (as opposed to Noms types) for the various Make*TypeRef()
functions.

Unifying these is a big step to unifying parse.Package and types.Package,
which is pretty necessary for dealing with imported packages.

Fixes issue #338
2015-09-25 15:17:49 -07:00
Erik Arvidsson bf095dab3c Merge branch 'master' into nomdl-optional-codegen 2015-09-25 17:20:23 -04:00
Erik Arvidsson d17dc67a73 NomDL CodeGen: Rename self 2015-09-25 17:17:12 -04:00
Erik Arvidsson c254a1391a Codegen for optional fields in structs 2015-09-25 17:08:57 -04:00
Erik Arvidsson 5b3f611104 NomDL Codegen: Add optional flag to Field 2015-09-25 14:38:41 -04:00
Chris Masone b12a89c0df Change types.TypeRef creation API to use native types instead of Noms.
These are just easier to work with. The internal representation remains
the same.

Towards issue #338
2015-09-24 12:57:51 -07:00