Skip to content

Commit

Permalink
Version bump, serialize re-exports
Browse files Browse the repository at this point in the history
  • Loading branch information
Victorious3 committed Dec 21, 2022
1 parent 7619786 commit 7544e04
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
Binary file added princess-0.3.5.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/scope.pr
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export def get_scope(value: &Value) -> &Scope {
return value._scope
}

type ReExport = struct {
export type ReExport = struct {
module: weak_ref(toolchain::Module)
pattern: &parser::Node
}
Expand Down
44 changes: 43 additions & 1 deletion src/serialize.pr
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,8 @@ export def serialize(module: &toolchain::Module) {
}
}

let zero: uint64 = 0

// Write imports
let imports = module.scope.imports
if imports {
Expand All @@ -840,7 +842,28 @@ export def serialize(module: &toolchain::Module) {
fp.write_str(imp.module.filename)
}
} else {
let zero: uint64 = 0
fp.write(*zero)
}

let re_exports = module.scope.re_exports
if re_exports {
fp.write(*re_exports.length)
for var i in 0..re_exports.length {
let re_export = re_exports[i]
fp.write_str(re_export.module.module)
fp.write_str(parser::identifier_to_str(re_export.pattern, types = false))
let types = re_export.pattern.value.identifier.types
if types {
fp.write(*types.length)
for var j in 0..types.length {
let tpe = types[i].tpe
write_type(fp, tpe, state)
}
} else {
fp.write(*zero)
}
}
} else {
fp.write(*zero)
}

Expand Down Expand Up @@ -1014,6 +1037,25 @@ export def resolver_pass(module: &toolchain::Module) {
let imprt = toolchain::create_module_if_absent(filename, modulename)
scope::insert_module(module.scope, ident, imprt)
}

fp.read(*size)
for var i in 0..size {
let mod = toolchain::find_module(fp.read_str())
let name = fp.read_str()
let ident = parser::make_identifier(name)
var types_size: uint64
fp.read(*types_size)
if types_size > 0 {
ident.value.identifier.types = vector::make(typechecking::NamedParameter)
}
for var j in 0..types_size {
let tpe = deserialize_type(deserialize, fp)
ident.value.identifier.types.push({
_tpe = tpe
} !typechecking::NamedParameter)
}
scope::insert_re_export(module.scope, ident, mod)
}

fp.read(*size)
for var i in 0..size {
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=0.3.4
VERSION=0.3.5

0 comments on commit 7544e04

Please sign in to comment.