New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lys

Package Overview
Dependencies
Maintainers
0
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lys - npm Package Compare versions

Comparing version 0.1.14-20250123143612.commit-4942aa9 to 0.1.14-20250124144723.commit-2157e77

2

dist/compiler/annotations.d.ts

@@ -7,3 +7,3 @@ import { Local, Nodes, Global } from './nodes';

}
export declare type IAnnotationConstructor<T extends Annotation> = {
export type IAnnotationConstructor<T extends Annotation> = {
new (...args: any[]): T;

@@ -10,0 +10,0 @@ };

@@ -50,2 +50,4 @@ "use strict";

class Extern extends Annotation {
module;
fn;
constructor(module, fn) {

@@ -59,2 +61,3 @@ super();

class Export extends Annotation {
exportedName;
constructor(exportedName) {

@@ -70,2 +73,3 @@ super();

class LabelId extends Annotation {
label;
constructor(label) {

@@ -78,2 +82,3 @@ super();

class FunctionInTable extends Annotation {
nameIdentifier;
constructor(nameIdentifier) {

@@ -89,2 +94,3 @@ super();

class LocalIdentifier extends Annotation {
local;
constructor(local) {

@@ -108,2 +114,3 @@ super();

class CurrentLoop extends Annotation {
loop;
constructor(loop) {

@@ -117,2 +124,3 @@ super();

class ImplicitCall extends Annotation {
implicitCall;
constructor(implicitCall) {

@@ -129,2 +137,3 @@ super();

class IsFunctionReference extends Annotation {
fun;
constructor(fun) {

@@ -152,6 +161,3 @@ super();

class IsReturnExpression extends Annotation {
constructor() {
super(...arguments);
this.targetLocal = null;
}
targetLocal = null;
toString() {

@@ -164,3 +170,3 @@ if (this.targetLocal === null)

annotations.IsReturnExpression = IsReturnExpression;
})(annotations = exports.annotations || (exports.annotations = {}));
})(annotations || (exports.annotations = annotations = {}));
//# sourceMappingURL=annotations.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.failWithErrors = exports.failIfErrors = exports.findAllErrors = void 0;
exports.findAllErrors = findAllErrors;
exports.failIfErrors = failIfErrors;
exports.failWithErrors = failWithErrors;
const walker_1 = require("./walker");

@@ -22,3 +24,2 @@ const errorPrinter_1 = require("../utils/errorPrinter");

}
exports.findAllErrors = findAllErrors;
function failIfErrors(phaseName, document, parsingContext) {

@@ -28,3 +29,2 @@ findAllErrors(document, parsingContext);

}
exports.failIfErrors = failIfErrors;
function failWithErrors(phaseName, pc, debug = false) {

@@ -78,3 +78,2 @@ if (!pc.messageCollector.hasErrors())

}
exports.failWithErrors = failWithErrors;
//# sourceMappingURL=findAllErrors.js.map
export declare function last<T>(list: T[]): T;
export declare type Item = any | any[];
export type Item = any | any[];
export declare function flatten(array: Item[]): any[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flatten = exports.last = void 0;
exports.last = last;
exports.flatten = flatten;
function last(list) {
return list[list.length - 1];
}
exports.last = last;
const isArray = Array.isArray;

@@ -28,3 +28,2 @@ /*

}
exports.flatten = flatten;
//# sourceMappingURL=helpers.js.map

@@ -6,5 +6,3 @@ "use strict";

class MessageCollector {
constructor() {
this.errors = [];
}
errors = [];
error(error, position) {

@@ -11,0 +9,0 @@ if (error instanceof NodeError_1.PositionCapableError) {

@@ -9,3 +9,3 @@ import { Nodes } from './nodes';

}
export declare type IErrorPositionCapable = {
export type IErrorPositionCapable = {
readonly message: string;

@@ -12,0 +12,0 @@ readonly node?: Nodes.Node;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotAFunction = exports.UnreachableCode = exports.InvalidCall = exports.InvalidOverload = exports.UnexpectedType = exports.NotAValidType = exports.CannotInferReturnType = exports.TypeMismatch = exports.LysCompilerError = exports.LysSemanticError = exports.LysTypeError = exports.LysScopeError = exports.AstNodeError = exports.PositionCapableError = exports.printDebugType = exports.isSamePositionOrInside = exports.isSamePosition = exports.DEBUG_TYPES = void 0;
exports.NotAFunction = exports.UnreachableCode = exports.InvalidCall = exports.InvalidOverload = exports.UnexpectedType = exports.NotAValidType = exports.CannotInferReturnType = exports.TypeMismatch = exports.LysCompilerError = exports.LysSemanticError = exports.LysTypeError = exports.LysScopeError = exports.AstNodeError = exports.PositionCapableError = exports.DEBUG_TYPES = void 0;
exports.isSamePosition = isSamePosition;
exports.isSamePositionOrInside = isSamePositionOrInside;
exports.printDebugType = printDebugType;
const types_1 = require("./types");

@@ -9,3 +12,2 @@ exports.DEBUG_TYPES = process.env.DEBUG_TYPES === '1' || process.env.DEBUG_TYPES === 'true';

}
exports.isSamePosition = isSamePosition;
function isSamePositionOrInside(parent, child) {

@@ -15,3 +17,2 @@ return (isSamePosition(parent, child) ||

}
exports.isSamePositionOrInside = isSamePositionOrInside;
function printDebugType(type) {

@@ -23,4 +24,6 @@ if (type) {

}
exports.printDebugType = printDebugType;
class PositionCapableError extends Error {
message;
position;
warning;
constructor(message, position, warning = false) {

@@ -39,2 +42,5 @@ super(message);

class AstNodeError extends PositionCapableError {
message;
node;
warning;
constructor(message, node, warning = false) {

@@ -71,2 +77,4 @@ super(message, AstNodeError.ensureNodePosition(node), warning);

class TypeMismatch extends LysTypeError {
givenType;
expectedType;
constructor(givenType, expectedType, node) {

@@ -94,2 +102,3 @@ super(expectedType instanceof types_1.TraitType

class UnexpectedType extends LysTypeError {
type;
constructor(type, node) {

@@ -102,2 +111,4 @@ super(`${printDebugType(type)} is not a value, constructor or function.`, node);

class InvalidOverload extends LysTypeError {
functionType;
givenTypes;
constructor(functionType, givenTypes, node) {

@@ -111,2 +122,4 @@ super(`Could not find a valid overload for function of type ${printDebugType(functionType)} with the arguments of type (${givenTypes.join(', ')})`, node);

class InvalidCall extends LysTypeError {
expectedTypes;
givenTypes;
constructor(expectedTypes, givenTypes, node) {

@@ -126,2 +139,3 @@ super(`Invalid signature. Expecting arguments type:\n (${expectedTypes.join(', ')})\nbut got:\n (${givenTypes.join(', ')})`, node);

class NotAFunction extends LysTypeError {
type;
constructor(type, node) {

@@ -128,0 +142,0 @@ super(`Type mismatch: Type ${printDebugType(type)} is not a function`, node);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findParentDelegate = exports.findParentType = void 0;
exports.findParentType = findParentType;
exports.findParentDelegate = findParentDelegate;
function findParentType(node, desiredClass) {

@@ -14,3 +15,2 @@ let parent = node.parent;

}
exports.findParentType = findParentType;
function findParentDelegate(node, delegate) {

@@ -26,3 +26,2 @@ let parent = node.parent;

}
exports.findParentDelegate = findParentDelegate;
//# sourceMappingURL=nodeHelpers.js.map

@@ -301,3 +301,2 @@ import { TokenError } from 'ebnf';

class HexLiteral extends IntegerLiteral {
suffixReference?: ReferenceNode;
get value(): number;

@@ -380,3 +379,2 @@ set value(value: number);

declaredName?: NameIdentifierNode;
parent?: PatternMatcherNode;
booleanReference?: Reference;

@@ -383,0 +381,0 @@ constructor(astNode: ASTNode, rhs: ExpressionNode);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findNodesByTypeInChildren = exports.findNodesByType = exports.Nodes = exports.PhaseFlags = exports.Local = exports.Global = void 0;
exports.Nodes = exports.PhaseFlags = exports.Local = exports.Global = void 0;
exports.findNodesByType = findNodesByType;
exports.findNodesByTypeInChildren = findNodesByTypeInChildren;
const types_1 = require("./types");
const annotations_1 = require("./annotations");
class Global {
declarationNode;
type;
name;
constructor(declarationNode) {

@@ -14,2 +19,6 @@ this.declarationNode = declarationNode;

class Local {
index;
name;
declarationNode;
type;
/** index in the function */

@@ -33,11 +42,15 @@ constructor(index, name, declarationNode) {

PhaseFlags[PhaseFlags["CodeGeneration"] = 7] = "CodeGeneration";
})(PhaseFlags = exports.PhaseFlags || (exports.PhaseFlags = {}));
})(PhaseFlags || (exports.PhaseFlags = PhaseFlags = {}));
var Nodes;
(function (Nodes) {
class Node {
astNode;
// TODO: remove this VVVVVVVVVV
hasParentheses = false;
isTypeResolved = false;
parent;
ownScope;
annotations;
constructor(astNode) {
this.astNode = astNode;
// TODO: remove this VVVVVVVVVV
this.hasParentheses = false;
this.isTypeResolved = false;
}

@@ -59,3 +72,3 @@ get scope() {

get children() {
return this.childrenOrEmpty.filter($ => !!$);
return this.childrenOrEmpty.filter(($) => !!$);
}

@@ -75,3 +88,3 @@ hasAnnotation(name) {

if (this.annotations) {
this.annotations.forEach($ => {
this.annotations.forEach(($) => {
if ($ instanceof klass)

@@ -86,3 +99,3 @@ ret.push($);

if (this.annotations) {
this.annotations.forEach($ => {
this.annotations.forEach(($) => {
if ($ instanceof klass)

@@ -100,3 +113,3 @@ ret.push($);

this.annotations &&
this.getAnnotationsByClass(name).forEach($ => this.annotations && this.annotations.delete($));
this.getAnnotationsByClass(name).forEach(($) => this.annotations && this.annotations.delete($));
}

@@ -112,3 +125,3 @@ }

if (this.annotations) {
this.annotations.forEach($ => {
this.annotations.forEach(($) => {
if (!klass || $ instanceof klass)

@@ -130,10 +143,12 @@ ret.push($);

class NameIdentifierNode extends Node {
name;
impls = new Set();
internalIdentifier;
get childrenOrEmpty() {
return [];
}
constructor(astNode, name) {
super(astNode);
this.name = name;
this.impls = new Set();
}
get childrenOrEmpty() {
return [];
}
static fromString(name, astNode) {

@@ -146,2 +161,3 @@ const r = new NameIdentifierNode(astNode, name);

class QNameNode extends Node {
names;
constructor(astNode, names) {

@@ -152,3 +168,3 @@ super(astNode);

static fromString(name, astNode) {
const names = name.split('::').map($ => NameIdentifierNode.fromString($, astNode));
const names = name.split('::').map(($) => NameIdentifierNode.fromString($, astNode));
const r = new QNameNode(astNode, names);

@@ -163,3 +179,3 @@ return r;

.slice(0, -1)
.map($ => $.name)
.map(($) => $.name)
.join('::');

@@ -170,3 +186,3 @@ const variable = this.names[this.names.length - 1].name;

get text() {
return this.names.map($ => $.name).join('::');
return this.names.map(($) => $.name).join('::');
}

@@ -185,2 +201,4 @@ }

class SignatureParameterNode extends TypeNode {
parameterType;
parameterName;
constructor(astNode, parameterType) {

@@ -196,2 +214,6 @@ super(astNode);

class FunctionTypeNode extends TypeNode {
parameters;
typeParameters;
effect;
returnType;
constructor(astNode, parameters) {

@@ -207,2 +229,6 @@ super(astNode);

class EffectMemberDeclarationNode extends TypeNode {
name;
typeParameters;
parameters;
returnType;
get childrenOrEmpty() {

@@ -214,6 +240,8 @@ return [this.name];

class ReferenceNode extends ExpressionNode {
variable;
isLocal = false;
resolvedReference;
constructor(astNode, variable) {
super(astNode);
this.variable = variable;
this.isLocal = false;
}

@@ -226,2 +254,4 @@ get childrenOrEmpty() {

class BlockNode extends ExpressionNode {
statements;
label;
constructor(astNode, statements) {

@@ -237,2 +267,6 @@ super(astNode);

class MemberNode extends ExpressionNode {
lhs;
operator;
memberName;
resolvedReference;
constructor(astNode, lhs, operator, memberName) {

@@ -250,2 +284,4 @@ super(astNode);

class DecoratorNode extends Node {
decoratorName;
args;
constructor(astNode, decoratorName, args) {

@@ -262,23 +298,21 @@ super(astNode);

class DirectiveNode extends Node {
constructor() {
super(...arguments);
this.isPublic = false;
}
decorators;
isPublic = false;
}
Nodes.DirectiveNode = DirectiveNode;
class DocumentNode extends Node {
constructor() {
super(...arguments);
this.directives = [];
this.analysis = {
version: 0,
nextPhase: PhaseFlags.Semantic,
isTypeAnalysisPassNeeded: true,
areTypesResolved: false
};
this.typeNumbers = new Map();
this.nameIdentifiers = new Set();
this.importedModules = new Set();
this.importedBy = new Set();
}
directives = [];
moduleName;
fileName;
content;
analysis = {
version: 0,
nextPhase: PhaseFlags.Semantic,
isTypeAnalysisPassNeeded: true,
areTypesResolved: false,
};
typeNumbers = new Map();
nameIdentifiers = new Set();
importedModules = new Set();
importedBy = new Set();
get childrenOrEmpty() {

@@ -290,2 +324,5 @@ return this.directives;

class ParameterNode extends Node {
parameterName;
parameterType;
defaultValue;
constructor(astNode, parameterName) {

@@ -301,21 +338,24 @@ super(astNode);

class FunctionNode extends Node {
functionName;
functionReturnType;
parameters = [];
body;
get childrenOrEmpty() {
return [this.functionName, ...this.parameters, this.functionReturnType, this.body];
}
/** Array of locals by index. */
localsByIndex = [];
/** List of additional non-parameter locals. */
additionalLocals = [];
tempI32s = null;
tempI64s = null;
tempF32s = null;
tempF64s = null;
constructor(astNode, functionName) {
super(astNode);
this.functionName = functionName;
this.parameters = [];
/** Array of locals by index. */
this.localsByIndex = [];
/** List of additional non-parameter locals. */
this.additionalLocals = [];
this.tempI32s = null;
this.tempI64s = null;
this.tempF32s = null;
this.tempF64s = null;
}
get childrenOrEmpty() {
return [this.functionName, ...this.parameters, this.functionReturnType, this.body];
}
processParameters() {
let localIndex = 0;
this.parameters.forEach(parameter => {
this.parameters.forEach((parameter) => {
let local = new Local(localIndex++, parameter.parameterName.name, parameter.parameterName);

@@ -438,2 +478,7 @@ this.localsByIndex[local.index] = local;

class ImplDirective extends DirectiveNode {
targetImpl;
directives;
baseImpl;
selfTypeName;
namespaceNames = new Map();
constructor(astNode, targetImpl, directives) {

@@ -443,3 +488,2 @@ super(astNode);

this.directives = directives;
this.namespaceNames = new Map();
}

@@ -451,3 +495,3 @@ get childrenOrEmpty() {

...(this.baseImpl ? [this.baseImpl] : []),
...(this.directives || [])
...(this.directives || []),
];

@@ -458,7 +502,8 @@ }

class ImportDirectiveNode extends DirectiveNode {
module;
allItems = true;
alias = null;
constructor(astNode, module) {
super(astNode);
this.module = module;
this.allItems = true;
this.alias = null;
}

@@ -471,2 +516,4 @@ get childrenOrEmpty() {

class FunDirectiveNode extends DirectiveNode {
functionNode;
decorators;
constructor(astNode, functionNode, decorators) {

@@ -483,2 +530,3 @@ super(astNode);

class EffectDirectiveNode extends DirectiveNode {
effect;
get childrenOrEmpty() {

@@ -490,6 +538,7 @@ return [...(this.decorators || []), this.effect];

class OverloadedFunctionNode extends DirectiveNode {
functionName;
functions = [];
constructor(astNode, functionName) {
super(astNode);
this.functionName = functionName;
this.functions = [];
}

@@ -502,2 +551,5 @@ get childrenOrEmpty() {

class VarDeclarationNode extends Node {
variableName;
value;
variableType;
constructor(astNode, variableName, value) {

@@ -514,2 +566,3 @@ super(astNode);

class VarDirectiveNode extends DirectiveNode {
decl;
constructor(astNode, decl) {

@@ -525,2 +578,4 @@ super(astNode);

class AssignmentNode extends Node {
lhs;
rhs;
constructor(astNode, lhs, rhs) {

@@ -537,2 +592,4 @@ super(astNode);

class TypeDirectiveNode extends DirectiveNode {
variableName;
valueType;
constructor(astNode, variableName) {

@@ -548,2 +605,6 @@ super(astNode);

class TraitDirectiveNode extends DirectiveNode {
traitName;
directives;
namespaceNames = new Map();
selfTypeName;
constructor(astNode, traitName, directives) {

@@ -553,3 +614,2 @@ super(astNode);

this.directives = directives;
this.namespaceNames = new Map();
}

@@ -562,2 +622,4 @@ get childrenOrEmpty() {

class EnumDirectiveNode extends DirectiveNode {
variableName;
declarations;
constructor(astNode, variableName, declarations) {

@@ -574,6 +636,14 @@ super(astNode);

class LiteralNode extends ExpressionNode {
typeName;
get value() {
throw new Error('not implemented');
}
set value(_) {
throw new Error('not implemented');
}
rawValue = '';
resolvedReference;
constructor(astNode, typeName) {
super(astNode);
this.typeName = typeName;
this.rawValue = '';
if (astNode) {

@@ -583,7 +653,6 @@ this.rawValue = astNode.text;

}
get value() { throw new Error('not implemented'); }
set value(_) { throw new Error('not implemented'); }
}
Nodes.LiteralNode = LiteralNode;
class FloatLiteral extends LiteralNode {
suffixReference;
get value() {

@@ -601,2 +670,3 @@ return parseFloat(this.rawValue);

class IntegerLiteral extends LiteralNode {
suffixReference;
get value() {

@@ -620,2 +690,3 @@ return parseInt(this.rawValue, 10);

class StructTypeNode extends TypeNode {
parameters;
constructor(astNode, parameters) {

@@ -631,6 +702,3 @@ super(astNode);

class StackTypeNode extends TypeNode {
constructor() {
super(...arguments);
this.metadata = {};
}
metadata = {};
get childrenOrEmpty() {

@@ -678,2 +746,4 @@ return [];

}
offset;
length;
get childrenOrEmpty() {

@@ -685,9 +755,7 @@ return [];

class AbstractFunctionCallNode extends ExpressionNode {
resolvedFunctionType;
}
Nodes.AbstractFunctionCallNode = AbstractFunctionCallNode;
class InjectedFunctionCallNode extends AbstractFunctionCallNode {
constructor() {
super(...arguments);
this.argumentsNode = [];
}
argumentsNode = [];
get childrenOrEmpty() {

@@ -699,2 +767,5 @@ return this.argumentsNode;

class FunctionCallNode extends AbstractFunctionCallNode {
functionNode;
argumentsNode;
isInfix = false;
constructor(astNode, functionNode, argumentsNode) {

@@ -704,3 +775,2 @@ super(astNode);

this.argumentsNode = argumentsNode;
this.isInfix = false;
}

@@ -713,2 +783,5 @@ get childrenOrEmpty() {

class BinaryExpressionNode extends ExpressionNode {
operator;
lhs;
rhs;
constructor(astNode, operator, lhs, rhs) {

@@ -726,8 +799,2 @@ super(astNode);

class AsExpressionNode extends AbstractFunctionCallNode {
constructor(astNode, lhs, rhs) {
super(astNode);
this.argumentsNode = [];
this.lhs = lhs;
this.rhs = rhs;
}
get lhs() {

@@ -739,2 +806,9 @@ return this.argumentsNode[0];

}
argumentsNode = [];
rhs;
constructor(astNode, lhs, rhs) {
super(astNode);
this.lhs = lhs;
this.rhs = rhs;
}
get childrenOrEmpty() {

@@ -746,8 +820,2 @@ return [this.lhs, this.rhs];

class IsExpressionNode extends AbstractFunctionCallNode {
constructor(astNode, lhs, rhs) {
super(astNode);
this.argumentsNode = [];
this.lhs = lhs;
this.rhs = rhs;
}
get lhs() {

@@ -759,2 +827,10 @@ return this.argumentsNode[0];

}
booleanReference;
argumentsNode = [];
rhs;
constructor(astNode, lhs, rhs) {
super(astNode);
this.lhs = lhs;
this.rhs = rhs;
}
get childrenOrEmpty() {

@@ -766,8 +842,3 @@ return [this.lhs, this.rhs];

class UnaryExpressionNode extends AbstractFunctionCallNode {
constructor(astNode, operator, rhs) {
super(astNode);
this.operator = operator;
this.argumentsNode = [];
this.rhs = rhs;
}
operator;
get rhs() {

@@ -779,2 +850,8 @@ return this.argumentsNode[0];

}
argumentsNode = [];
constructor(astNode, operator, rhs) {
super(astNode);
this.operator = operator;
this.rhs = rhs;
}
get childrenOrEmpty() {

@@ -786,2 +863,4 @@ return [this.rhs];

class WasmAtomNode extends Node {
symbol;
args;
constructor(astNode, symbol, args) {

@@ -798,2 +877,3 @@ super(astNode);

class WasmExpressionNode extends ExpressionNode {
atoms;
constructor(astNode, atoms) {

@@ -809,2 +889,5 @@ super(astNode);

class MatcherNode extends ExpressionNode {
rhs;
declaredName;
booleanReference;
constructor(astNode, rhs) {

@@ -820,2 +903,6 @@ super(astNode);

class IfNode extends ExpressionNode {
condition;
truePart;
falsePart;
booleanReference;
constructor(astNode, condition, truePart, falsePart) {

@@ -833,2 +920,4 @@ super(astNode);

class MatchConditionNode extends MatcherNode {
condition;
rhs;
constructor(astNode, condition, rhs) {

@@ -845,2 +934,6 @@ super(astNode, rhs);

class MatchCaseIsNode extends MatcherNode {
typeReference;
rhs;
deconstructorNames;
resolvedFunctionType;
constructor(astNode, typeReference, rhs) {

@@ -857,2 +950,5 @@ super(astNode, rhs);

class MatchLiteralNode extends MatcherNode {
literal;
rhs;
resolvedFunctionType;
constructor(astNode, literal, rhs) {

@@ -869,6 +965,3 @@ super(astNode, rhs);

class UnionTypeNode extends TypeNode {
constructor() {
super(...arguments);
this.of = [];
}
of = [];
get childrenOrEmpty() {

@@ -880,6 +973,3 @@ return this.of;

class IntersectionTypeNode extends TypeNode {
constructor() {
super(...arguments);
this.of = [];
}
of = [];
get childrenOrEmpty() {

@@ -891,2 +981,5 @@ return this.of || [];

class StructDeclarationNode extends TypeNode {
declaredName;
parameters;
isPublic = true;
constructor(astNode, declaredName, parameters) {

@@ -896,3 +989,2 @@ super(astNode);

this.parameters = parameters;
this.isPublic = true;
}

@@ -905,2 +997,4 @@ get childrenOrEmpty() {

class EffectDeclarationNode extends Node {
name;
elements;
constructor(astNode, name) {

@@ -919,2 +1013,5 @@ super(astNode);

class PatternMatcherNode extends ExpressionNode {
lhs;
matchingSet;
carryType;
constructor(astNode, lhs, matchingSet) {

@@ -931,2 +1028,3 @@ super(astNode);

class LoopNode extends ExpressionNode {
body;
constructor(astNode, body) {

@@ -953,3 +1051,3 @@ super(astNode);

Nodes.BreakNode = BreakNode;
})(Nodes = exports.Nodes || (exports.Nodes = {}));
})(Nodes || (exports.Nodes = Nodes = {}));
function findNodesByType(astRoot, type, list = []) {

@@ -959,8 +1057,7 @@ if (astRoot instanceof type) {

}
astRoot.children.forEach($ => findNodesByType($, type, list));
astRoot.children.forEach(($) => findNodesByType($, type, list));
return list;
}
exports.findNodesByType = findNodesByType;
function findNodesByTypeInChildren(astRoot, type, list = []) {
astRoot.children.forEach($ => {
astRoot.children.forEach(($) => {
if ($ instanceof type) {

@@ -972,3 +1069,2 @@ list.push($);

}
exports.findNodesByTypeInChildren = findNodesByTypeInChildren;
//# sourceMappingURL=nodes.js.map

@@ -8,11 +8,12 @@ "use strict";

class ParsingContext {
system;
messageCollector = new MessageCollector_1.MessageCollector();
paths = [];
modulesInContext = new Map();
// internalIdentifiers of the functions that should be part of the wasm table
functionsInTable = new Set();
signatures = new Map();
typeNumbers = new Map();
constructor(system) {
this.system = system;
this.messageCollector = new MessageCollector_1.MessageCollector();
this.paths = [];
this.modulesInContext = new Map();
// internalIdentifiers of the functions that should be part of the wasm table
this.functionsInTable = new Set();
this.signatures = new Map();
this.typeNumbers = new Map();
// stub

@@ -19,0 +20,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAST = void 0;
exports.getAST = getAST;
const nodes_1 = require("../nodes");

@@ -600,3 +600,2 @@ const NodeError_1 = require("../NodeError");

}
exports.getAST = getAST;
//# sourceMappingURL=canonicalPhase.js.map
import { Nodes } from '../nodes';
import { ParsingContext } from '../ParsingContext';
declare type CompilationModuleResult = {
type CompilationModuleResult = {
document: Nodes.DocumentNode;

@@ -5,0 +5,0 @@ moduleParts: any[];

@@ -18,21 +18,24 @@ "use strict";

});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CodeGenerationPhaseResult = void 0;
const t = __importStar(require("@webassemblyjs/ast"));
const ast = __importStar(require("@webassemblyjs/ast"));
const wast_printer_1 = require("@webassemblyjs/wast-printer");
globalThis['Binaryen'] = {
TOTAL_MEMORY: 16777216 * 8
};
const binaryen_1 = __importDefault(require("binaryen"));
const wabt_1 = __importDefault(require("wabt"));
const t = ast;
const annotations_1 = require("../annotations");

@@ -47,3 +50,2 @@ const helpers_1 = require("../helpers");

const findAllErrors_1 = require("../findAllErrors");
const wabt = (0, wabt_1.default)();
const starterName = t.identifier('%%START%%');

@@ -67,4 +69,3 @@ const optimizeLevel = 3;

fnType, // signature
statements // body
);
statements);
}

@@ -82,3 +83,3 @@ function getTypeForFunctionType(fn, errorNode) {

id: fn.parameterNames[$$] || '$param' + $$,
valtype: $.binaryenType
valtype: $.binaryenType,
})), retType);

@@ -107,3 +108,3 @@ }

restartFunctionSeqId(fn);
const locals = fn.additionalLocals.map($ => t.instruction('local', [t.identifier($.name), t.valtypeLiteral($.type.binaryenType)]));
const locals = fn.additionalLocals.map(($) => t.instruction('local', [t.identifier($.name), t.valtypeLiteral($.type.binaryenType)]));
if (!fn.body)

@@ -113,4 +114,3 @@ throw new NodeError_1.LysCompilerError('Function has no body', fn);

fnType, // signature
[...locals, ...emitList(fn.body, document, parsingContext)] // body
);
[...locals, ...emitList(fn.body, document, parsingContext)]);
return moduleFun;

@@ -124,3 +124,3 @@ }

return t.blockInstruction(breakLabel, [
t.loopInstruction(continueLabel, void 0, emitList(node.body, document, parsingContext))
t.loopInstruction(continueLabel, void 0, emitList(node.body, document, parsingContext)),
]);

@@ -130,3 +130,3 @@ }

const matchers = match.matchingSet.slice(0);
const ixDefaultBranch = matchers.findIndex($ => $ instanceof nodes_1.Nodes.MatchDefaultNode);
const ixDefaultBranch = matchers.findIndex(($) => $ instanceof nodes_1.Nodes.MatchDefaultNode);
const local = match.getAnnotation(annotations_1.annotations.LocalIdentifier).local;

@@ -153,3 +153,3 @@ const lhs = t.instruction('local.set', [t.identifier(local.name), emit(match.lhs, document, parsingContext)]);

t.instruction('local.get', [t.identifier(local.name)]),
emit(node.literal, document, parsingContext)
emit(node.literal, document, parsingContext),
]);

@@ -159,3 +159,3 @@ const body = emit(node.rhs, document, parsingContext);

condition,
body
body,
};

@@ -169,3 +169,3 @@ }

const condition = t.callInstruction(t.identifier(ofType.name.internalIdentifier), [
t.instruction('local.get', [t.identifier(local.name)])
t.instruction('local.get', [t.identifier(local.name)]),
]);

@@ -175,3 +175,3 @@ const body = emit(node.rhs, document, parsingContext);

condition,
body
body,
};

@@ -181,7 +181,7 @@ }

})
.filter($ => !!$);
.filter(($) => !!$);
const exitBlock = 'B' + getFunctionSeqId(match);
const exitLabel = t.identifier(exitBlock);
const breaks = blocks
.filter($ => !!$.condition)
.filter(($) => !!$.condition)
.map(($, $$) => t.instruction('br_if', [t.identifier(`${exitBlock}_${$$}`), $.condition]));

@@ -202,3 +202,3 @@ const ret = blocks.reduceRight((prev, curr, ix) => {

if (nodes instanceof Array) {
return (0, helpers_1.flatten)(nodes.map($ => emit($, document, parsingContext)));
return (0, helpers_1.flatten)(nodes.map(($) => emit($, document, parsingContext)));
}

@@ -237,3 +237,3 @@ else {

}
return t.instruction(node.symbol, (node.args || []).map($ => emitWast($, document, parsingContext)));
return t.instruction(node.symbol, (node.args || []).map(($) => emitWast($, document, parsingContext)));
}

@@ -247,3 +247,3 @@ function emitImplicitCall(node, document, parsingContext) {

throw new NodeError_1.LysCompilerError('implicit call is not a function', node);
return t.callInstruction(t.identifier(ofType.name.internalIdentifier), implicitCallData.implicitCall.argumentsNode.map($ => emit($, document, parsingContext)));
return t.callInstruction(t.identifier(ofType.name.internalIdentifier), implicitCallData.implicitCall.argumentsNode.map(($) => emit($, document, parsingContext)));
}

@@ -255,3 +255,3 @@ function getReferencedSymbol(node) {

symbol: local.local.name,
type: 'VALUE'
type: 'VALUE',
};

@@ -266,3 +266,3 @@ }

symbol: fn.nameIdentifier.internalIdentifier,
type: 'TABLE'
type: 'TABLE',
};

@@ -280,6 +280,6 @@ }

const retType = ret.binaryenType ? [ret.binaryenType] : [];
const name = 'lys::' + fn.parameterTypes.map($ => $.binaryenType).join('_') + '->' + (retType.join('_') || 'void');
const name = 'lys::' + fn.parameterTypes.map(($) => $.binaryenType).join('_') + '->' + (retType.join('_') || 'void');
if (!parsingContext.signatures.has(name)) {
parsingContext.signatures.set(name, t.typeInstruction(t.identifier(name), t.signature(fn.parameterTypes.map($ => ({
valtype: $.binaryenType
parsingContext.signatures.set(name, t.typeInstruction(t.identifier(name), t.signature(fn.parameterTypes.map(($) => ({
valtype: $.binaryenType,
})), retType)));

@@ -311,3 +311,3 @@ }

return t.callIndirectInstruction(signature, node.argumentsNode
.map($ => emit($, document, parsingContext))
.map(($) => emit($, document, parsingContext))
.concat(emit(node.functionNode, document, parsingContext)));

@@ -321,3 +321,3 @@ }

throw new NodeError_1.LysCompilerError(`${funType}.internalIdentifier is falsy`, node);
return t.callInstruction(t.identifier(funType.name.internalIdentifier), node.argumentsNode.map($ => emit($, document, parsingContext)));
return t.callInstruction(t.identifier(funType.name.internalIdentifier), node.argumentsNode.map(($) => emit($, document, parsingContext)));
}

@@ -328,3 +328,3 @@ else if (node instanceof nodes_1.Nodes.UnknownExpressionNode) {

else if (node instanceof nodes_1.Nodes.WasmExpressionNode) {
return (0, helpers_1.flatten)(node.atoms.map($ => emitWast($, document, parsingContext)));
return (0, helpers_1.flatten)(node.atoms.map(($) => emitWast($, document, parsingContext)));
}

@@ -379,3 +379,3 @@ else if (node instanceof nodes_1.Nodes.ContinueNode) {

t.instruction('global.set', [t.identifier(local.name), emit(node.rhs, document, parsingContext)]),
t.instruction('global.get', [t.identifier(local.name)])
t.instruction('global.get', [t.identifier(local.name)]),
], types_1.TypeHelpers.getNodeType(node.rhs).binaryenType);

@@ -398,3 +398,3 @@ }

let instr = [];
node.statements.forEach($ => {
node.statements.forEach(($) => {
// TODO: Drop here things

@@ -467,6 +467,10 @@ let emited = emit($, document, parsingContext);

class CodeGenerationPhaseResult {
document;
parsingContext;
programAST;
buffer;
sourceMap = null;
constructor(document, parsingContext) {
this.document = document;
this.parsingContext = parsingContext;
this.sourceMap = null;
(0, findAllErrors_1.failWithErrors)(`Compilation`, parsingContext);

@@ -481,38 +485,28 @@ try {

async validate(optimize = true, debug = false) {
let text = (0, wast_printer_1.print)(this.programAST);
const theWabt = await wabt;
let wabtModule;
const { default: binaryen } = await import('binaryen');
const parseText = (text) => {
try {
return binaryen.parseText(text);
}
catch (e) {
const invalidFile = this.parsingContext.system.resolvePath(this.parsingContext.system.getCurrentDirectory(), 'failed_debug_wat.wat');
this.parsingContext.system.writeFile(invalidFile, text);
console.error('Error while parsing generated code. Writing debug WAT to ' + invalidFile);
console.error(e);
throw e;
}
};
try {
wabtModule = theWabt.parseWat(this.document.moduleName, text, {});
}
catch (e) {
const invalidFile = this.parsingContext.system.resolvePath(this.parsingContext.system.getCurrentDirectory(), 'failed_debug_wat.wat');
this.parsingContext.system.writeFile(invalidFile, text);
console.error('Error while parsing generated code. Writing debug WAT to ' + invalidFile);
console.error(e);
throw e;
}
try {
wabtModule.resolveNames();
wabtModule.validate();
}
catch (e) {
const invalidFile = this.parsingContext.system.resolvePath(this.parsingContext.system.getCurrentDirectory(), 'failed_debug_wat.wat');
this.parsingContext.system.writeFile(invalidFile, text);
console.error('Error while resolving names and validate code. Writing debug WAT to ' + invalidFile);
console.error(e);
this.parsingContext.messageCollector.error(e, this.document.astNode);
throw e;
}
const binary = wabtModule.toBinary({ log: false, write_debug_names: debug });
wabtModule.destroy();
try {
binaryen_1.default.setOptimizeLevel(optimizeLevel);
binaryen_1.default.setShrinkLevel(shrinkLevel);
binaryen_1.default.setDebugInfo(debug || !optimize);
const module = binaryen_1.default.readBinary(binary.buffer);
if (!debug) {
module.runPasses(['duplicate-function-elimination']);
binaryen.setOptimizeLevel(optimizeLevel);
binaryen.setShrinkLevel(shrinkLevel);
binaryen.setDebugInfo(debug || !optimize);
let text = (0, wast_printer_1.print)(this.programAST);
const module = parseText(text);
// if (!debug) {
// module.runPasses(['duplicate-function-elimination']);
// }
module.runPasses(['remove-unused-module-elements']);
if (optimize) {
module.optimize();
}
module.runPasses(['remove-unused-module-elements']);
if (module.validate() === 0) {

@@ -523,15 +517,2 @@ this.parsingContext.messageCollector.error(new NodeError_1.LysCompilerError('binaryen validation failed', this.document));

let last = module.emitBinary('sourceMap.map');
if (optimize) {
do {
module.optimize();
let next = module.emitBinary('sourceMap.map');
if (next.binary.length >= last.binary.length) {
// a if (next.length > last.length) {
// a this.parsingContext.system.write('Last converge was suboptimial.\n');
// a }
break;
}
last = next;
} while (true);
}
this.buffer = last.binary;

@@ -541,17 +522,3 @@ this.sourceMap = last.sourceMap;

else {
let last = module.emitBinary();
if (optimize) {
do {
module.optimize();
let next = module.emitBinary();
if (next.length >= last.length) {
// a if (next.length > last.length) {
// a this.parsingContext.system.write('Last converge was suboptimial.\n');
// a }
break;
}
last = next;
} while (true);
}
this.buffer = last;
this.buffer = module.emitBinary();
}

@@ -569,3 +536,4 @@ module.dispose();

if (this.buffer) {
const module = binaryen_1.default.readBinary(this.buffer);
const { default: binaryen } = await import('binaryen');
const module = binaryen.readBinary(this.buffer);
const ret = module.emitText();

@@ -594,4 +562,4 @@ module.dispose();

memory: new WebAssembly.Memory({ initial: 256 }),
table: new WebAssembly.Table({ initial: 0, element: 'funcref' })
}
table: new WebAssembly.Table({ initial: 0, element: 'funcref' }),
},
};

@@ -634,7 +602,8 @@ // Create the instance.

const offsetToken = t.objectInstruction('const', 'i32', [numberLiteral]);
dataSection.push(t.data(t.memIndexLiteral(0), offsetToken, t.byteArray(bytes)));
// dataSection.push(t.data(t.memIndexLiteral(dataCount++), offsetToken, t.byteArray(bytes)));
dataSection.push(t.data(t.identifier(`mem_${offset}`), offsetToken, t.byteArray(bytes)));
return offset + size;
}
}, startMemory);
const createdGlobals = globals.map($ => {
const createdGlobals = globals.map(($) => {
// TODO: If the value is a literal, do not defer initialization to starters

@@ -650,6 +619,6 @@ const mut = 'var'; // TODO: $ instanceof Nodes.ValDeclarationNode ? 'const' : 'var';

});
functions.forEach($ => {
functions.forEach(($) => {
if ($.parent instanceof nodes_1.Nodes.TraitDirectiveNode)
return;
$.functions.forEach(fun => {
$.functions.forEach((fun) => {
const functionName = fun.functionNode.functionName;

@@ -676,3 +645,3 @@ if (functionName.hasAnnotation(annotations_1.annotations.Extern)) {

endMemory,
imports
imports,
};

@@ -683,3 +652,3 @@ }

const moduleList = (0, helpers_2.getModuleSet)(this.document, this.parsingContext);
moduleList.forEach($ => {
moduleList.forEach(($) => {
const compilation = this.parsingContext.getPhase($, nodes_1.PhaseFlags.Compilation);

@@ -692,3 +661,3 @@ if (!exportList.includes(compilation)) {

const moduleParts = [];
const generatedModules = exportList.map($ => {
const generatedModules = exportList.map(($) => {
const ret = this.generatePhase($, currentMemory);

@@ -701,11 +670,11 @@ currentMemory = ret.endMemory;

const tableElems = this.parsingContext.getOrderedTable();
this.parsingContext.signatures.forEach($ => moduleParts.push($));
this.parsingContext.signatures.forEach(($) => moduleParts.push($));
const table = t.table('funcref', t.limit(tableElems.length), t.identifier('lys::internal-functions'));
const elem = t.elem(
// table
t.indexLiteral(0),
t.identifier('elem_table_0'),
// offset
[t.objectInstruction('const', 'i32', [t.numberLiteralFromRaw(0)])],
// elems
tableElems.map(x => t.identifier(x)));
tableElems.map((x) => t.identifier(x)));
const memory = t.memory(t.limit(1), t.identifier('mem'));

@@ -718,3 +687,3 @@ moduleParts.push(table);

moduleParts.push(t.moduleExport('memory', t.moduleExportDescr('Memory', t.identifier('mem'))));
generatedModules.reverse().forEach(ret => {
generatedModules.reverse().forEach((ret) => {
moduleParts.push(...ret.moduleParts);

@@ -721,0 +690,0 @@ starters.push(...ret.starters);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeCompilationPhase = exports.executePreCompilationPhase = exports.detectTailCall = void 0;
exports.detectTailCall = void 0;
exports.executePreCompilationPhase = executePreCompilationPhase;
exports.executeCompilationPhase = executeCompilationPhase;
const nodes_1 = require("../nodes");

@@ -194,3 +196,2 @@ const walker_1 = require("../walker");

}
exports.executePreCompilationPhase = executePreCompilationPhase;
function executeCompilationPhase(moduleName, parsingContext) {

@@ -211,3 +212,2 @@ const document = parsingContext.getPhase(moduleName, nodes_1.PhaseFlags.Compilation - 1);

}
exports.executeCompilationPhase = executeCompilationPhase;
//# sourceMappingURL=compilationPhase.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.forEachModuleWithPhase = exports.getModuleSet = exports.collectImports = exports.fixParents = exports.getDocument = void 0;
exports.fixParents = void 0;
exports.getDocument = getDocument;
exports.collectImports = collectImports;
exports.getModuleSet = getModuleSet;
exports.forEachModuleWithPhase = forEachModuleWithPhase;
const nodes_1 = require("../nodes");

@@ -17,3 +21,2 @@ const NodeError_1 = require("../NodeError");

}
exports.getDocument = getDocument;
exports.fixParents = (0, walker_1.walkPreOrder)((node, _, parent) => {

@@ -42,3 +45,2 @@ if (parent) {

}
exports.collectImports = collectImports;
/**

@@ -74,3 +76,2 @@ * Returns a list of all the modules that are necessary to compile the given

}
exports.getModuleSet = getModuleSet;
function forEachModuleWithPhase(mainModule, parsingContext, phase, debug = false, cb) {

@@ -85,3 +86,2 @@ const document = parsingContext.getPhase(mainModule, phase, debug);

}
exports.forEachModuleWithPhase = forEachModuleWithPhase;
//# sourceMappingURL=helpers.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.analyze = void 0;
exports.analyze = analyze;
const nodes_1 = require("../nodes");

@@ -44,3 +44,2 @@ const semanticPhase_1 = require("./semanticPhase");

}
exports.analyze = analyze;
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeScopePhase = exports.executeNameInitializationPhase = void 0;
exports.executeNameInitializationPhase = executeNameInitializationPhase;
exports.executeScopePhase = executeScopePhase;
const nodes_1 = require("../nodes");

@@ -373,3 +374,2 @@ const walker_1 = require("../walker");

}
exports.executeNameInitializationPhase = executeNameInitializationPhase;
function executeScopePhase(moduleName, parsingContext) {

@@ -386,3 +386,2 @@ const document = parsingContext.getPhase(moduleName, nodes_1.PhaseFlags.Scope - 1);

}
exports.executeScopePhase = executeScopePhase;
//# sourceMappingURL=scopePhase.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeSemanticPhase = void 0;
exports.executeSemanticPhase = executeSemanticPhase;
const nodes_1 = require("../nodes");

@@ -578,3 +578,2 @@ const walker_1 = require("../walker");

}
exports.executeSemanticPhase = executeSemanticPhase;
//# sourceMappingURL=semanticPhase.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeTypeCheck = exports.executeTypeInitialization = void 0;
exports.executeTypeInitialization = executeTypeInitialization;
exports.executeTypeCheck = executeTypeCheck;
const nodes_1 = require("../nodes");

@@ -110,3 +111,2 @@ const walker_1 = require("../walker");

}
exports.executeTypeInitialization = executeTypeInitialization;
function findNonFinalizedImportsRecursive(moduleName, parsingContext, queue, visited = new Set()) {

@@ -229,3 +229,2 @@ if (visited.has(moduleName))

}
exports.executeTypeCheck = executeTypeCheck;
//# sourceMappingURL=typePhase.js.map

@@ -5,2 +5,7 @@ "use strict";

class Reference {
referencedNode;
scope;
type;
moduleName;
usages = 0;
constructor(referencedNode, scope, type, moduleName = null) {

@@ -11,3 +16,2 @@ this.referencedNode = referencedNode;

this.moduleName = moduleName;
this.usages = 0;
}

@@ -14,0 +18,0 @@ /** Returns true if the reference points to a declaration in the same module */

import { Nodes } from './nodes';
import { Reference } from './Reference';
import { ParsingContext } from './ParsingContext';
export declare type ReferenceType = 'TYPE' | 'VALUE' | 'FUNCTION' | 'TRAIT';
export type ReferenceType = 'TYPE' | 'VALUE' | 'FUNCTION' | 'TRAIT';
export declare class Scope {

@@ -6,0 +6,0 @@ parsingContext: ParsingContext;

@@ -10,2 +10,13 @@ "use strict";

class Scope {
parsingContext;
moduleName;
parent;
nameHint;
localScopeDeclares = new Set();
exportedNames = new Set();
nameMappings = {};
localUsages = {};
importedModules = new Map();
childrenScopes = [];
name;
constructor(parsingContext, moduleName, parent = null, nameHint = '') {

@@ -16,8 +27,2 @@ this.parsingContext = parsingContext;

this.nameHint = nameHint;
this.localScopeDeclares = new Set();
this.exportedNames = new Set();
this.nameMappings = {};
this.localUsages = {};
this.importedModules = new Map();
this.childrenScopes = [];
this.name = this.parsingContext.getInternalName(moduleName, nameHint + '[child_scope]');

@@ -24,0 +29,0 @@ }

import { Nodes } from './nodes';
import { Scope } from './Scope';
export declare type Valtype = 'i32' | 'i64' | 'f32' | 'f64' | 'u32' | 'label';
export type Valtype = 'i32' | 'i64' | 'f32' | 'f64' | 'u32' | 'label';
export declare enum NativeTypes {

@@ -150,3 +150,3 @@ i32 = "i32",

};
getSchemaValue(name: string, ctx: Scope): any;
getSchemaValue(name: string, ctx: Scope): number | undefined;
}

@@ -153,0 +153,0 @@ export declare class TypeAlias extends Type {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeHelpers = exports.UNRESOLVED_TYPE = exports.InjectableTypes = exports.AnyType = exports.SelfType = exports.NeverType = exports.TypeType = exports.TraitType = exports.TypeAlias = exports.UnionType = exports.getUnderlyingTypeFromAlias = exports.IntersectionType = exports.RefType = exports.StackType = exports.StructType = exports.FunctionType = exports.FunctionSignatureType = exports.areEqualTypes = exports.Type = exports.NativeTypes = void 0;
exports.TypeHelpers = exports.UNRESOLVED_TYPE = exports.InjectableTypes = exports.AnyType = exports.SelfType = exports.NeverType = exports.TypeType = exports.TraitType = exports.TypeAlias = exports.UnionType = exports.IntersectionType = exports.RefType = exports.StackType = exports.StructType = exports.FunctionType = exports.FunctionSignatureType = exports.Type = exports.NativeTypes = void 0;
exports.areEqualTypes = areEqualTypes;
exports.getUnderlyingTypeFromAlias = getUnderlyingTypeFromAlias;
const typeHelpers_1 = require("./types/typeHelpers");

@@ -14,3 +16,3 @@ var NativeTypes;

NativeTypes["void"] = "void";
})(NativeTypes = exports.NativeTypes || (exports.NativeTypes = {}));
})(NativeTypes || (exports.NativeTypes = NativeTypes = {}));
class Type {

@@ -78,10 +80,7 @@ get binaryenType() {

}
exports.areEqualTypes = areEqualTypes;
class FunctionSignatureType extends Type {
constructor() {
super(...arguments);
this.nativeType = NativeTypes.func;
this.parameterTypes = [];
this.parameterNames = [];
}
nativeType = NativeTypes.func;
parameterTypes = [];
parameterNames = [];
returnType;
canBeAssignedTo(type, ctx) {

@@ -150,7 +149,8 @@ if (type instanceof FunctionSignatureType) {

class FunctionType extends Type {
name;
nativeType = NativeTypes.func;
signature = new FunctionSignatureType();
constructor(name) {
super();
this.name = name;
this.nativeType = NativeTypes.func;
this.signature = new FunctionSignatureType();
}

@@ -203,6 +203,7 @@ equals(type) {

class StructType extends Type {
parameters;
nativeType = NativeTypes.i64;
constructor(parameters) {
super();
this.parameters = parameters;
this.nativeType = NativeTypes.i64;
}

@@ -255,2 +256,6 @@ equals(type) {

class StackType extends Type {
typeName;
nativeType;
byteSize;
static nativeTypes = new Map();
constructor(typeName, nativeType, byteSize) {

@@ -311,10 +316,10 @@ super();

exports.StackType = StackType;
StackType.nativeTypes = new Map();
const u32 = StackType.of('u32', NativeTypes.i32, 4);
const voidType = StackType.of('void', NativeTypes.void, 0);
class RefType extends Type {
static instance = new RefType();
nativeType = NativeTypes.i64;
byteSize = 8;
constructor() {
super();
this.nativeType = NativeTypes.i64;
this.byteSize = 8;
}

@@ -366,8 +371,8 @@ // returns true when otherType is explicityly RefType.instance

exports.RefType = RefType;
RefType.instance = new RefType();
class IntersectionType extends Type {
of;
nativeType = NativeTypes.funcref;
constructor(of = []) {
super();
this.of = of;
this.nativeType = NativeTypes.funcref;
}

@@ -438,9 +443,6 @@ toString() {

}
exports.getUnderlyingTypeFromAlias = getUnderlyingTypeFromAlias;
class UnionType extends Type {
constructor(of = [], simplified = false) {
super();
this.of = of;
this.simplified = simplified;
}
of;
simplified;
nativeType;
get binaryenType() {

@@ -463,2 +465,7 @@ const nativeTypes = new Set();

}
constructor(of = [], simplified = false) {
super();
this.of = of;
this.simplified = simplified;
}
static of(x) {

@@ -691,9 +698,4 @@ if (x instanceof UnionType) {

class TypeAlias extends Type {
constructor(name, of) {
super();
this.name = name;
this.of = of;
this.discriminant = null;
this.traits = new Map();
}
name;
of;
get binaryenType() {

@@ -705,2 +707,9 @@ return this.of.binaryenType;

}
discriminant = null;
traits = new Map();
constructor(name, of) {
super();
this.name = name;
this.of = of;
}
canBeAssignedTo(other, ctx) {

@@ -851,6 +860,3 @@ // | if (other instanceof TraitType) {

class TraitType extends Type {
constructor(traitNode) {
super();
this.traitNode = traitNode;
}
traitNode;
get binaryenType() {

@@ -862,2 +868,6 @@ return undefined;

}
constructor(traitNode) {
super();
this.traitNode = traitNode;
}
canBeAssignedTo(other, _ctx) {

@@ -907,2 +917,5 @@ return this === other;

class TypeType extends Type {
of;
nativeType;
static memMap = new WeakMap();
constructor(of) {

@@ -946,3 +959,2 @@ super();

exports.TypeType = TypeType;
TypeType.memMap = new WeakMap();
// https://en.wikipedia.org/wiki/Bottom_type

@@ -989,2 +1001,6 @@ // https://en.wikipedia.org/wiki/Fail-stop

class SelfType extends Type {
traitType;
get nativeType() {
return NativeTypes.funcref;
}
constructor(traitType) {

@@ -994,5 +1010,2 @@ super();

}
get nativeType() {
return NativeTypes.funcref;
}
toString() {

@@ -1060,3 +1073,3 @@ return 'Self';

TypeHelpers.setNodeType = setNodeType;
})(TypeHelpers = exports.TypeHelpers || (exports.TypeHelpers = {}));
})(TypeHelpers || (exports.TypeHelpers = TypeHelpers = {}));
//# sourceMappingURL=types.js.map

@@ -7,3 +7,3 @@ import { Nodes } from '../nodes';

export declare const MaxAnalysisPassCount = 100;
export declare type LysPropertyDescription = {
export type LysPropertyDescription = {
type: Type;

@@ -10,0 +10,0 @@ setter: boolean;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidType = void 0;
exports.isValidType = isValidType;
const types_1 = require("../types");

@@ -34,3 +34,2 @@ function isValidType(type) {

}
exports.isValidType = isValidType;
//# sourceMappingURL=typeHelpers.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.walk = exports.walkPreOrder = void 0;
exports.walkPreOrder = walkPreOrder;
exports.walk = walk;
const NodeError_1 = require("./NodeError");

@@ -12,3 +13,2 @@ const nodes_1 = require("./nodes");

}
exports.walkPreOrder = walkPreOrder;
function walk(node, phaseResult, cbEnter, cbLeave, parent = null) {

@@ -63,3 +63,2 @@ if (node) {

}
exports.walk = walk;
//# sourceMappingURL=walker.js.map

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.main = void 0;
exports.main = main;
const arg_1 = __importDefault(require("arg"));

@@ -287,3 +287,2 @@ const ParsingContext_1 = require("./compiler/ParsingContext");

}
exports.main = main;
//# sourceMappingURL=index-bin.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compile = exports.ParsingContext = void 0;
exports.ParsingContext = void 0;
exports.compile = compile;
const ParsingContext_1 = require("./compiler/ParsingContext");

@@ -16,3 +17,2 @@ Object.defineProperty(exports, "ParsingContext", { enumerable: true, get: function () { return ParsingContext_1.ParsingContext; } });

}
exports.compile = compile;
//# sourceMappingURL=index.js.map

@@ -18,9 +18,19 @@ "use strict";

});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });

@@ -27,0 +37,0 @@ exports.HidratedWebSystem = void 0;

@@ -36,8 +36,6 @@ "use strict";

class NodeSystem {
constructor() {
this.args = process.argv.slice(2);
this.newLine = _os.EOL;
this.useCaseSensitiveFileNames = this.isFileSystemCaseSensitive();
this.cwd = process.cwd();
}
args = process.argv.slice(2);
newLine = _os.EOL;
useCaseSensitiveFileNames = this.isFileSystemCaseSensitive();
cwd = process.cwd();
isFileSystemCaseSensitive() {

@@ -44,0 +42,0 @@ // win32\win64 are case insensitive platforms

@@ -6,8 +6,6 @@ "use strict";

class WebSystem {
constructor() {
this.args = [];
this.newLine = '\n';
this.useCaseSensitiveFileNames = true;
this.files = new Map();
}
args = [];
newLine = '\n';
useCaseSensitiveFileNames = true;
files = new Map();
write(s) {

@@ -14,0 +12,0 @@ console.log(s);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.indent = exports.printAST = void 0;
exports.printAST = printAST;
exports.indent = indent;
const nodes_1 = require("../compiler/nodes");

@@ -51,3 +52,2 @@ const types_1 = require("../compiler/types");

}
exports.printAST = printAST;
function indent(str, indentation = ' ') {

@@ -59,3 +59,2 @@ if (!str.replace) {

}
exports.indent = indent;
//# sourceMappingURL=astPrinter.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatColorAndReset = exports.resetEscapeSequence = exports.gutterSeparator = exports.gutterStyleSequence = exports.ForegroundColors = void 0;
exports.resetEscapeSequence = exports.gutterSeparator = exports.gutterStyleSequence = exports.ForegroundColors = void 0;
exports.formatColorAndReset = formatColorAndReset;
var ForegroundColors;

@@ -13,3 +14,3 @@ (function (ForegroundColors) {

ForegroundColors["Cyan"] = "\u001B[96m";
})(ForegroundColors = exports.ForegroundColors || (exports.ForegroundColors = {}));
})(ForegroundColors || (exports.ForegroundColors = ForegroundColors = {}));
exports.gutterStyleSequence = '\u001b[36m';

@@ -21,3 +22,2 @@ exports.gutterSeparator = '│ ';

}
exports.formatColorAndReset = formatColorAndReset;
//# sourceMappingURL=colors.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printErrors = exports.LysError = void 0;
exports.LysError = void 0;
exports.printErrors = printErrors;
const LineMapper_1 = require("./LineMapper");

@@ -35,3 +36,2 @@ const astPrinter_1 = require("./astPrinter");

}
exports.printErrors = printErrors;
function printErrors_(moduleName, parsingContext, errors, stripAnsi = false) {

@@ -38,0 +38,0 @@ const printLines = [];

"use strict";
// @lys-require=support::ffi
Object.defineProperty(exports, "__esModule", { value: true });
exports.hexDump = exports.readBytes = exports.readStringFromHeap = exports.writeStringToHeap = exports.readString = void 0;
exports.readString = readString;
exports.writeStringToHeap = writeStringToHeap;
exports.readStringFromHeap = readStringFromHeap;
exports.readBytes = readBytes;
exports.hexDump = hexDump;
function readString(memory, offset) {

@@ -21,3 +25,2 @@ const dv = new DataView(memory, offset);

}
exports.readString = readString;
function writeStringToHeap(instance, value) {

@@ -35,3 +38,2 @@ const allocatedString = instance.exports.ffi_allocateString(value.length);

}
exports.writeStringToHeap = writeStringToHeap;
function readStringFromHeap(instance, unsafeCPointer) {

@@ -55,3 +57,2 @@ const dv = new DataView(instance.exports.memory.buffer, unsafeCPointer - 4);

}
exports.readStringFromHeap = readStringFromHeap;
function readBytes(memory, offset) {

@@ -72,3 +73,2 @@ const dv = new DataView(memory, offset);

}
exports.readBytes = readBytes;
const BLOCK_SIZE = 16;

@@ -100,3 +100,2 @@ const DUMP_LIMIT = 1024 * 64;

}
exports.hexDump = hexDump;
//# sourceMappingURL=execution.js.map
export default function (getInstance: () => any): {
env: {
putchar: () => never;
printf: (offset: number, ...args: number[]) => void;

@@ -4,0 +5,0 @@ segfault: () => never;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
const execution_1 = require("../execution");

@@ -15,2 +16,5 @@ const tmpArrayBuffer = new DataView(new ArrayBuffer(1024));

env: {
putchar: function () {
throw new Error('putchar not implemented');
},
printf: function (offset, ...args) {

@@ -45,3 +49,2 @@ try {

}
exports.default = default_1;
//# sourceMappingURL=env.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTestResults = void 0;
exports.getTestResults = getTestResults;
exports.default = default_1;
const execution_1 = require("../execution");

@@ -13,3 +14,2 @@ const colors_1 = require("../colors");

}
exports.getTestResults = getTestResults;
function default_1(getInstance) {

@@ -109,3 +109,2 @@ function getTestStack() {

}
exports.default = default_1;
//# sourceMappingURL=test.js.map

@@ -5,6 +5,8 @@ "use strict";

class LineMapper {
content;
absPath;
mapping = null;
constructor(content, absPath) {
this.content = content;
this.absPath = absPath;
this.mapping = null;
}

@@ -11,0 +13,0 @@ position(_pos) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadFromMD = void 0;
exports.loadFromMD = loadFromMD;
const MDParser_1 = require("./MDParser");

@@ -51,3 +51,2 @@ const errorPrinter_1 = require("./errorPrinter");

}
exports.loadFromMD = loadFromMD;
//# sourceMappingURL=loadFromMD.js.map

@@ -5,7 +5,7 @@ /**

*/
export declare type Header = {
export type Header = {
type: 'header';
text: string | null;
};
export declare type FileBlock = {
export type FileBlock = {
type: 'file';

@@ -15,3 +15,3 @@ codeBlock: CodeBlock;

};
export declare type CodeBlock = {
export type CodeBlock = {
type: 'code';

@@ -21,3 +21,3 @@ language: string;

};
export declare type Title = {
export type Title = {
type: 'title';

@@ -27,7 +27,7 @@ level: number;

};
export declare type RawText = {
export type RawText = {
type: 'text';
text: string;
};
export declare type Content = Header | FileBlock | CodeBlock | Title | RawText;
export type Content = Header | FileBlock | CodeBlock | Title | RawText;
export declare function parseMD(document: string): Content[];

@@ -7,3 +7,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseMD = void 0;
exports.parseMD = parseMD;
let currentPosition = 0;

@@ -147,3 +147,2 @@ let lines = [];

}
exports.parseMD = parseMD;
//# sourceMappingURL=MDParser.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printNode = void 0;
exports.printNode = printNode;
const nodes_1 = require("../compiler/nodes");

@@ -258,3 +258,2 @@ const astPrinter_1 = require("./astPrinter");

}
exports.printNode = printNode;
//# sourceMappingURL=nodePrinter.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.printScopes = void 0;
exports.printScopes = printScopes;
const nodes_1 = require("../compiler/nodes");

@@ -15,3 +15,2 @@ function printScopes(parsingContext) {

}
exports.printScopes = printScopes;
//# sourceMappingURL=scopePrinter.js.map

@@ -5,7 +5,8 @@ "use strict";

class StringCodeWriter {
indentSpaces;
_indent = 0;
_content = '';
_newLineCallBacks = [];
constructor(indentSpaces = 2) {
this.indentSpaces = indentSpaces;
this._indent = 0;
this._content = '';
this._newLineCallBacks = [];
// stub

@@ -12,0 +13,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateTestInstance = void 0;
exports.generateTestInstance = generateTestInstance;
async function generateTestInstance(buffer, modules = []) {

@@ -18,3 +18,2 @@ let instance = null;

}
exports.generateTestInstance = generateTestInstance;
//# sourceMappingURL=testEnvironment.js.map
{
"name": "lys",
"version": "0.1.14-20250123143612.commit-4942aa9",
"version": "0.1.14-20250124144723.commit-2157e77",
"description": "",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"types": "dist/index.d.ts",
"bin": {

@@ -30,8 +31,8 @@ "lys": "dist/bin.js"

"dependencies": {
"@webassemblyjs/ast": "1.11.1",
"@webassemblyjs/wast-printer": "1.11.1",
"@webassemblyjs/ast": "^1.14.1",
"@webassemblyjs/wast-printer": "^1.14.1",
"arg": "^4.1.3",
"binaryen": "^100.0.0",
"binaryen": "^121.0.0",
"ebnf": "^1.9.0",
"wabt": "^1.0.30"
"wabt": "^1.0.36"
},

@@ -42,3 +43,3 @@ "devDependencies": {

"@types/mocha": "^10.0.0",
"@types/node": "^16.18.2",
"@types/node": "^22.10.9",
"@types/node-fetch": "^2.5.7",

@@ -54,4 +55,4 @@ "@types/semver": "^6.2.1",

"semver": "^6.3.0",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
"ts-node": "^10.9.2",
"typescript": "^5.7.3"
},

@@ -63,3 +64,3 @@ "files": [

],
"commit": "4942aa93f040486bd23606f283b621beb89f0645"
"commit": "2157e77771cd2722f466dbb98468450edd4891a2"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc