primea-annotations
Advanced tools
Comparing version 0.0.1 to 0.0.2
43
index.js
@@ -300,25 +300,23 @@ const Stream = require('buffer-pipe') | ||
const newType = type.entries[typeIndex] | ||
// validate that no function signature have no return types | ||
if (newType.return_type) { | ||
throw new Error('no return types allowed') | ||
} | ||
let customIndex = mappedFuncs.get(funcIndex) | ||
if (customIndex === undefined) { | ||
customIndex = mappedTypes.get(typeIndex) | ||
} else { | ||
const customType = result.types[customIndex] | ||
if (customType.params.length !== newType.params.length) { | ||
throw new Error('invalid param length') | ||
if (!newType.return_type) { | ||
let customIndex = mappedFuncs.get(funcIndex) | ||
if (customIndex === undefined) { | ||
customIndex = mappedTypes.get(typeIndex) | ||
} else { | ||
const customType = result.types[customIndex] | ||
if (customType.params.length !== newType.params.length) { | ||
throw new Error('invalid param length') | ||
} | ||
if (!newType.params.every(param => param === 'i32')) { | ||
throw new Error('invalid base param type') | ||
} | ||
} | ||
if (!newType.params.every(param => param === 'i32')) { | ||
throw new Error('invalid base param type') | ||
if (customIndex === undefined) { | ||
customIndex = result.types.push(newType) - 1 | ||
mappedTypes.set(typeIndex, customIndex) | ||
} | ||
result.indexes[funcIndex + imports.entries.length] = customIndex | ||
} | ||
if (customIndex === undefined) { | ||
customIndex = result.types.push(newType) - 1 | ||
mappedTypes.set(typeIndex, customIndex) | ||
} | ||
result.indexes[funcIndex + imports.entries.length] = customIndex | ||
}) | ||
@@ -329,2 +327,9 @@ | ||
if (entry.kind === 'function') { | ||
// validate that no function signature have no return types | ||
// get the type index. entry.index is the global function index (imported function + internal function) | ||
const typeIndex = functions.entries[entry.index - imports.entries.length] | ||
const exportType = type.entries[typeIndex] | ||
if (exportType.return_type) { | ||
throw new Error('no return types allowed') | ||
} | ||
result.exports[entry.field_str] = entry.index | ||
@@ -331,0 +336,0 @@ } |
{ | ||
"name": "primea-annotations", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "parsing/encoding for primea's type annotations", | ||
@@ -14,4 +14,7 @@ "main": "index.js", | ||
"keywords": [ | ||
"" | ||
"primea" | ||
], | ||
"bin": { | ||
"primea-annotate": "./bin/annotate" | ||
}, | ||
"author": "mjbecze <mjbecze@gmail.com>", | ||
@@ -18,0 +21,0 @@ "license": "MPL-2.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
1651471
23
16740