sensorlog: Fix native type consts, and gen 0 values for all types.
We had a TODO to fix consts with native types, since they didn't
work at all. The strategy is to create the 0-valued wire type,
and call vdl.Convert to convert to the native type. We inline a
func literal to do this for us, which means we can call it in the
natural spot without creating temporary variables. The downside
is that the generated code looks a little ugly.
We use this functionality to generate zero values for all types
defined in each package. This will be useful for Benj's FromZero
changes, and was also useful in spotting weird behavior.
Also changed typeGoInternal to be typeGoWire. The idea is that
sometimes we want to force the wire type to be generated, but
only for the top-level type, so it makes more sense to split the
functions into wire / non-wire versions, rather than passing a
bool around that we ignore everywhere except the top level.
And fixed the isNativeType logic. I should have spotted this in
an earlier review; we should never call vdl.SplitIdent in the
codegen package, since we have the full compile.Env, and can just
look up anything we need.
And finally - changed the unnamed targets to use an incrementing
number with a unique prefix, rather than the hex hash of the
type. This is much more readable, and the hex hashes were really
long and annoying.
MultiPart: 6/6
Change-Id: Iad5c3721f333aacaa79ddf30afac34445f966746
1 file changed