Node/Connection deserialization

Deserialization for nodes and connections! I only did some basic testing
but everything seems to be good.

Attributes are pretty FUBAR and we definitely need to refactor how they
work in the future, but as far as I know they're not necessary for our
MVP.

Constraints are also still pending.
Yeah. I'll add this when I get back home.                                                                                                                                                                                                                                                                          Sent from my mobile, please excuse any typos.                                                                                                                                                                                                                                        From: Murphy BerzishSent: Thursday, August 7, 2014 12:29 PMTo: manifold-lang/manifoldReply To: manifold-lang/manifoldCc: Max Qitian ChenSubject: Re: [manifold] Node/Connection deserialization (#138)In src/main/java/org/manifold/compiler/middle/serialization/SchematicDeserializer.java:
> @@ -46,11 +73,32 @@
>      return attributeMap;
>    }
>  
> +  private Map<String, Value> getValueAttributes(Schematic sch, JsonObject obj)
> +      throws UndeclaredIdentifierException {
> +    JsonObject attributeMapJson = obj.getAsJsonObject(ATTRIBUTES);
> +    HashMap<String, Value> attributeMap = new HashMap<>();
> +
> +    if (attributeMapJson == null) {
> +      return attributeMap;
> +    }
> +
> +    // TODO (max): read these, dependent on IR attribute/type overhaul

One thing you could try is, if you have type information about the object whose attributes you're getting, try parsing that type explicitly. 

For example, you're deserializing a node whose type is "register". You look in the Schematic and see that "register" is a node type whose attributes are "foo => bool" and "bar => int". In the attributes section, when you see an attribute whose key is "foo", you deserialize the value as "bool" or throw an exception, and when you see an attribute whose key is "bar", you deserialize the value as "int" or throw an exception.

If you have the type information from earlier, you can use that when you deserialize. Does that make sense?

—Reply to this email directly or view it on GitHub.