commit | 67d0e3ef242db725401ca3a3438adf4aea5004c1 | [log] [tgz] |
---|---|---|
author | Todd Wang <toddw@google.com> | Fri Mar 18 11:20:04 2016 -0700 |
committer | Todd Wang <toddw@google.com> | Fri Mar 18 11:20:04 2016 -0700 |
tree | 79be9ea9eeaa1a981fcdec6601e86e10758ff5cc | |
parent | d09dad921fd6e140941035a9e6b3060065687c60 [diff] |
ref: 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: 3/6 Change-Id: Ide1de2b1aed535b2eb52cdf5db7feb48cdb01241
This repository contains a reference implementation of the Vanadium APIs.
Unlike the APIs in https://github.com/vanadium/go.v23, which promises to provide backward compatibility this repository makes no such promises.