Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix references to old name #60

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ npm i -g voyd
# Run the exported main function
voyd --run script.voyd

# Compile a directory (containing an index.void) to webassembly
# Compile a directory (containing an index.voyd) to webassembly
voyd --emit-wasm src > output.wasm

# Compile to optimized WebAssembly
Expand Down Expand Up @@ -385,7 +385,7 @@ let double = n => n * 2
array.map n => n * 2
```

Void also supports a concise syntax for passing closures to labeled arguments:
Voyd also supports a concise syntax for passing closures to labeled arguments:

```rust
try do():
Expand Down
2 changes: 1 addition & 1 deletion docs/structural-subtyping.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() -> i32

```

Implementation (Psuedo VOID / WASM hybrid):
Implementation (Psuedo Voyd / WASM hybrid):
```voyd
// All objects implicitly extend Object
type Object = {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/compiler.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
e2eVoidText,
e2eVoydText,
kitchenSink,
goodTypeInferenceText,
tcoText,
Expand All @@ -13,7 +13,7 @@ import { readString } from "../lib/read-string.js";

describe("E2E Compiler Pipeline", () => {
test("Compiler can compile and run a basic voyd program", async (t) => {
const mod = await compile(e2eVoidText);
const mod = await compile(e2eVoydText);
const instance = getWasmInstance(mod);
const fn = getWasmFn("main", instance);
assert(fn, "Function exists");
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/fixtures/e2e-file.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const e2eVoidText = `
export const e2eVoydText = `
use std::all

fn fib(n: i32) -> i32
Expand Down
4 changes: 2 additions & 2 deletions src/assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { Variable } from "./syntax-objects/variable.js";
import { Block } from "./syntax-objects/block.js";
import { Declaration } from "./syntax-objects/declaration.js";
import { VoidModule } from "./syntax-objects/module.js";
import { VoydModule } from "./syntax-objects/module.js";
import { ObjectLiteral } from "./syntax-objects/object-literal.js";
import {
binaryenTypeToHeapType,
Expand Down Expand Up @@ -137,7 +137,7 @@ const compileType = (opts: CompileExprOpts<Type>) => {
return opts.mod.nop();
};

const compileModule = (opts: CompileExprOpts<VoidModule>) => {
const compileModule = (opts: CompileExprOpts<VoydModule>) => {
const result = opts.mod.block(
opts.expr.id,
opts.expr.value.map((expr) => compileExpression({ ...opts, expr }))
Expand Down
4 changes: 2 additions & 2 deletions src/lib/config/arg-parser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ParseArgsConfig, parseArgs } from "node:util";
import { VoidConfig } from "./types.js";
import { VoydConfig } from "./types.js";

const options: ParseArgsConfig["options"] = {
"emit-parser-ast": {
Expand Down Expand Up @@ -38,7 +38,7 @@ const options: ParseArgsConfig["options"] = {
},
};

export const getConfigFromCli = (): VoidConfig => {
export const getConfigFromCli = (): VoydConfig => {
const { values, positionals } = parseArgs({
options,
allowPositionals: true,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getConfigFromCli } from "./arg-parser.js";
import { VoidConfig } from "./types.js";
import { VoydConfig } from "./types.js";

let config: VoidConfig | undefined = undefined;
let config: VoydConfig | undefined = undefined;
export const getConfig = () => {
if (config) return config;
config = getConfigFromCli();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/config/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type VoidConfig = {
export type VoydConfig = {
/** Write raw parser AST to stdout */
emitParserAst?: boolean;
/** Write desurfaced AST to stdout */
Expand Down
4 changes: 2 additions & 2 deletions src/semantics/check-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Block,
Call,
Variable,
VoidModule,
VoydModule,
Parameter,
Use,
TypeAlias,
Expand Down Expand Up @@ -291,7 +291,7 @@ const checkParameters = (params: Parameter[]) => {
});
};

const checkModuleTypes = (mod: VoidModule): VoidModule => {
const checkModuleTypes = (mod: VoydModule): VoydModule => {
mod.each(checkTypes);
return mod;
};
Expand Down
12 changes: 6 additions & 6 deletions src/semantics/modules.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ParsedModule, stdPath } from "../parser/index.js";
import { List } from "../syntax-objects/list.js";
import { RootModule, VoidModule } from "../syntax-objects/module.js";
import { RootModule, VoydModule } from "../syntax-objects/module.js";

/** Registers submodules of a parsed module for future import resolution */
export const registerModules = (opts: ParsedModule): VoidModule => {
export const registerModules = (opts: ParsedModule): VoydModule => {
const { srcPath, files } = opts;

const rootModule = new RootModule({});
Expand Down Expand Up @@ -34,10 +34,10 @@ const registerModule = ({
isIndex,
}: {
path: string[];
parentModule: VoidModule;
parentModule: VoydModule;
ast: List;
isIndex?: boolean;
}): VoidModule | undefined => {
}): VoydModule | undefined => {
const [name, ...rest] = path;

if (!name) return;
Expand All @@ -61,7 +61,7 @@ const registerModule = ({

const module =
existingModule ??
new VoidModule({
new VoydModule({
...(!rest.length ? { ...ast.metadata, value: ast.toArray() } : {}),
name,
isIndex,
Expand Down Expand Up @@ -99,7 +99,7 @@ const filePathToModulePath = (filePath: string, srcPath: string) => {
return finalPath;
};

const registerDefaultImports = (module: VoidModule) => {
const registerDefaultImports = (module: VoydModule) => {
module.unshift(new List(["use", ["::", "root", "all"]]));
const mod = module.resolveModule("std");
if (mod) return;
Expand Down
6 changes: 3 additions & 3 deletions src/semantics/regular-macros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Macro,
RegularMacro,
MacroVariable,
VoidModule,
VoydModule,
Block,
Use,
nop,
Expand Down Expand Up @@ -45,7 +45,7 @@ export const expandRegularMacros = (expr: Expr): Expr => {
return expr.map(expandRegularMacros);
};

const expandModuleMacros = (module: VoidModule): VoidModule => {
const expandModuleMacros = (module: VoydModule): VoydModule => {
if (module.phase > 0) return module;
module.phase = 1;
module.applyMap(expandRegularMacros);
Expand All @@ -70,7 +70,7 @@ const initMod = (list: List) => {
if (list.length < 3) return list; // Maybe error here?
const name = list.identifierAt(1);
const block = list.listAt(2);
const module = new VoidModule({
const module = new VoydModule({
...list.metadata,
name,
value: block.argsArray().map(expandRegularMacros),
Expand Down
4 changes: 2 additions & 2 deletions src/semantics/resolution/resolve-entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Block } from "../../syntax-objects/block.js";
import { Expr } from "../../syntax-objects/expr.js";
import { nop } from "../../syntax-objects/helpers.js";
import { List } from "../../syntax-objects/list.js";
import { VoidModule } from "../../syntax-objects/module.js";
import { VoydModule } from "../../syntax-objects/module.js";
import { ObjectLiteral } from "../../syntax-objects/object-literal.js";
import {
ObjectType,
Expand Down Expand Up @@ -62,7 +62,7 @@ export const resolveVar = (variable: Variable): Variable => {
return variable;
};

export const resolveModule = (mod: VoidModule): VoidModule => {
export const resolveModule = (mod: VoydModule): VoydModule => {
if (mod.phase >= 3) return mod;
mod.phase = 3;
mod.each(resolveEntities);
Expand Down
6 changes: 3 additions & 3 deletions src/semantics/resolution/resolve-use.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Call } from "../../syntax-objects/call.js";
import { Expr } from "../../syntax-objects/expr.js";
import { List } from "../../syntax-objects/list.js";
import { VoidModule } from "../../syntax-objects/module.js";
import { VoydModule } from "../../syntax-objects/module.js";
import { NamedEntity } from "../../syntax-objects/named-entity.js";
import { Use, UseEntities } from "../../syntax-objects/use.js";
import { resolveModule, resolveEntities } from "./resolve-entities.js";

export type ModulePass = (mod: VoidModule) => VoidModule;
export type ModulePass = (mod: VoydModule) => VoydModule;

export const resolveUse = (use: Use, runPass?: ModulePass) => {
const path = use.path;
Expand Down Expand Up @@ -83,7 +83,7 @@ export const resolveModulePath = (
return entities.map((e) => ({ e }));
};

const resolveObjectPath = (path: Call | List, module: VoidModule) => {
const resolveObjectPath = (path: Call | List, module: VoydModule) => {
const entities: UseEntities = [];

const imports = path.argsArray();
Expand Down
4 changes: 2 additions & 2 deletions src/syntax-objects/expr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Macro } from "./macros.js";
import { MacroLambda } from "./macro-lambda.js";
import { Call } from "./call.js";
import { Block } from "./block.js";
import { VoidModule } from "./module.js";
import { VoydModule } from "./module.js";
import { Declaration } from "./declaration.js";
import { Use } from "./use.js";
import { ObjectLiteral } from "./object-literal.js";
Expand All @@ -34,7 +34,7 @@ export type Expr =
| Global
| MacroVariable
| MacroLambda
| VoidModule
| VoydModule
| Call
| Block
| Declaration
Expand Down
22 changes: 11 additions & 11 deletions src/syntax-objects/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
ScopedNamedEntityOpts,
} from "./named-entity.js";

export type VoidModuleOpts = ScopedNamedEntityOpts & {
export type VoydModuleOpts = ScopedNamedEntityOpts & {
value?: Expr[];
phase?: number;
isIndex?: boolean;
exports?: LexicalContext;
};

export class VoidModule extends ScopedNamedEntity {
export class VoydModule extends ScopedNamedEntity {
readonly syntaxType = "module";
readonly exports: LexicalContext;
readonly isRoot: boolean = false;
Expand All @@ -31,7 +31,7 @@ export class VoidModule extends ScopedNamedEntity {
*/
phase = 0;

constructor(opts: VoidModuleOpts) {
constructor(opts: VoydModuleOpts) {
super(opts);
if (opts.value) this.push(...opts.value);
this.exports = opts.exports ?? new LexicalContext();
Expand Down Expand Up @@ -68,13 +68,13 @@ export class VoidModule extends ScopedNamedEntity {
return [...path, this.name.toString()];
}

each(fn: (expr: Expr, index: number, array: Expr[]) => void): VoidModule {
each(fn: (expr: Expr, index: number, array: Expr[]) => void): VoydModule {
this.value.forEach(fn);
return this;
}

map(fn: (expr: Expr, index: number, array: Expr[]) => Expr): VoidModule {
return new VoidModule({
map(fn: (expr: Expr, index: number, array: Expr[]) => Expr): VoydModule {
return new VoydModule({
...super.getCloneOpts(),
value: this.value.map(fn),
phase: this.phase,
Expand All @@ -83,7 +83,7 @@ export class VoidModule extends ScopedNamedEntity {
});
}

applyMap(fn: (expr: Expr, index: number, array: Expr[]) => Expr): VoidModule {
applyMap(fn: (expr: Expr, index: number, array: Expr[]) => Expr): VoydModule {
const old = this.value;
this.value = [];
old.forEach((expr, index, arr) => this.push(fn(expr, index, arr)));
Expand All @@ -94,8 +94,8 @@ export class VoidModule extends ScopedNamedEntity {
return this.id;
}

clone(parent?: Expr | undefined): VoidModule {
return new VoidModule({
clone(parent?: Expr | undefined): VoydModule {
return new VoydModule({
...super.getCloneOpts(parent),
value: this.value.map((expr) => expr.clone()),
phase: this.phase,
Expand All @@ -122,10 +122,10 @@ export class VoidModule extends ScopedNamedEntity {
}
}

export class RootModule extends VoidModule {
export class RootModule extends VoydModule {
readonly isRoot = true;

constructor(opts: Omit<VoidModuleOpts, "name">) {
constructor(opts: Omit<VoydModuleOpts, "name">) {
super({ ...opts, name: "root" });
}
}
8 changes: 4 additions & 4 deletions src/syntax-objects/syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Fn } from "./fn.js";
import type { Global } from "./global.js";
import type { Id, Identifier } from "./identifier.js";
import type { Int } from "./int.js";
import type { VoidModule } from "./module.js";
import type { VoydModule } from "./module.js";
import { LexicalContext } from "./lib/lexical-context.js";
import type { List } from "./list.js";
import type { MacroLambda } from "./macro-lambda.js";
Expand Down Expand Up @@ -63,7 +63,7 @@ export abstract class Syntax {
return this.parent?.isFn() ? this.parent : this.parent?.parentFn;
}

get parentModule(): VoidModule | undefined {
get parentModule(): VoydModule | undefined {
return this.parent?.isModule() ? this.parent : this.parent?.parentModule;
}

Expand All @@ -90,7 +90,7 @@ export abstract class Syntax {
}

/** Will resolve a sibling module, or a direct ancestor */
resolveModule(name: Id, level = 0): VoidModule | undefined {
resolveModule(name: Id, level = 0): VoydModule | undefined {
if (!this.isModule()) {
return this.parentModule?.resolveModule(name, level);
}
Expand Down Expand Up @@ -253,7 +253,7 @@ export abstract class Syntax {
return this.syntaxType === "macro-lambda";
}

isModule(): this is VoidModule {
isModule(): this is VoydModule {
return this.syntaxType === "module";
}

Expand Down