Commit Graph

41 Commits

Author SHA1 Message Date
Erik Arvidsson c9d176cb28 Cleanup serialization of types (#1410)
We used to serialize types in two different ways, depending on whether
the type was used as a tag or as a value. Now we serialize it the same
way.

Also, remove makeCompoundType completely.

And remove some dead code.
2016-05-04 11:35:33 -07:00
Erik Arvidsson 3032c76a39 Use a map for the struct fields
Fixes #1368
2016-05-02 15:35:27 -07:00
Erik Arvidsson d4d6de6a76 Rename Field t to type (#1366)
* Rename Field t to type

* Fix clients/csv too
2016-04-29 13:47:52 -07:00
Erik Arvidsson cfc51e2e9d Remove optional fields (#1354)
Remove optional fields

Fixes #1310
2016-04-28 17:12:15 -07:00
Erik Arvidsson fa742aecb1 Remove unions from structs (#1345)
Fixes #1344
2016-04-28 11:13:59 -07:00
Erik Arvidsson 3ff6ee6add Inline struct type declaration into chunk (#1324)
Struct type definition is now inlined into the chunk. To break
cycles we use back references.

- Removes unresolved type refs
- Removes packages

Fixes #1164
Fixes #1165
2016-04-27 20:39:51 -07:00
Mike Gray 47794ca754 Removing [U]Int[8|16|32|64] and Float[32|64] in favor of Number 2016-04-27 16:24:13 -04:00
Erik Arvidsson 423d3a87ec Make MakeCompoundType package private (#1304)
And same for MakePrimitiveType. This also makes sure that we return
the same primitive type every single time.

Fixes #1271
2016-04-22 17:49:27 -07:00
Erik Arvidsson 02c47661fd Make all usages of Type in Go use pointers (#1295)
This is in preparation of allowing back references which requires
pointers to be able to compare that the structs are the same.
2016-04-22 15:19:42 -07:00
Erik Arvidsson 5896559db7 Remove support for enums (#1291) 2016-04-22 10:14:05 -07:00
Erik Arvidsson bbeb504943 Type describe use human readable serialization (#1287)
* Make Type Describe use the Human Readable Serialization

This reduces code duplication.

* Remove Choices in favor of []Field
2016-04-21 11:12:37 -07:00
Erik Arvidsson c91b8146dc Go: Eagerly fixup types after the Package has been created (#1241)
This fixes the package refs in NewPackage and makes the serializer
know about these refs when a Package is encoded.
2016-04-13 18:09:22 -07:00
Rafael Weinstein 1676707906 WriteValue returns RefBase 2016-04-11 17:09:25 -07:00
Erik Arvidsson ea51e1ccfc Handle imports in js codegen
Issue #1081
2016-04-06 11:46:13 -07:00
Chris Masone 119a56c3a9 Move ReadValue and WriteValue to DataStore
This patch is the first step in moving all reading and writing to the
DataStore API, so that we can validate data commited to Noms.

The big change here is that types.ReadValue() no longer exists and is
replaced with a ReadValue() method on DataStore. A similar
WriteValue() method deprecates types.WriteValue(), but fully removing
that is left for a later patch. Since a lot of code in the types
package needs to read and write values, but cannot import the datas
package without creating an import cycle, the types package exports
ValueReader and ValueWriter interfaces, which DataStore implements.
Thus, a DataStore can be passed to anything in the types package which
needs to read or write values (e.g. a collection constructor or
typed-ref)

Relatedly, this patch also introduces the DataSink interface, so that
some public-facing apis no longer need to provide a ChunkSink.

Towards #654
2016-03-17 12:57:44 -07:00
Aaron Boodman cff0de3696 non-vendor changes 2016-02-08 23:15:09 -08:00
Rafael Weinstein 6c3239a1d0 Collections no longer need a ChunkStore on creation 2016-02-02 13:39:26 -08:00
Erik Arvidsson 4482eed74c Fix issue with canUseDef
We were not passing the package through when we called
containsComparable which made us lookup the type in the wrong package.

Fixes #869
2016-01-20 13:27:48 -08:00
Benjamin Kalman 9a3e73779d Make types.Ref implement the OrderedValue interface.
This fixes the bug where compoundSets/Maps of refs are ordered by their
type.Ref's Ref, rather than their type.Ref's TargetRef.
2015-12-14 11:28:38 -08:00
Chris Masone 6e316d9975 Move build scripts to python
Finding and running build scripts remains in Go
(tools/run_all_build.go and supporting libs), but the build scripts
themselves are in python now.  This is because Go doesn't have much
support for copying files and directories around, which is kind of the
primary focus of build and packaging scripts.

Towards issue 677
2015-12-11 14:46:16 -08:00
Erik Arvidsson 698c21bc67 NomDL: Change type syntax to use <> instead of ()
Fixes #678
2015-12-02 12:30:00 -05:00
Erik Arvidsson 61f14f8c9a Rename noms UInt* to Uint*
Fixes #673
2015-12-02 12:01:42 -05:00
Erik Arvidsson a72ce41a1d Go: TypeRef -> Type
Remaining identifiers
2015-11-13 17:54:53 -05:00
Chris Masone 4118de422f Small refactor in parse.go
pkg/parse.go has grown a bit unwieldy, so factor some functions out
into imports.go and move other code around so utility functions are
closer to the functions that use them.
2015-11-09 12:43:18 -08:00
Chris Masone eda9b92870 Rename types.TypeRef to types.Type
There are probably still a lot of variable names and comments to fix,
but this updates all the Go code.

Towards #441
2015-11-09 08:26:32 -08: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 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
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 e249f11347 pkg.Parsed should embed a types.Package, not a types.PackageDef
Doing so makes it so we don't create new Package instances all over codegen.go

Fixes #420
2015-10-19 11:22:16 -07: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 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
Chris Masone 3e43c58320 Import .noms files by path
.noms files can now import other .noms files by relative or absolute path.

Fixes #399
2015-10-14 15:03:50 -07:00
Chris Masone 30422eaa33 Fix a few issues with switching from NamedTypes -> Types and re-run go generate
grammar.peg didn't get updated along with grammar.peg.go in arv's last patch,
so that needed to be fixed. Also, pkg.Parsed had its own field named Types, which
shadowed the one it got by embedded types.Package. This only came into play when
generating code for packages pulled out of a dataset. Since arv had to manually
patch up all generated code in his last patch, he never hit this issue and I
missed it in review.

Now, go generate passes once more. Yay
2015-10-14 14:31:06 -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
Chris Masone 56cd548328 Support compounding types with imported types.
Sets, Lists, Refs and Maps of imported types work now.

This PR also factors some of codegen.go into a separate package, to slim down
that file a bit.

Towards issue #294
2015-10-12 15:29:45 -07:00
Chris Masone cc15992778 Initial support for importing type pacakges by ref
Towards #294
2015-10-09 15:19:06 -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
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 24bc9e4831 Add unittests to check failures in namespace resolution 2015-09-29 10:23:33 -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