-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plumbing for extensible encode reading
- Loading branch information
Showing
5 changed files
with
177 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 141 additions & 2 deletions
143
convex-core/src/main/java/convex/core/data/CAD3Encoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
package convex.core.data; | ||
|
||
import convex.core.exceptions.BadFormatException; | ||
import convex.core.lang.Core; | ||
|
||
/** | ||
* Encoder for CVM values and data structures | ||
*/ | ||
public class CVMEncoder extends CAD3Encoder { | ||
|
||
public static final CVMEncoder INSTANCE = new CVMEncoder(); | ||
|
||
@Override | ||
public ACell read(Blob encoding,int offset) throws BadFormatException { | ||
return super.read(encoding,offset); | ||
} | ||
|
||
|
||
protected ACell readExtension(byte tag, Blob blob, int offset) throws BadFormatException { | ||
// We expect a VLQ Count following the tag | ||
long code=Format.readVLQCount(blob,offset+1); | ||
if (tag == Tag.CORE_DEF) return Core.fromCode(code); | ||
|
||
return ExtensionValue.create(tag, code); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters