Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
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
3 changes: 1 addition & 2 deletions as-pect.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ module.exports = {
* A set of globs passed to the glob package that qualify typescript files for testing.
*/
include: [
"packages/*/assembly/__tests__/**/*.spec.ts",
"packages/kernel/*/assembly/__tests/**/*.spec.ts"
"packages/*/assembly/__tests__/**/*.spec.ts"
],
/**
* A set of globs passed to the glob package that quality files to be added to each test.
Expand Down
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test:jest": "jest",
"test:as": "asp",
"test": "npm-run-all test:jest test:as",
"check": "tsc --noEmit",
"check": "tsc -p tsconfig.ts.json --noEmit",
"bootstrap": "lerna bootstrap && npm run linkDev",
"clean": "lerna clean -y",
"clean:soft": "lerna exec \"rm -rf node_modules/**/node_modules\" ",
Expand Down Expand Up @@ -49,7 +49,8 @@
"webpack": "^4.29.5",
"webpack-cli": "^3.2.3",
"webpack-dev-server": "^3.2.0",
"@wasmos/utils": "file:./utils"
"@wasmos/utils": "file:./utils",
"@types/assembly": "file:./types"
},
"dependencies": {
"@types/filesystem": "0.0.28",
Expand Down
6 changes: 1 addition & 5 deletions packages/as-node/assembly/bin/echo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@
// import { process } from "../process";

import { File } from "@wasmos/fs";
import { Console, CommandLine } from "@wasmos/wasa/wasa";

export const enum ExitStatus {
EXIT_FAILURE = -1,
EXIT_SUCCESS = 0
}

function _main(argv: String[]): ExitStatus {
function _main(argv: string[]): ExitStatus {
Console.log(argv.slice(1).join(" "));

return ExitStatus.EXIT_SUCCESS;
}

let commandLine = new CommandLine();
_main(commandLine.all());

let f = new File();
// log(process.uid)
// log(process);
Expand Down
3 changes: 0 additions & 3 deletions packages/as-node/assembly/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/as-node/src/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as path from "path";
export async function exec(filename: string, args?: string) {
let opts = Compiler.opts;
let name = path.basename(filename);
let wasmPath = path.join(opts.outDir, name, "index.wasm");
let wasmPath = path.join(opts.outDir!, name, "index.wasm");

if (!(await fs.pathExists(wasmPath))) {
await Compiler.compileOne(path.resolve(filename), { lib: false });
Expand Down
10 changes: 2 additions & 8 deletions packages/as-node/src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
{
"extends": "../node_modules/@wasmos/assemblyscript/tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"target": "es6"
}
}
"extends": "../../../tsconfig.ts.json"
}
3 changes: 0 additions & 3 deletions packages/as-node/tsconfig.json

This file was deleted.

1 change: 1 addition & 0 deletions packages/ash/assembly/__test__/echo.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import { Console } from "@wasmos/assemblyscript";
8 changes: 0 additions & 8 deletions packages/ash/assembly/arg-as/argas.d.ts

This file was deleted.

86 changes: 0 additions & 86 deletions packages/ash/assembly/arg-as/index.d.ts

This file was deleted.

100 changes: 51 additions & 49 deletions packages/ash/assembly/arg-as/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ enum ArgType {
type Value = i32;

class Argument<T> {
constructor(public value: T){}
constructor(public value: T) {}
}


class Option {
private _value: string | null = null;
constructor(public name: string,
public type: ArgType,
public desc: string,
public optional: bool) {}
constructor(
public name: string,
public type: ArgType,
public desc: string,
public optional: bool
) {}
/**
* Parsed options set the corresponding value.
*/
set value(val: string | null){
set value(val: string | null) {
this._value = val;
}

Expand All @@ -42,29 +43,26 @@ class Option {
}

parseInt(): i32 {
return parseI32(this.value!)
return parseI32(this.value!);
}

parseFloat(): i32 {
return parseFloat(this.value!)
return parseFloat(this.value!);
}

parseBool(): bool {
return this.value != null;
}


}


export class Argas {
desc: string;
options: Map<string, Option>;
optionNames: Array<string>;
input: Array<string>;
command: string;

constructor(desc: string){
constructor(desc: string) {
this.options = new Map<string, Option>();
this.input = new Array<string>();
this.optionNames = new Array<string>();
Expand All @@ -74,8 +72,13 @@ export class Argas {
/**
* Used to add available options to print and to parse
*/
addOption(name: string, type: ArgType, desc: string,
_shortName: string = "", optional: boolean = false): void {
addOption(
name: string,
type: ArgType,
desc: string,
_shortName: string = "",
optional: boolean = false
): void {
this.optionNames.push(name);
let shortName = _shortName ? _shortName : name.charAt(0);
let option = new Option(name, type, desc, optional);
Expand All @@ -87,43 +90,43 @@ export class Argas {
let argv: string[] = args.split(" ");
this.command = argv[0];
let i: i32 = 1;
while (i < argv.length){
if (argv[i].startsWith("-")){
if (argv[i].startsWith("--")){
let option = this.options.get(argv[i].substr(2));
if (option.type == ArgType.Flag){
option.value = "";
}else {
i++;
if (i == argv.length || argv[i].startsWith("--")){
abort("Missing argument after " + option.name)
}else{
let val: string = argv[i];
switch (option.type){
case ArgType.Int:
case ArgType.Float:
case ArgType.String: {
break;
}
default: {
abort("Argument Type does not exist");
}
}
option.value = val;
}
}
}else{
if (argv[i].length > 2){
for(let j = 1; j < argv[1].length; j++){
while (i < argv.length) {
if (argv[i].startsWith("-")) {
if (argv[i].startsWith("--")) {
let option = this.options.get(argv[i].substr(2));
if (option.type == ArgType.Flag) {
option.value = "";
} else {
i++;
if (i == argv.length || argv[i].startsWith("--")) {
abort("Missing argument after " + option.name);
} else {
let val: string = argv[i];
switch (option.type) {
case ArgType.Int:
case ArgType.Float:
case ArgType.String: {
break;
}
default: {
abort("Argument Type does not exist");
}
}
option.value = val;
}
}
} else {
if (argv[i].length > 2) {
for (let j = 1; j < argv[1].length; j++) {
let opt = this.options.get(argv[i].charAt(j));
if (opt.type != ArgType.Flag){
if (opt.type != ArgType.Flag) {
abort("can't combine flag options with non-flag options");
}
}
}
}
} else {
this.input.push(argv[i])
this.input.push(argv[i]);
}
i++;
}
Expand All @@ -132,18 +135,17 @@ export class Argas {
/**
* When --help or -h is passed print out the options.
*/
toString(): string{
toString(): string {
let descs = new Array<string>();
descs.push("");
descs.push("SYNTAX");
descs.push("\t" + this.desc);
descs.push("");
descs.push("OPTIONS");
for (let i = 0; i < this.optionNames.length; i++){
for (let i = 0; i < this.optionNames.length; i++) {
let option = this.options.get(this.optionNames[i]);
descs.push("\t--"+option.name + "\t\t" + option.desc);
descs.push("\t--" + option.name + "\t\t" + option.desc);
}
return descs.join("\n");
}

}
12 changes: 5 additions & 7 deletions packages/ash/assembly/bin/echo.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// import {_process, Process} from "../preamble";
import {IO, Console, Random, Date, Process, EnvironEntry, Environ, CommandLine, Filesystem} from "@wasmos/assemblyscript";

export const enum ExitStatus { EXIT_FAILURE=-1, EXIT_SUCCESS=0 }
export const enum ExitStatus {
EXIT_FAILURE = -1,
EXIT_SUCCESS = 0
}

function _main(argv: string[]): ExitStatus {
Console.log(argv.slice(1).join(" "))
Console.log(argv.slice(1).join(" "));
return ExitStatus.EXIT_SUCCESS;
}


// log(process.uid)
// log(process);
// log(process.argv[0]);
process.exitCode = _main(process.argv);
Loading