Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

一、概要设计

1、架构图 | architecture diagram

源文件

2、move编译器构建原理图

源文件

二、详细设计

1、move编译器接口

1.1 支持的命令

$mc support-cmds [OPTIONS]

命令选项:

选项

描述

--json

输出JSON格式

标准输出:

{
   "code": 0,
   "message": "success",
   "data": [
       "compile",
       "test",
       "package"
   ]
}

错误输出:

 

1.2 编译命令

$mc compile [OPTIONS] 

命令选项:

选项

描述

--json

输出JSON格式

--path

工程路径

标准输出:

{
   "code": 0,
   "message": "success"
}

错误输出:

{
   "code": 1,
   "message": "compile fail",
   "data": {
       "diagnostics": []
   }
}

1.3 测试命令

$mc test [OPTIONS] 

命令选项:

选项

描述

--json

输出JSON格式

--path

工程路径

--filter

需要测试的函数

标准输出:

{
   "code": 0,
   "message": "success",
   "data": {
       "test_cases": [],
   }
}

错误输出:

{
   "code": 1,
   "message": "compile fail",
   "data": {
       "diagnostics": []
   }
}

1.4 编译命令

$mc package [OPTIONS] 

命令选项:

选项

描述

--json

输出JSON格式

--path

工程路径

标准输出:

{
   "code": 0,
   "message": "success",
   "data": {
       "target_path": "",
   }
}

错误输出:

{
   "code": 1,
   "message": "compile fail",
   "data": {
       "diagnostics": []
   }
}

2、move-api

2.1 git.d.ts

import { WasmFs } from '@wasmer/wasmfs';

/**
 * Git interface
 */
export interface IGit {
    /**
     * Download code to dest path
     *
     * @param repoUrl
     * @param destPath
     */
    download(repoUrl: string, destPath: string): Promise<void>;
}

/**
 * Git
 *
 */
export declare class Git implements IGit {
    wasmfs?: WasmFs;
    constructor(wasmfs: WasmFs);
    download(zipURL: string, destPath: string): Promise<void>;
}

2.2 package.d.ts

import { WasmFs } from '@wasmer/wasmfs';

export interface IDependency {
    git?: string;
    rev?: string;
    local?: string;
}

export interface IMovePackage {
    name?: string;
    version?: string;
    addresses?: Map<string, string>;
    dependencies?: Map<string, IDependency>;
    devDependencies?: Map<string, IDependency>;
    build(): void;
}

export declare type MoveOptions = {
    packagePath: string;
    test: boolean;
    alias?: Map<string, string>;
    initFunction?: string;
};

export declare class MovePackage implements IMovePackage {
    name?: string;
    version?: string;
    addresses?: Map<string, string>;
    devDependencies?: Map<string, IDependency>;
    dependencies?: Map<string, IDependency>;
    private wasmfs;
    private packagePath;
    private packageAlias;
    private test;
    private initFunction?;
    constructor(wasmfs: WasmFs, opts: MoveOptions);
    parseToml(tomlContent: string): void;
    parseDeps(thisDeps: Map<string, IDependency>, tomlDeps: any): void;
    build(): Promise<void>;
    getAllDeps(): string[];
    collectDependencies(allDeps: string[], modules: Map<string, IDependency>): void;
    getAllAddresses(): Map<string, string>;
    collectAddresses(allAddresss: Map<string, string>, modules: Map<string, IDependency>): void;
    buildPackage(wasmfs: WasmFs, packagePath: string, deps: string[], addresses: Map<string, string>): Promise<void>;
}

3.3 disassemble.d.ts

import { WasmFs } from '@wasmer/wasmfs';

export interface IDisassemble {
    disassemble(name: string, bytecode: string, callback: (ok: boolean, data: string) => void): Promise<void>;
}

export declare class Disassemble implements IDisassemble {
    private wasmfs;
    constructor(wasmfs: WasmFs);
    disassemble(name: string, bytecode: string, callback: (ok: boolean, data: string) => void): Promise<void>;
}

  • No labels