MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / checkHeader

Method checkHeader

src/main/java/wyil/io/WyilFileReader.java:48–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46 }
47
48 @Override
49 protected Schema checkHeader() throws IOException {
50 // Extract current schema
51 Schema schema = WyilFile.getSchema();
52 // Check magic number
53 for (int i = 0; i != 8; ++i) {
54 char c = (char) in.read_u8();
55 if (magic[i] != c) {
56 throw new IllegalArgumentException("invalid magic number");
57 }
58 }
59 // Check version number
60 majorVersion = in.read_uv();
61 minorVersion = in.read_uv();
62 //
63 if (majorVersion > schema.getMajorVersion()
64 || (majorVersion == schema.getMajorVersion() && minorVersion > schema.getMinorVersion())) {
65 String msg = "WyilFile compiled with newer version of WyC [" + majorVersion + "." + minorVersion
66 + " > " + schema.getMajorVersion() + "." + schema.getMinorVersion() + "]";
67 throw new Syntactic.Exception(msg, null, null);
68 } else {
69 schema = selectSchema(majorVersion,minorVersion,schema);
70 }
71 // Pad to next byte boundary
72 in.pad_u8();
73 //
74 return schema;
75 }
76
77 /**
78 * Select the most appropriate schema for decoding this file based on its

Callers

nothing calls this directly

Calls 7

getSchemaMethod · 0.95
getMajorVersionMethod · 0.95
getMinorVersionMethod · 0.95
selectSchemaMethod · 0.95
read_u8Method · 0.80
read_uvMethod · 0.80
pad_u8Method · 0.45

Tested by

no test coverage detected