private CapnpType _ResolveImport(CapnpImport import) { if (_GetImportContents == null) { throw new Exception("import attempted but no way to resolve it"); } var source = _GetImportContents(import.File); var importedType = import.Type; var importParser = new CapnpParser(source); var parsedSource = importParser.Parse(); parsedSource = importParser.ProcessParsedSource(parsedSource, _GetImportContents); // No type specified, so return the module for later perusal. if (importedType == null) { return(parsedSource); } if (importedType is CapnpReference) { var @ref = (CapnpReference)importedType; return(parsedSource.ResolveFullName(@ref.FullName)); } else { Debug.Assert(false); } return(importedType); }
protected internal override Value VisitValue(Value value) { if (value == null) { return(null); } var unresolvedValue = value as UnresolvedValue; if (unresolvedValue == null) { return(value); } if (value.Type is CapnpReference) { throw new Exception("unexpected reference in value"); } //if (value.Type == CapnpPrimitive.Void) //{ // if (unresolvedValue.RawData == "void") return value; // throw new Exception("invalid Void value: " + unresolvedValue.RawData); //} var genericType = value.Type as CapnpGenericType; if (genericType != null && genericType.IsGeneric) { throw new InvalidOperationException("cannot parse unresolved value with open generic type"); } if (value.Type is CapnpGenericParameter) { throw new InvalidOperationException("cannot parse an unresolved value for a generic parameter"); } // todo: double check no const refs here? return(CapnpParser.ParseValue(unresolvedValue.RawData, value.Type)); // < todo relative positioning for errors yadida }