From 28bc35a3e043b5f0b21802a7c2abbab4a601cccf Mon Sep 17 00:00:00 2001 From: Lance Pollard Date: Fri, 19 Jan 2024 01:20:59 -0800 Subject: [PATCH] save --- .php-cs-fixer.cache | 1 + Dockerfile | 16 + code/node/call/compile.ts | 44 ++ code/node/code.ts | 39 +- code/shared/code.ts | 59 +- code/shared/command.ts | 4 + code/shared/type/call/compile.ts | 16 +- code/shared/type/cast.ts | 252 +++++++- code/shared/type/source/code.ts | 799 +----------------------- code/shared/type/source/code/compile.ts | 231 +++++++ code/shared/type/source/code/data.ts | 547 ++++++++++++++++ code/shared/type/source/code/format.ts | 273 ++++++++ code/shared/type/source/code/index.ts | 3 + code/shared/type/source/index.ts | 1 + code/shared/type/take.ts | 17 + package.json | 1 + pnpm-lock.yaml | 15 + readme.md | 1 + test/cli.sh | 16 +- test/file/code/quicksort/quicksort.php | 22 + test/file/code/quicksort/quicksort.rs | 4 + 21 files changed, 1544 insertions(+), 817 deletions(-) create mode 100644 .php-cs-fixer.cache create mode 100644 code/shared/type/source/code/compile.ts create mode 100644 code/shared/type/source/code/data.ts create mode 100644 code/shared/type/source/code/format.ts create mode 100644 code/shared/type/source/code/index.ts diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache new file mode 100644 index 0000000..ec55d6c --- /dev/null +++ b/.php-cs-fixer.cache @@ -0,0 +1 @@ +{"php":"8.3.2","version":"3.47.1","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"attribute_placement":"ignore","on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true},"hashes":{"test\/file\/code\/quicksort\/quicksort.php":"4282e04e5e1112bf0dad02375c761f4a"}} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 3992d63..6cb56f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -193,3 +193,19 @@ RUN ln -s /home/python/venv/bin/antlr4-parse /usr/bin/antlr4-parse RUN /home/python/venv/bin/pip install patool RUN ln -s /home/python/venv/bin/patool /usr/bin/patool + +RUN apt-get install apt-transport-https +RUN wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/dart.gpg +RUN echo 'deb [signed-by=/usr/share/keyrings/dart.gpg arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main' | tee /etc/apt/sources.list.d/dart_stable.list +RUN apt-get update -y -q +RUN apt-get -y install dart + +RUN apt-get -y install php-cli +RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php +RUN HASH=`curl -sS https://composer.github.io/installer.sig` \ + && php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" +RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer + +RUN wget https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v3.13.0/php-cs-fixer.phar -O php-cs-fixer +RUN chmod a+x php-cs-fixer +RUN mv php-cs-fixer /usr/local/bin/php-cs-fixer diff --git a/code/node/call/compile.ts b/code/node/call/compile.ts index 352d404..e3e2c1a 100644 --- a/code/node/call/compile.ts +++ b/code/node/call/compile.ts @@ -4,7 +4,15 @@ import { } from '~/code/shared/type/call/compile' import { BuildFormatInputOutput, + CompileCModel, + CompileCppModel, + CompileJavaModel, + CompileRustModel, CompileSwiftModel, + compileC, + compileCpp, + compileJava, + compileRust, compileSwift, } from '..' import kink from '~/code/shared/kink' @@ -22,6 +30,42 @@ export async function compileInternal(source: BuildFormatInputOutput) { const input = CompileSwiftModel.parse(source) return await compileSwift(input) } + case 'rust': { + const input = CompileRustModel.parse(source) + return await compileRust(input) + } + case 'c': { + const input = CompileCModel.parse(source) + return await compileC(input) + } + case 'cpp': { + const input = CompileCppModel.parse(source) + return await compileCpp(input) + } + case 'cs': { + // const input = CompileJavaModel.parse(source) + // return await compileJava(input) + } + case 'java': { + const input = CompileJavaModel.parse(source) + return await compileJava(input) + } + case 'haskell': { + // const input = CompileJavaModel.parse(source) + // return await compileJava(input) + } + case 'go': { + // const input = CompileJavaModel.parse(source) + // return await compileJava(input) + } + case 'kotlin': { + // const input = CompileJavaModel.parse(source) + // return await compileJava(input) + } + case 'clojure': { + // const input = CompileJavaModel.parse(source) + // return await compileJava(input) + } } throw kink('task_not_implemented', { diff --git a/code/node/code.ts b/code/node/code.ts index 4e8400b..fc878aa 100644 --- a/code/node/code.ts +++ b/code/node/code.ts @@ -1,3 +1,4 @@ +import { stripAnsiFromText } from '../cli/logging.js' import { FormatRust, CompileLlvmIrToAssembly, @@ -12,8 +13,16 @@ import { CompileToAst, CompileSwift, buildCommandToCompileSwift, + buildCommandToCompileRust, + CompileRust, + CompileC, + CompileCpp, + CompileJava, } from '../shared/index.js' +import kink from '../shared/kink.js' import { handleCommand } from './command.js' +import { ChildProcessError } from './process.js' +import ansiToHtml from 'ansi-to-html' // import Parser from 'tree-sitter' // import JavaScript from 'tree-sitter-javascript' // import Swift from 'tree-sitter-swift' @@ -181,13 +190,37 @@ export async function compileKotlin(input: FormatKotlin) { // return await runFormatKotlinCommand(cmd) } +export async function compileC(input: CompileC) { + // return await runFormatKotlinCommand(cmd) +} + +export async function compileJava(input: CompileJava) { + // return await runFormatKotlinCommand(cmd) +} + +export async function compileCpp(input: CompileCpp) { + // return await runFormatKotlinCommand(cmd) +} + export async function compileSwift(input: CompileSwift) { const [cmd] = buildCommandToCompileSwift(input) handleCommand(cmd!) // return await runFormatSwiftCommand(cmd) } -export async function compileRust(input: FormatRust) { - const [cmd] = buildCommandToFormatRust(input) - return await handleCommand(cmd!) +export async function compileRust(input: CompileRust) { + const [cmd] = buildCommandToCompileRust(input) + try { + await handleCommand(cmd!) + } catch (e) { + if (e instanceof ChildProcessError) { + if (e.data.stderr) { + throw kink('compilation_error', { note: e.data.stderr }) + } else { + throw kink('compilation_error', { note: e.data.stdout ?? '' }) + } + } else if (e instanceof Error) { + throw kink('compilation_error', { note: e.message }) + } + } } diff --git a/code/shared/code.ts b/code/shared/code.ts index 6622fe9..ee4b385 100644 --- a/code/shared/code.ts +++ b/code/shared/code.ts @@ -3,6 +3,7 @@ import { CompileC, CompileCpp, CompileLlvmIrToAssembly, + CompileRust, CompileSwift, FormatAssembly, FormatCodeWithClangFormat, @@ -31,7 +32,7 @@ export function buildCommandToCompileSwift(input: CompileSwift) { if (input.output.format === 'assembly') { cmd.list.push(`-emit-assembly`) - } else if (input.output.format === 'llvm') { + } else if (input.output.format === 'llvm-ir') { cmd.list.push(`-emit-ir`) } @@ -63,6 +64,44 @@ export function buildCommandToFormatRust(input: FormatRust) { return [cmd] } +export function buildCommandToCompileRust(input: CompileRust) { + const cmd = getCommand('rustc') + + if (input.output.format === 'assembly') { + cmd.list.push(`--emit`, `asm`) + } else if (input.output.format === 'llvm-ir') { + cmd.list.push(`--emit`, 'llvm-ir') + } else if (input.output.format === 'llvm-bitcode') { + cmd.list.push(`--emit`, 'llvm-bc') + } else if (input.output.format === 'mir') { + cmd.list.push(`--emit`, 'mir') + } + + if (input.output.optimize) { + cmd.list.push('-O') + } + + if (input.explain) { + cmd.list.push('--explain') + } + + if (input.output.target) { + cmd.list.push('--target', input.output.target) + } + + // cmd.list.push(`--error-format`, `json`) + cmd.list.push(`--color`, `always`) + cmd.list.push(`--diagnostic-width`, String(92)) + + cmd.list.push( + `"${input.input.file.path}"`, + '-o', + `"${input.output.file.path}"`, + ) + + return [cmd] +} + export function buildCommandToFormatPython(input: FormatPython) { const cmd = getCommand('black') cmd.list.push(input.input.file.path) @@ -90,12 +129,18 @@ export async function buildCommandToCompileC(input: CompileC) { const cmd = getCommand(`clang`) cmd.list.push(`-O${input.optimizationLevel}`) - if (input.output.format === 'llvm') { + if (input.output.format === 'llvm-ir') { cmd.list.push(`-S`, `-emit-llvm`) + } else if (input.output.format === 'llvm-bitcode') { + cmd.list.push(`-c`, `-emit-llvm`) } else if (input.output.format === 'assembly') { cmd.list.push(`-S`) } + if (input.output.architecture) { + cmd.list.push(`-target`, input.output.architecture) + } + if (input.output.syntax && input.output.format === 'assembly') { cmd.list.push(`-masm`, `${input.output.syntax}`) } @@ -117,12 +162,18 @@ export async function buildCommandToCompileCpp(input: CompileCpp) { const cmd = getCommand(`clang++`) cmd.list.push(`-O${input.optimizationLevel}`) - if (input.output.format === 'llvm') { + if (input.output.format === 'llvm-ir') { cmd.list.push(`-S`, `-emit-llvm`) + } else if (input.output.format === 'llvm-bitcode') { + cmd.list.push(`-c`, `-emit-llvm`) } else if (input.output.format === 'assembly') { cmd.list.push(`-S`) } + if (input.output.architecture) { + cmd.list.push(`-target`, input.output.architecture) + } + if (input.output.syntax && input.output.format === 'assembly') { cmd.list.push(`-masm`, `${input.output.syntax}`) } @@ -142,7 +193,7 @@ export async function buildCommandToCompileCpp(input: CompileCpp) { // rubocop --autocorrect file.rb -export async function buildCommandToDecompileBinary() { +export async function buildCommandToDisassembleBinary() { const cmd = getCommand(`objdump`) cmd.list.push( `-S`, diff --git a/code/shared/command.ts b/code/shared/command.ts index 5a6c717..ba8c956 100644 --- a/code/shared/command.ts +++ b/code/shared/command.ts @@ -38,6 +38,7 @@ export const COMMAND_NAME = [ 'patool', 'identify', 'perltidy', + 'php-cs-fixer', ] as const export type CommandName = (typeof COMMAND_NAME)[number] @@ -77,6 +78,7 @@ export const COMMAND: Record | undefined> = { 'ebook-convert': ['ebook-convert'], soffice: ['soffice'], jupyter: ['jupyter'], + 'php-cs-fixer': ['php-cs-fixer'], docx2pdf: process.platform.match(/win32|darwin/) ? ['docx2pdf'] : undefined, @@ -102,3 +104,5 @@ export function setCommand( export type Command = { name: CommandName; list: CommandCall } export type CommandCall = Array export type CommandList = Array + +// php-cs-fixer fix test/file/code/quicksort/quicksort.php diff --git a/code/shared/type/call/compile.ts b/code/shared/type/call/compile.ts index 1c98b9f..b126e9b 100644 --- a/code/shared/type/call/compile.ts +++ b/code/shared/type/call/compile.ts @@ -1,15 +1,10 @@ import { - CompressMp4WithFfmpeg, - CompileDocumentWithCalibre, - CalibreInputFormat, - CalibreOutputFormat, - FfmpegFormat, - ImageMagickInputFormat, - ImageMagickOutputFormat, CompileSwift, CompileRust, CompileC, BackendCompilationOutput, + RustOutputFormat, + CompileCpp, } from '../cast' // // https://www.reddit.com/r/typescript/comments/199eutl/typescript_error_type_string_cannot_be_used_to/ @@ -21,7 +16,7 @@ export type CompileFormat = { } rust: { input: 'rust' - output: BackendCompilationOutput + output: RustOutputFormat extend: CompileRust } c: { @@ -29,6 +24,11 @@ export type CompileFormat = { output: BackendCompilationOutput extend: CompileC } + cpp: { + input: 'cpp' + output: BackendCompilationOutput + extend: CompileCpp + } } export type ExtractBySubKey< diff --git a/code/shared/type/cast.ts b/code/shared/type/cast.ts index a542b59..c3bd382 100644 --- a/code/shared/type/cast.ts +++ b/code/shared/type/cast.ts @@ -31,7 +31,8 @@ export type AssemblySyntax = (typeof ASSEMBLY_SYNTAX)[number] export const BACKEND_COMPILATION_OUTPUT = [ 'assembly', - 'llvm', + 'llvm-ir', + 'llvm-bitcode', 'binary', ] as const @@ -3401,6 +3402,7 @@ export type CompileC = { output: { format: BackendCompilationOutput syntax?: AssemblySyntax + architecture: LlvmArchitecture file: { path: string } @@ -3417,6 +3419,7 @@ export type CompileCpp = { } } output: { + architecture: LlvmArchitecture format: BackendCompilationOutput syntax?: AssemblySyntax file: { @@ -3468,6 +3471,15 @@ export type CompileRust = { path: string } } + explain?: boolean + output: { + format: RustOutputFormat + optimize?: boolean + target?: RustCompilerTarget + file: { + path: string + } + } } export type CompileSwift = { @@ -108106,6 +108118,244 @@ export type ResizeImageWithImageMagick = { gravity: ImageMagickGravity } +export const RUST_COMPILER_TARGET = [ + 'aarch64-apple-darwin', + 'aarch64-apple-ios', + 'aarch64-apple-ios-macabi', + 'aarch64-apple-ios-sim', + 'aarch64-apple-tvos', + 'aarch64-apple-tvos-sim', + 'aarch64-apple-watchos-sim', + 'aarch64-fuchsia', + 'aarch64-kmc-solid_asp3', + 'aarch64-linux-android', + 'aarch64-nintendo-switch-freestanding', + 'aarch64-pc-windows-gnullvm', + 'aarch64-pc-windows-msvc', + 'aarch64-unknown-freebsd', + 'aarch64-unknown-fuchsia', + 'aarch64-unknown-hermit', + 'aarch64-unknown-linux-gnu', + 'aarch64-unknown-linux-gnu_ilp32', + 'aarch64-unknown-linux-musl', + 'aarch64-unknown-linux-ohos', + 'aarch64-unknown-netbsd', + 'aarch64-unknown-none', + 'aarch64-unknown-none-softfloat', + 'aarch64-unknown-nto-qnx710', + 'aarch64-unknown-openbsd', + 'aarch64-unknown-redox', + 'aarch64-unknown-teeos', + 'aarch64-unknown-uefi', + 'aarch64-uwp-windows-msvc', + 'aarch64-wrs-vxworks', + 'aarch64_be-unknown-linux-gnu', + 'aarch64_be-unknown-linux-gnu_ilp32', + 'aarch64_be-unknown-netbsd', + 'arm-linux-androideabi', + 'arm-unknown-linux-gnueabi', + 'arm-unknown-linux-gnueabihf', + 'arm-unknown-linux-musleabi', + 'arm-unknown-linux-musleabihf', + 'arm64_32-apple-watchos', + 'armeb-unknown-linux-gnueabi', + 'armebv7r-none-eabi', + 'armebv7r-none-eabihf', + 'armv4t-none-eabi', + 'armv4t-unknown-linux-gnueabi', + 'armv5te-none-eabi', + 'armv5te-unknown-linux-gnueabi', + 'armv5te-unknown-linux-musleabi', + 'armv5te-unknown-linux-uclibceabi', + 'armv6-unknown-freebsd', + 'armv6-unknown-netbsd-eabihf', + 'armv6k-nintendo-3ds', + 'armv7-linux-androideabi', + 'armv7-sony-vita-newlibeabihf', + 'armv7-unknown-freebsd', + 'armv7-unknown-linux-gnueabi', + 'armv7-unknown-linux-gnueabihf', + 'armv7-unknown-linux-musleabi', + 'armv7-unknown-linux-musleabihf', + 'armv7-unknown-linux-ohos', + 'armv7-unknown-linux-uclibceabi', + 'armv7-unknown-linux-uclibceabihf', + 'armv7-unknown-netbsd-eabihf', + 'armv7-wrs-vxworks-eabihf', + 'armv7a-kmc-solid_asp3-eabi', + 'armv7a-kmc-solid_asp3-eabihf', + 'armv7a-none-eabi', + 'armv7a-none-eabihf', + 'armv7k-apple-watchos', + 'armv7r-none-eabi', + 'armv7r-none-eabihf', + 'armv7s-apple-ios', + 'asmjs-unknown-emscripten', + 'avr-unknown-gnu-atmega328', + 'bpfeb-unknown-none', + 'bpfel-unknown-none', + 'csky-unknown-linux-gnuabiv2', + 'csky-unknown-linux-gnuabiv2hf', + 'hexagon-unknown-linux-musl', + 'i386-apple-ios', + 'i586-pc-nto-qnx700', + 'i586-pc-windows-msvc', + 'i586-unknown-linux-gnu', + 'i586-unknown-linux-musl', + 'i586-unknown-netbsd', + 'i686-apple-darwin', + 'i686-linux-android', + 'i686-pc-windows-gnu', + 'i686-pc-windows-gnullvm', + 'i686-pc-windows-msvc', + 'i686-unknown-freebsd', + 'i686-unknown-haiku', + 'i686-unknown-hurd-gnu', + 'i686-unknown-linux-gnu', + 'i686-unknown-linux-musl', + 'i686-unknown-netbsd', + 'i686-unknown-openbsd', + 'i686-unknown-uefi', + 'i686-uwp-windows-gnu', + 'i686-uwp-windows-msvc', + 'i686-wrs-vxworks', + 'loongarch64-unknown-linux-gnu', + 'loongarch64-unknown-none', + 'loongarch64-unknown-none-softfloat', + 'm68k-unknown-linux-gnu', + 'mips-unknown-linux-gnu', + 'mips-unknown-linux-musl', + 'mips-unknown-linux-uclibc', + 'mips64-openwrt-linux-musl', + 'mips64-unknown-linux-gnuabi64', + 'mips64-unknown-linux-muslabi64', + 'mips64el-unknown-linux-gnuabi64', + 'mips64el-unknown-linux-muslabi64', + 'mipsel-sony-psp', + 'mipsel-sony-psx', + 'mipsel-unknown-linux-gnu', + 'mipsel-unknown-linux-musl', + 'mipsel-unknown-linux-uclibc', + 'mipsel-unknown-netbsd', + 'mipsel-unknown-none', + 'mipsisa32r6-unknown-linux-gnu', + 'mipsisa32r6el-unknown-linux-gnu', + 'mipsisa64r6-unknown-linux-gnuabi64', + 'mipsisa64r6el-unknown-linux-gnuabi64', + 'msp430-none-elf', + 'nvptx64-nvidia-cuda', + 'powerpc-unknown-freebsd', + 'powerpc-unknown-linux-gnu', + 'powerpc-unknown-linux-gnuspe', + 'powerpc-unknown-linux-musl', + 'powerpc-unknown-netbsd', + 'powerpc-unknown-openbsd', + 'powerpc-wrs-vxworks', + 'powerpc-wrs-vxworks-spe', + 'powerpc64-ibm-aix', + 'powerpc64-unknown-freebsd', + 'powerpc64-unknown-linux-gnu', + 'powerpc64-unknown-linux-musl', + 'powerpc64-unknown-openbsd', + 'powerpc64-wrs-vxworks', + 'powerpc64le-unknown-freebsd', + 'powerpc64le-unknown-linux-gnu', + 'powerpc64le-unknown-linux-musl', + 'riscv32gc-unknown-linux-gnu', + 'riscv32gc-unknown-linux-musl', + 'riscv32i-unknown-none-elf', + 'riscv32im-unknown-none-elf', + 'riscv32imac-esp-espidf', + 'riscv32imac-unknown-none-elf', + 'riscv32imac-unknown-xous-elf', + 'riscv32imc-esp-espidf', + 'riscv32imc-unknown-none-elf', + 'riscv64-linux-android', + 'riscv64gc-unknown-freebsd', + 'riscv64gc-unknown-fuchsia', + 'riscv64gc-unknown-hermit', + 'riscv64gc-unknown-linux-gnu', + 'riscv64gc-unknown-linux-musl', + 'riscv64gc-unknown-netbsd', + 'riscv64gc-unknown-none-elf', + 'riscv64gc-unknown-openbsd', + 'riscv64imac-unknown-none-elf', + 's390x-unknown-linux-gnu', + 's390x-unknown-linux-musl', + 'sparc-unknown-linux-gnu', + 'sparc-unknown-none-elf', + 'sparc64-unknown-linux-gnu', + 'sparc64-unknown-netbsd', + 'sparc64-unknown-openbsd', + 'sparcv9-sun-solaris', + 'thumbv4t-none-eabi', + 'thumbv5te-none-eabi', + 'thumbv6m-none-eabi', + 'thumbv7a-pc-windows-msvc', + 'thumbv7a-uwp-windows-msvc', + 'thumbv7em-none-eabi', + 'thumbv7em-none-eabihf', + 'thumbv7m-none-eabi', + 'thumbv7neon-linux-androideabi', + 'thumbv7neon-unknown-linux-gnueabihf', + 'thumbv7neon-unknown-linux-musleabihf', + 'thumbv8m.base-none-eabi', + 'thumbv8m.main-none-eabi', + 'thumbv8m.main-none-eabihf', + 'wasm32-unknown-emscripten', + 'wasm32-unknown-unknown', + 'wasm32-wasi', + 'wasm32-wasi-preview1-threads', + 'wasm64-unknown-unknown', + 'x86_64-apple-darwin', + 'x86_64-apple-ios', + 'x86_64-apple-ios-macabi', + 'x86_64-apple-tvos', + 'x86_64-apple-watchos-sim', + 'x86_64-fortanix-unknown-sgx', + 'x86_64-fuchsia', + 'x86_64-linux-android', + 'x86_64-pc-nto-qnx710', + 'x86_64-pc-solaris', + 'x86_64-pc-windows-gnu', + 'x86_64-pc-windows-gnullvm', + 'x86_64-pc-windows-msvc', + 'x86_64-sun-solaris', + 'x86_64-unikraft-linux-musl', + 'x86_64-unknown-dragonfly', + 'x86_64-unknown-freebsd', + 'x86_64-unknown-fuchsia', + 'x86_64-unknown-haiku', + 'x86_64-unknown-hermit', + 'x86_64-unknown-illumos', + 'x86_64-unknown-l4re-uclibc', + 'x86_64-unknown-linux-gnu', + 'x86_64-unknown-linux-gnux32', + 'x86_64-unknown-linux-musl', + 'x86_64-unknown-linux-ohos', + 'x86_64-unknown-netbsd', + 'x86_64-unknown-none', + 'x86_64-unknown-openbsd', + 'x86_64-unknown-redox', + 'x86_64-unknown-uefi', + 'x86_64-uwp-windows-gnu', + 'x86_64-uwp-windows-msvc', + 'x86_64-wrs-vxworks', + 'x86_64h-apple-darwin', +] as const + +export type RustCompilerTarget = (typeof RUST_COMPILER_TARGET)[number] + +export const RUST_OUTPUT_FORMAT = [ + 'binary', + 'assembly', + 'llvm-ir', + 'llvm-bitcode', + 'mir', +] as const + +export type RustOutputFormat = (typeof RUST_OUTPUT_FORMAT)[number] + export type SanitizeHtmlFromContent = { input: { format: string diff --git a/code/shared/type/source/code.ts b/code/shared/type/source/code.ts index ab561c3..799b823 100644 --- a/code/shared/type/source/code.ts +++ b/code/shared/type/source/code.ts @@ -3,42 +3,7 @@ import STYLE_JAVA from './data/style.java.type.json' assert { type: 'json' } import STYLE_JAVASCRIPT from './data/style.javascript.type.json' assert { type: 'json' } import STYLE_OBJC from './data/style.objc.type.json' assert { type: 'json' } import STYLE_ALL from './data/style.all.type.json' assert { type: 'json' } -import LLVM_ARCHITECTURE_CONTENT from './data/llvm.architecture.json' assert { type: 'json' } -import LLVM_CPU_CONTENT from './data/llvm.cpu.json' assert { type: 'json' } -import LLVM_CPU from './data/llvm.cpu.key.json' assert { type: 'json' } -import LLVM_FEATURE_CONTENT from './data/llvm.feature.json' assert { type: 'json' } -import LLVM_FEATURE from './data/llvm.feature.key.json' assert { type: 'json' } -import { Form, Hash, List } from '@termsurf/form' - -export const llvm_cpu: List = { - form: 'list', - list: LLVM_CPU, -} - -export const llvm_cpu_content: Hash = { - form: 'hash', - link: 'llvm_cpu', - bond: { - host: { like: 'string' }, - note: { like: 'string' }, - }, - hash: LLVM_CPU_CONTENT, -} - -export const llvm_feature: List = { - form: 'list', - list: LLVM_FEATURE, -} - -export const llvm_feature_content: Hash = { - form: 'hash', - link: 'llvm_feature', - bond: { - host: { like: 'string' }, - note: { like: 'string' }, - }, - hash: LLVM_FEATURE_CONTENT, -} +import { Form } from '@termsurf/form' export const clang_style_all: Form = { form: 'form', @@ -73,765 +38,3 @@ export const clang_style_objc: Form = { base: 'clang_style_all', link: STYLE_OBJC, } - -export const llvm_architecture: List = { - form: 'list', - list: [ - 'aarch64', - 'aarch64_32', - 'aarch64_be', - 'amdgcn', - 'arm', - 'arm64', - 'arm64_32', - 'armeb', - 'avr', - 'bpf', - 'bpfeb', - 'bpfel', - 'hexagon', - 'lanai', - 'mips', - 'mips64', - 'mips64el', - 'mipsel', - 'msp430', - 'nvptx', - 'nvptx64', - 'ppc32', - 'ppc64', - 'ppc64le', - 'r600', - 'riscv32', - 'riscv64', - 'sparc', - 'sparcel', - 'sparcv9', - 'systemz', - 'thumb', - 'thumbeb', - 'wasm32', - 'wasm64', - 'x86', - 'x86_64', - 'xcore', - ], -} - -export const llvm_optimization_level: List = { - form: 'list', - list: ['0', '1', '2', '3'], -} - -export const llvm_architecture_content: Hash = { - form: 'hash', - link: 'llvm_architecture', - bond: { - host: { like: 'string' }, - note: { like: 'string' }, - cpu: { like: 'string', list: true }, - feature: { like: 'string', list: true }, - }, - hash: { - aarch64: { - ...LLVM_ARCHITECTURE_CONTENT.aarch_64, - host: 'aarch64', - note: 'AArch64 (little endian)', - }, - aarch64_32: { - ...LLVM_ARCHITECTURE_CONTENT.aarch_64_32, - host: 'aarch64_32', - note: 'AArch64 (little endian ILP32)', - }, - aarch64_be: { - ...LLVM_ARCHITECTURE_CONTENT.aarch_64_be, - host: 'aarch64_be', - note: 'AArch64 (big endian)', - }, - amdgcn: { - ...LLVM_ARCHITECTURE_CONTENT.amdgcn, - host: 'amdgcn', - note: 'AMD GCN GPUs', - }, - arm: { - ...LLVM_ARCHITECTURE_CONTENT.arm, - host: 'arm', - note: 'ARM', - }, - arm64: { - ...LLVM_ARCHITECTURE_CONTENT.arm_64, - host: 'arm64', - note: 'ARM64 (little endian)', - }, - arm64_32: { - ...LLVM_ARCHITECTURE_CONTENT.arm_64_32, - host: 'arm64_32', - note: 'ARM64 (little endian ILP32)', - }, - armeb: { - ...LLVM_ARCHITECTURE_CONTENT.armeb, - host: 'armeb', - note: 'ARM (big endian)', - }, - avr: { - ...LLVM_ARCHITECTURE_CONTENT.avr, - host: 'avr', - note: 'Atmel AVR Microcontroller', - }, - bpf: { - ...LLVM_ARCHITECTURE_CONTENT.bpf, - host: 'bpf', - note: 'BPF (host endian)', - }, - bpfeb: { - ...LLVM_ARCHITECTURE_CONTENT.bpfeb, - host: 'bpfeb', - note: 'BPF (big endian)', - }, - bpfel: { - ...LLVM_ARCHITECTURE_CONTENT.bpfel, - host: 'bpfel', - note: 'BPF (little endian)', - }, - hexagon: { - ...LLVM_ARCHITECTURE_CONTENT.hexagon, - host: 'hexagon', - note: 'Hexagon', - }, - lanai: { - ...LLVM_ARCHITECTURE_CONTENT.lanai, - host: 'lanai', - note: 'Lanai', - }, - mips: { - ...LLVM_ARCHITECTURE_CONTENT.mips, - host: 'mips', - note: 'MIPS (32-bit big endian)', - }, - mips64: { - ...LLVM_ARCHITECTURE_CONTENT.mips_64, - host: 'mips64', - note: 'MIPS (64-bit big endian)', - }, - mips64el: { - ...LLVM_ARCHITECTURE_CONTENT.mips_64_el, - host: 'mips64el', - note: 'MIPS (64-bit little endian)', - }, - mipsel: { - ...LLVM_ARCHITECTURE_CONTENT.mipsel, - host: 'mipsel', - note: 'MIPS (32-bit little endian)', - }, - msp430: { - ...LLVM_ARCHITECTURE_CONTENT.msp_430, - host: 'msp430', - note: 'MSP430 [experimental]', - }, - nvptx: { - ...LLVM_ARCHITECTURE_CONTENT.nvptx, - host: 'nvptx', - note: 'NVIDIA PTX 32-bit', - }, - nvptx64: { - ...LLVM_ARCHITECTURE_CONTENT.nvptx_64, - host: 'nvptx64', - note: 'NVIDIA PTX 64-bit', - }, - ppc32: { - ...LLVM_ARCHITECTURE_CONTENT.ppc_32, - host: 'ppc32', - note: 'PowerPC 32', - }, - ppc64: { - ...LLVM_ARCHITECTURE_CONTENT.ppc_64, - host: 'ppc64', - note: 'PowerPC 64', - }, - ppc64le: { - ...LLVM_ARCHITECTURE_CONTENT.ppc_64_le, - host: 'ppc64le', - note: 'PowerPC 64 LE', - }, - r600: { - ...LLVM_ARCHITECTURE_CONTENT.r_600, - host: 'r600', - note: 'AMD GPUs HD2XXX-HD6XXX', - }, - riscv32: { - ...LLVM_ARCHITECTURE_CONTENT.riscv_32, - host: 'riscv32', - note: '32-bit RISC-V', - }, - riscv64: { - ...LLVM_ARCHITECTURE_CONTENT.riscv_64, - host: 'riscv64', - note: '64-bit RISC-V', - }, - sparc: { - ...LLVM_ARCHITECTURE_CONTENT.sparc, - host: 'sparc', - note: 'Sparc', - }, - sparcel: { - ...LLVM_ARCHITECTURE_CONTENT.sparcel, - host: 'sparcel', - note: 'Sparc LE', - }, - sparcv9: { - ...LLVM_ARCHITECTURE_CONTENT.sparcv_9, - host: 'sparcv9', - note: 'Sparc V9', - }, - systemz: { - ...LLVM_ARCHITECTURE_CONTENT.systemz, - host: 'systemz', - note: 'SystemZ', - }, - thumb: { - ...LLVM_ARCHITECTURE_CONTENT.thumb, - host: 'thumb', - note: 'Thumb', - }, - thumbeb: { - ...LLVM_ARCHITECTURE_CONTENT.thumbeb, - host: 'thumbeb', - note: 'Thumb (big endian)', - }, - wasm32: { - ...LLVM_ARCHITECTURE_CONTENT.wasm_32, - host: 'wasm32', - note: 'WebAssembly 32-bit', - }, - wasm64: { - ...LLVM_ARCHITECTURE_CONTENT.wasm_64, - host: 'wasm64', - note: 'WebAssembly 64-bit', - }, - x86: { - ...LLVM_ARCHITECTURE_CONTENT.x_86, - host: 'x86', - note: '32-bit X86: Pentium-Pro and above', - }, - x86_64: { - ...LLVM_ARCHITECTURE_CONTENT.x_86_64, - host: 'x86-64', - note: '64-bit X86: EM64T and AMD64', - }, - xcore: { - ...LLVM_ARCHITECTURE_CONTENT.xcore, - host: 'xcore', - note: 'XCore', - }, - }, -} - -export const backend_compilation_output: List = { - form: 'list', - list: ['assembly', 'llvm', 'binary'], -} - -export const backend_compilation_output_content: Hash = { - form: 'hash', - link: 'backend_compilation_output', - bond: { - extension: { like: 'string', need: false }, - }, - hash: { - assembly: { extension: 'asm' }, - llvm: { extension: 'll' }, - binary: {}, - }, -} - -export const compile_swift: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - format: { like: 'backend_compilation_output' }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const assembly_syntax: List = { - form: 'list', - list: ['intel', 'att'], -} - -export const compile_c: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - format: { like: 'backend_compilation_output' }, - syntax: { like: 'assembly_syntax', need: false }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - optimizationLevel: { - like: 'llvm_optimization_level', - fall: '0', - need: false, - }, - fastMath: { like: 'boolean', fall: false, need: false }, - }, -} - -export const compile_cpp: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - format: { like: 'backend_compilation_output' }, - syntax: { like: 'assembly_syntax', need: false }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - optimizationLevel: { - like: 'llvm_optimization_level', - fall: '0', - need: false, - }, - fastMath: { like: 'boolean', fall: false, need: false }, - }, -} - -export const format_kotlin: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const format_swift: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const format_rust: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const format_python: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const format_ruby: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const format_assembly: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const format_c: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const format_cpp: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const format_java: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const format_code_with_clang_format: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - style: { - like: 'clang_style_all', - need: false, - }, - }, -} - -export const compile_llvm_ir_to_assembly: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - output: { - link: { - syntax: { like: 'assembly_syntax', fall: 'intel' }, - architecture: { like: 'llvm_architecture', fall: 'x86_64' }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const compile_to_ast: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const format_sql_with_content: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string', name: { mark: 'I' } }, - file: { - link: { - content: { - case: [{ like: 'ArrayBuffer' }, { like: 'string' }], - }, - }, - }, - }, - }, - }, -} - -export const compile_java: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string' }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const compile_rust: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string' }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const compile_wast: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string' }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const compile_llvm: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string' }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} - -export const compile_asm: Form = { - form: 'form', - link: { - input: { - link: { - format: { like: 'string' }, - file: { - link: { - path: { like: 'string' }, - }, - }, - }, - }, - }, -} diff --git a/code/shared/type/source/code/compile.ts b/code/shared/type/source/code/compile.ts new file mode 100644 index 0000000..0f6dbe0 --- /dev/null +++ b/code/shared/type/source/code/compile.ts @@ -0,0 +1,231 @@ +import { Form } from '@termsurf/form' + +export const compile_swift: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + format: { like: 'backend_compilation_output' }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const compile_c: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + format: { like: 'backend_compilation_output' }, + syntax: { like: 'assembly_syntax', need: false }, + architecture: { like: 'llvm_architecture' }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + optimizationLevel: { + like: 'llvm_optimization_level', + fall: '0', + need: false, + }, + fastMath: { like: 'boolean', fall: false, need: false }, + }, +} + +export const compile_cpp: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + architecture: { like: 'llvm_architecture' }, + format: { like: 'backend_compilation_output' }, + syntax: { like: 'assembly_syntax', need: false }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + optimizationLevel: { + like: 'llvm_optimization_level', + fall: '0', + need: false, + }, + fastMath: { like: 'boolean', fall: false, need: false }, + }, +} + +export const compile_llvm_ir_to_assembly: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + syntax: { like: 'assembly_syntax', fall: 'intel' }, + architecture: { like: 'llvm_architecture', fall: 'x86_64' }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const compile_to_ast: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const compile_java: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string' }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const compile_rust: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string', name: { mark: 'i' } }, + }, + }, + }, + }, + explain: { like: 'boolean', fall: false, need: false }, + output: { + link: { + format: { like: 'rust_output_format', name: { mark: 'O' } }, + optimize: { like: 'boolean', fall: false, need: false }, + target: { like: 'rust_compiler_target', need: false }, + file: { + link: { + path: { like: 'string', name: { mark: 'o' } }, + }, + }, + }, + }, + }, +} + +export const compile_wast: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string' }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const compile_llvm: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string' }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const compile_asm: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string' }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} diff --git a/code/shared/type/source/code/data.ts b/code/shared/type/source/code/data.ts new file mode 100644 index 0000000..78a5ad1 --- /dev/null +++ b/code/shared/type/source/code/data.ts @@ -0,0 +1,547 @@ +import { Hash, List } from '@termsurf/form' +import LLVM_ARCHITECTURE_CONTENT from '../data/llvm.architecture.json' assert { type: 'json' } +import LLVM_CPU_CONTENT from '../data/llvm.cpu.json' assert { type: 'json' } +import LLVM_CPU from '../data/llvm.cpu.key.json' assert { type: 'json' } +import LLVM_FEATURE_CONTENT from '../data/llvm.feature.json' assert { type: 'json' } +import LLVM_FEATURE from '../data/llvm.feature.key.json' assert { type: 'json' } + +export const llvm_cpu: List = { + form: 'list', + list: LLVM_CPU, +} + +export const llvm_cpu_content: Hash = { + form: 'hash', + link: 'llvm_cpu', + bond: { + host: { like: 'string' }, + note: { like: 'string' }, + }, + hash: LLVM_CPU_CONTENT, +} + +export const llvm_feature: List = { + form: 'list', + list: LLVM_FEATURE, +} + +export const llvm_feature_content: Hash = { + form: 'hash', + link: 'llvm_feature', + bond: { + host: { like: 'string' }, + note: { like: 'string' }, + }, + hash: LLVM_FEATURE_CONTENT, +} + +export const llvm_architecture: List = { + form: 'list', + list: [ + 'aarch64', + 'aarch64_32', + 'aarch64_be', + 'amdgcn', + 'arm', + 'arm64', + 'arm64_32', + 'armeb', + 'avr', + 'bpf', + 'bpfeb', + 'bpfel', + 'hexagon', + 'lanai', + 'mips', + 'mips64', + 'mips64el', + 'mipsel', + 'msp430', + 'nvptx', + 'nvptx64', + 'ppc32', + 'ppc64', + 'ppc64le', + 'r600', + 'riscv32', + 'riscv64', + 'sparc', + 'sparcel', + 'sparcv9', + 'systemz', + 'thumb', + 'thumbeb', + 'wasm32', + 'wasm64', + 'x86', + 'x86_64', + 'xcore', + ], +} + +export const llvm_optimization_level: List = { + form: 'list', + list: ['0', '1', '2', '3'], +} + +export const llvm_architecture_content: Hash = { + form: 'hash', + link: 'llvm_architecture', + bond: { + host: { like: 'string' }, + note: { like: 'string' }, + cpu: { like: 'string', list: true }, + feature: { like: 'string', list: true }, + }, + hash: { + aarch64: { + ...LLVM_ARCHITECTURE_CONTENT.aarch_64, + host: 'aarch64', + note: 'AArch64 (little endian)', + }, + aarch64_32: { + ...LLVM_ARCHITECTURE_CONTENT.aarch_64_32, + host: 'aarch64_32', + note: 'AArch64 (little endian ILP32)', + }, + aarch64_be: { + ...LLVM_ARCHITECTURE_CONTENT.aarch_64_be, + host: 'aarch64_be', + note: 'AArch64 (big endian)', + }, + amdgcn: { + ...LLVM_ARCHITECTURE_CONTENT.amdgcn, + host: 'amdgcn', + note: 'AMD GCN GPUs', + }, + arm: { + ...LLVM_ARCHITECTURE_CONTENT.arm, + host: 'arm', + note: 'ARM', + }, + arm64: { + ...LLVM_ARCHITECTURE_CONTENT.arm_64, + host: 'arm64', + note: 'ARM64 (little endian)', + }, + arm64_32: { + ...LLVM_ARCHITECTURE_CONTENT.arm_64_32, + host: 'arm64_32', + note: 'ARM64 (little endian ILP32)', + }, + armeb: { + ...LLVM_ARCHITECTURE_CONTENT.armeb, + host: 'armeb', + note: 'ARM (big endian)', + }, + avr: { + ...LLVM_ARCHITECTURE_CONTENT.avr, + host: 'avr', + note: 'Atmel AVR Microcontroller', + }, + bpf: { + ...LLVM_ARCHITECTURE_CONTENT.bpf, + host: 'bpf', + note: 'BPF (host endian)', + }, + bpfeb: { + ...LLVM_ARCHITECTURE_CONTENT.bpfeb, + host: 'bpfeb', + note: 'BPF (big endian)', + }, + bpfel: { + ...LLVM_ARCHITECTURE_CONTENT.bpfel, + host: 'bpfel', + note: 'BPF (little endian)', + }, + hexagon: { + ...LLVM_ARCHITECTURE_CONTENT.hexagon, + host: 'hexagon', + note: 'Hexagon', + }, + lanai: { + ...LLVM_ARCHITECTURE_CONTENT.lanai, + host: 'lanai', + note: 'Lanai', + }, + mips: { + ...LLVM_ARCHITECTURE_CONTENT.mips, + host: 'mips', + note: 'MIPS (32-bit big endian)', + }, + mips64: { + ...LLVM_ARCHITECTURE_CONTENT.mips_64, + host: 'mips64', + note: 'MIPS (64-bit big endian)', + }, + mips64el: { + ...LLVM_ARCHITECTURE_CONTENT.mips_64_el, + host: 'mips64el', + note: 'MIPS (64-bit little endian)', + }, + mipsel: { + ...LLVM_ARCHITECTURE_CONTENT.mipsel, + host: 'mipsel', + note: 'MIPS (32-bit little endian)', + }, + msp430: { + ...LLVM_ARCHITECTURE_CONTENT.msp_430, + host: 'msp430', + note: 'MSP430 [experimental]', + }, + nvptx: { + ...LLVM_ARCHITECTURE_CONTENT.nvptx, + host: 'nvptx', + note: 'NVIDIA PTX 32-bit', + }, + nvptx64: { + ...LLVM_ARCHITECTURE_CONTENT.nvptx_64, + host: 'nvptx64', + note: 'NVIDIA PTX 64-bit', + }, + ppc32: { + ...LLVM_ARCHITECTURE_CONTENT.ppc_32, + host: 'ppc32', + note: 'PowerPC 32', + }, + ppc64: { + ...LLVM_ARCHITECTURE_CONTENT.ppc_64, + host: 'ppc64', + note: 'PowerPC 64', + }, + ppc64le: { + ...LLVM_ARCHITECTURE_CONTENT.ppc_64_le, + host: 'ppc64le', + note: 'PowerPC 64 LE', + }, + r600: { + ...LLVM_ARCHITECTURE_CONTENT.r_600, + host: 'r600', + note: 'AMD GPUs HD2XXX-HD6XXX', + }, + riscv32: { + ...LLVM_ARCHITECTURE_CONTENT.riscv_32, + host: 'riscv32', + note: '32-bit RISC-V', + }, + riscv64: { + ...LLVM_ARCHITECTURE_CONTENT.riscv_64, + host: 'riscv64', + note: '64-bit RISC-V', + }, + sparc: { + ...LLVM_ARCHITECTURE_CONTENT.sparc, + host: 'sparc', + note: 'Sparc', + }, + sparcel: { + ...LLVM_ARCHITECTURE_CONTENT.sparcel, + host: 'sparcel', + note: 'Sparc LE', + }, + sparcv9: { + ...LLVM_ARCHITECTURE_CONTENT.sparcv_9, + host: 'sparcv9', + note: 'Sparc V9', + }, + systemz: { + ...LLVM_ARCHITECTURE_CONTENT.systemz, + host: 'systemz', + note: 'SystemZ', + }, + thumb: { + ...LLVM_ARCHITECTURE_CONTENT.thumb, + host: 'thumb', + note: 'Thumb', + }, + thumbeb: { + ...LLVM_ARCHITECTURE_CONTENT.thumbeb, + host: 'thumbeb', + note: 'Thumb (big endian)', + }, + wasm32: { + ...LLVM_ARCHITECTURE_CONTENT.wasm_32, + host: 'wasm32', + note: 'WebAssembly 32-bit', + }, + wasm64: { + ...LLVM_ARCHITECTURE_CONTENT.wasm_64, + host: 'wasm64', + note: 'WebAssembly 64-bit', + }, + x86: { + ...LLVM_ARCHITECTURE_CONTENT.x_86, + host: 'x86', + note: '32-bit X86: Pentium-Pro and above', + }, + x86_64: { + ...LLVM_ARCHITECTURE_CONTENT.x_86_64, + host: 'x86-64', + note: '64-bit X86: EM64T and AMD64', + }, + xcore: { + ...LLVM_ARCHITECTURE_CONTENT.xcore, + host: 'xcore', + note: 'XCore', + }, + }, +} + +export const backend_compilation_output: List = { + form: 'list', + list: ['assembly', 'llvm-ir', 'llvm-bitcode', 'binary'], +} + +export const backend_compilation_output_content: Hash = { + form: 'hash', + link: 'backend_compilation_output', + bond: { + extension: { like: 'string', need: false }, + }, + hash: { + assembly: { extension: 'asm' }, + llvm: { extension: 'll' }, + binary: {}, + }, +} + +export const assembly_syntax: List = { + form: 'list', + list: ['intel', 'att'], +} + +export const rust_output_format: List = { + form: 'list', + list: ['binary', 'assembly', 'llvm-ir', 'llvm-bitcode', 'mir'], +} + +export const rust_compiler_target: List = { + form: 'list', + list: [ + 'aarch64-apple-darwin', + 'aarch64-apple-ios', + 'aarch64-apple-ios-macabi', + 'aarch64-apple-ios-sim', + 'aarch64-apple-tvos', + 'aarch64-apple-tvos-sim', + 'aarch64-apple-watchos-sim', + 'aarch64-fuchsia', + 'aarch64-kmc-solid_asp3', + 'aarch64-linux-android', + 'aarch64-nintendo-switch-freestanding', + 'aarch64-pc-windows-gnullvm', + 'aarch64-pc-windows-msvc', + 'aarch64-unknown-freebsd', + 'aarch64-unknown-fuchsia', + 'aarch64-unknown-hermit', + 'aarch64-unknown-linux-gnu', + 'aarch64-unknown-linux-gnu_ilp32', + 'aarch64-unknown-linux-musl', + 'aarch64-unknown-linux-ohos', + 'aarch64-unknown-netbsd', + 'aarch64-unknown-none', + 'aarch64-unknown-none-softfloat', + 'aarch64-unknown-nto-qnx710', + 'aarch64-unknown-openbsd', + 'aarch64-unknown-redox', + 'aarch64-unknown-teeos', + 'aarch64-unknown-uefi', + 'aarch64-uwp-windows-msvc', + 'aarch64-wrs-vxworks', + 'aarch64_be-unknown-linux-gnu', + 'aarch64_be-unknown-linux-gnu_ilp32', + 'aarch64_be-unknown-netbsd', + 'arm-linux-androideabi', + 'arm-unknown-linux-gnueabi', + 'arm-unknown-linux-gnueabihf', + 'arm-unknown-linux-musleabi', + 'arm-unknown-linux-musleabihf', + 'arm64_32-apple-watchos', + 'armeb-unknown-linux-gnueabi', + 'armebv7r-none-eabi', + 'armebv7r-none-eabihf', + 'armv4t-none-eabi', + 'armv4t-unknown-linux-gnueabi', + 'armv5te-none-eabi', + 'armv5te-unknown-linux-gnueabi', + 'armv5te-unknown-linux-musleabi', + 'armv5te-unknown-linux-uclibceabi', + 'armv6-unknown-freebsd', + 'armv6-unknown-netbsd-eabihf', + 'armv6k-nintendo-3ds', + 'armv7-linux-androideabi', + 'armv7-sony-vita-newlibeabihf', + 'armv7-unknown-freebsd', + 'armv7-unknown-linux-gnueabi', + 'armv7-unknown-linux-gnueabihf', + 'armv7-unknown-linux-musleabi', + 'armv7-unknown-linux-musleabihf', + 'armv7-unknown-linux-ohos', + 'armv7-unknown-linux-uclibceabi', + 'armv7-unknown-linux-uclibceabihf', + 'armv7-unknown-netbsd-eabihf', + 'armv7-wrs-vxworks-eabihf', + 'armv7a-kmc-solid_asp3-eabi', + 'armv7a-kmc-solid_asp3-eabihf', + 'armv7a-none-eabi', + 'armv7a-none-eabihf', + 'armv7k-apple-watchos', + 'armv7r-none-eabi', + 'armv7r-none-eabihf', + 'armv7s-apple-ios', + 'asmjs-unknown-emscripten', + 'avr-unknown-gnu-atmega328', + 'bpfeb-unknown-none', + 'bpfel-unknown-none', + 'csky-unknown-linux-gnuabiv2', + 'csky-unknown-linux-gnuabiv2hf', + 'hexagon-unknown-linux-musl', + 'i386-apple-ios', + 'i586-pc-nto-qnx700', + 'i586-pc-windows-msvc', + 'i586-unknown-linux-gnu', + 'i586-unknown-linux-musl', + 'i586-unknown-netbsd', + 'i686-apple-darwin', + 'i686-linux-android', + 'i686-pc-windows-gnu', + 'i686-pc-windows-gnullvm', + 'i686-pc-windows-msvc', + 'i686-unknown-freebsd', + 'i686-unknown-haiku', + 'i686-unknown-hurd-gnu', + 'i686-unknown-linux-gnu', + 'i686-unknown-linux-musl', + 'i686-unknown-netbsd', + 'i686-unknown-openbsd', + 'i686-unknown-uefi', + 'i686-uwp-windows-gnu', + 'i686-uwp-windows-msvc', + 'i686-wrs-vxworks', + 'loongarch64-unknown-linux-gnu', + 'loongarch64-unknown-none', + 'loongarch64-unknown-none-softfloat', + 'm68k-unknown-linux-gnu', + 'mips-unknown-linux-gnu', + 'mips-unknown-linux-musl', + 'mips-unknown-linux-uclibc', + 'mips64-openwrt-linux-musl', + 'mips64-unknown-linux-gnuabi64', + 'mips64-unknown-linux-muslabi64', + 'mips64el-unknown-linux-gnuabi64', + 'mips64el-unknown-linux-muslabi64', + 'mipsel-sony-psp', + 'mipsel-sony-psx', + 'mipsel-unknown-linux-gnu', + 'mipsel-unknown-linux-musl', + 'mipsel-unknown-linux-uclibc', + 'mipsel-unknown-netbsd', + 'mipsel-unknown-none', + 'mipsisa32r6-unknown-linux-gnu', + 'mipsisa32r6el-unknown-linux-gnu', + 'mipsisa64r6-unknown-linux-gnuabi64', + 'mipsisa64r6el-unknown-linux-gnuabi64', + 'msp430-none-elf', + 'nvptx64-nvidia-cuda', + 'powerpc-unknown-freebsd', + 'powerpc-unknown-linux-gnu', + 'powerpc-unknown-linux-gnuspe', + 'powerpc-unknown-linux-musl', + 'powerpc-unknown-netbsd', + 'powerpc-unknown-openbsd', + 'powerpc-wrs-vxworks', + 'powerpc-wrs-vxworks-spe', + 'powerpc64-ibm-aix', + 'powerpc64-unknown-freebsd', + 'powerpc64-unknown-linux-gnu', + 'powerpc64-unknown-linux-musl', + 'powerpc64-unknown-openbsd', + 'powerpc64-wrs-vxworks', + 'powerpc64le-unknown-freebsd', + 'powerpc64le-unknown-linux-gnu', + 'powerpc64le-unknown-linux-musl', + 'riscv32gc-unknown-linux-gnu', + 'riscv32gc-unknown-linux-musl', + 'riscv32i-unknown-none-elf', + 'riscv32im-unknown-none-elf', + 'riscv32imac-esp-espidf', + 'riscv32imac-unknown-none-elf', + 'riscv32imac-unknown-xous-elf', + 'riscv32imc-esp-espidf', + 'riscv32imc-unknown-none-elf', + 'riscv64-linux-android', + 'riscv64gc-unknown-freebsd', + 'riscv64gc-unknown-fuchsia', + 'riscv64gc-unknown-hermit', + 'riscv64gc-unknown-linux-gnu', + 'riscv64gc-unknown-linux-musl', + 'riscv64gc-unknown-netbsd', + 'riscv64gc-unknown-none-elf', + 'riscv64gc-unknown-openbsd', + 'riscv64imac-unknown-none-elf', + 's390x-unknown-linux-gnu', + 's390x-unknown-linux-musl', + 'sparc-unknown-linux-gnu', + 'sparc-unknown-none-elf', + 'sparc64-unknown-linux-gnu', + 'sparc64-unknown-netbsd', + 'sparc64-unknown-openbsd', + 'sparcv9-sun-solaris', + 'thumbv4t-none-eabi', + 'thumbv5te-none-eabi', + 'thumbv6m-none-eabi', + 'thumbv7a-pc-windows-msvc', + 'thumbv7a-uwp-windows-msvc', + 'thumbv7em-none-eabi', + 'thumbv7em-none-eabihf', + 'thumbv7m-none-eabi', + 'thumbv7neon-linux-androideabi', + 'thumbv7neon-unknown-linux-gnueabihf', + 'thumbv7neon-unknown-linux-musleabihf', + 'thumbv8m.base-none-eabi', + 'thumbv8m.main-none-eabi', + 'thumbv8m.main-none-eabihf', + 'wasm32-unknown-emscripten', + 'wasm32-unknown-unknown', + 'wasm32-wasi', + 'wasm32-wasi-preview1-threads', + 'wasm64-unknown-unknown', + 'x86_64-apple-darwin', + 'x86_64-apple-ios', + 'x86_64-apple-ios-macabi', + 'x86_64-apple-tvos', + 'x86_64-apple-watchos-sim', + 'x86_64-fortanix-unknown-sgx', + 'x86_64-fuchsia', + 'x86_64-linux-android', + 'x86_64-pc-nto-qnx710', + 'x86_64-pc-solaris', + 'x86_64-pc-windows-gnu', + 'x86_64-pc-windows-gnullvm', + 'x86_64-pc-windows-msvc', + 'x86_64-sun-solaris', + 'x86_64-unikraft-linux-musl', + 'x86_64-unknown-dragonfly', + 'x86_64-unknown-freebsd', + 'x86_64-unknown-fuchsia', + 'x86_64-unknown-haiku', + 'x86_64-unknown-hermit', + 'x86_64-unknown-illumos', + 'x86_64-unknown-l4re-uclibc', + 'x86_64-unknown-linux-gnu', + 'x86_64-unknown-linux-gnux32', + 'x86_64-unknown-linux-musl', + 'x86_64-unknown-linux-ohos', + 'x86_64-unknown-netbsd', + 'x86_64-unknown-none', + 'x86_64-unknown-openbsd', + 'x86_64-unknown-redox', + 'x86_64-unknown-uefi', + 'x86_64-uwp-windows-gnu', + 'x86_64-uwp-windows-msvc', + 'x86_64-wrs-vxworks', + 'x86_64h-apple-darwin', + ], +} + +// https://doc.rust-lang.org/rustc/platform-support.html diff --git a/code/shared/type/source/code/format.ts b/code/shared/type/source/code/format.ts new file mode 100644 index 0000000..3c4e7df --- /dev/null +++ b/code/shared/type/source/code/format.ts @@ -0,0 +1,273 @@ +import { Form } from '@termsurf/form' + +export const format_kotlin: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const format_swift: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const format_rust: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const format_python: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const format_ruby: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const format_assembly: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const format_c: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const format_cpp: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const format_java: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + }, +} + +export const format_code_with_clang_format: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + output: { + link: { + file: { + link: { + path: { like: 'string' }, + }, + }, + }, + }, + style: { + like: 'clang_style_all', + need: false, + }, + }, +} + +export const format_sql_with_content: Form = { + form: 'form', + link: { + input: { + link: { + format: { like: 'string', name: { mark: 'I' } }, + file: { + link: { + content: { + case: [{ like: 'ArrayBuffer' }, { like: 'string' }], + }, + }, + }, + }, + }, + }, +} diff --git a/code/shared/type/source/code/index.ts b/code/shared/type/source/code/index.ts new file mode 100644 index 0000000..2d4d459 --- /dev/null +++ b/code/shared/type/source/code/index.ts @@ -0,0 +1,3 @@ +export * from './data.js' +export * from './compile.js' +export * from './format.js' diff --git a/code/shared/type/source/index.ts b/code/shared/type/source/index.ts index 7dd0c27..8e6231d 100644 --- a/code/shared/type/source/index.ts +++ b/code/shared/type/source/index.ts @@ -2,6 +2,7 @@ import { Form, List } from '@termsurf/form' export * from './document.js' export * from './code.js' +export * from './code/index.js' export * from './font.js' export * from './image.js' export * from './video.js' diff --git a/code/shared/type/take.ts b/code/shared/type/take.ts index 9187801..ba54a9c 100644 --- a/code/shared/type/take.ts +++ b/code/shared/type/take.ts @@ -610,6 +610,7 @@ export const CompileCModel: z.ZodType = z.object({ output: z.object({ format: z.lazy(() => BackendCompilationOutputModel), syntax: z.optional(z.lazy(() => AssemblySyntaxModel)), + architecture: z.lazy(() => LlvmArchitectureModel), file: z.object({ path: z.string(), }), @@ -628,6 +629,7 @@ export const CompileCppModel: z.ZodType = z.object({ }), }), output: z.object({ + architecture: z.lazy(() => LlvmArchitectureModel), format: z.lazy(() => BackendCompilationOutputModel), syntax: z.optional(z.lazy(() => AssemblySyntaxModel)), file: z.object({ @@ -684,6 +686,15 @@ export const CompileRustModel: z.ZodType = z.object({ path: z.string(), }), }), + explain: z.optional(z.boolean()).default(false), + output: z.object({ + format: z.lazy(() => RustOutputFormatModel), + optimize: z.optional(z.boolean()).default(false), + target: z.optional(z.lazy(() => RustCompilerTargetModel)), + file: z.object({ + path: z.string(), + }), + }), }) export const CompileSwiftModel: z.ZodType = z.object( @@ -1497,6 +1508,12 @@ export const ResizeImageWithImageMagickModel: z.ZodType ImageMagickGravityModel), }) +export const RustCompilerTargetModel: z.ZodType = + z.enum(Cast.RUST_COMPILER_TARGET) + +export const RustOutputFormatModel: z.ZodType = + z.enum(Cast.RUST_OUTPUT_FORMAT) + export const SanitizeHtmlFromContentModel: z.ZodType = z.object({ input: z.object({ diff --git a/package.json b/package.json index 7a1698a..d9736af 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "@types/sanitize-html": "^2.9.5", "@types/sql-formatter": "^4.0.1", "accept-language-parser": "^1.5.0", + "ansi-to-html": "^0.7.2", "archiver": "^6.0.1", "bytes": "^3.1.2", "chalk": "^5.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e487544..26a558f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,6 +62,9 @@ dependencies: accept-language-parser: specifier: ^1.5.0 version: 1.5.0 + ansi-to-html: + specifier: ^0.7.2 + version: 0.7.2 archiver: specifier: ^6.0.1 version: 6.0.1 @@ -1826,6 +1829,14 @@ packages: engines: {node: '>=12'} dev: false + /ansi-to-html@0.7.2: + resolution: {integrity: sha512-v6MqmEpNlxF+POuyhKkidusCHWWkaLcGRURzivcU3I9tv7k4JVhFcnukrM5Rlk2rUywdZuzYAZ+kbZqWCnfN3g==} + engines: {node: '>=8.0.0'} + hasBin: true + dependencies: + entities: 2.2.0 + dev: false + /anymatch@3.1.3: resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} engines: {node: '>= 8'} @@ -2584,6 +2595,10 @@ packages: tapable: 2.2.1 dev: true + /entities@2.2.0: + resolution: {integrity: sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==} + dev: false + /entities@4.5.0: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} diff --git a/readme.md b/readme.md index 2f69986..b82800c 100644 --- a/readme.md +++ b/readme.md @@ -54,6 +54,7 @@ pip install nbconvert pip install docx2pdf brew install atool brew install perltidy +brew install php-cs-fixer echo 'export PATH=/Applications/calibre.app/Contents/MacOS/:$PATH' >> ~/.profile ``` diff --git a/test/cli.sh b/test/cli.sh index a1ad6db..7e00041 100755 --- a/test/cli.sh +++ b/test/cli.sh @@ -53,6 +53,10 @@ alias task="pnpm tsx code/cli" # task convert -I mkv -O dvd -i test/file/document/example.mkv -o test/hold/example.mkv.dvd # task convert -I xlsx -O csv +# archive +# task extract zip +# task archive -O zip + # format # task format rust -i test/hold/example.rs -o test/hold/example.rs # task format c -i test/file/code/example.c -o test/hold/example.c @@ -89,9 +93,10 @@ alias task="pnpm tsx code/cli" # task compile c -O binary -i test/file/code/quicksort.c -o test/hold/quicksort # task compile cpp -O binary -i test/file/code/quicksort.cpp -o test/hold/quicksort # task compile java -O jar -i test/file/code/quicksort.java -o test/hold/quicksort.jar -# task compile rust -O binary -i test/file/code/quicksort.rs -o test/hold/quicksort -task compile swift -O binary -i test/file/code/quicksort/quicksort.swift -o test/hold/quicksort.swift.o -task compile swift -O assembly -i test/file/code/quicksort/quicksort.swift -o test/hold/quicksort.swift.asm +# task compile rust -O binary -i test/file/code/quicksort/quicksort.rs -o test/hold/quicksort.rust.o +# task compile rust -O assembly -i test/file/code/quicksort/quicksort.rs -o test/hold/quicksort.rust.asm +# task compile swift -O binary -i test/file/code/quicksort/quicksort.swift -o test/hold/quicksort.swift.o +# task compile swift -O assembly -i test/file/code/quicksort/quicksort.swift -o test/hold/quicksort.swift.asm # task compile wast -O wasm -i test/file/code/quicksort.wast -o test/hold/quicksort.wasm # task compile llvm -O asm -i test/file/code/quicksort.ll -o test/hold/quicksort.asm # task compile asm -O binary -i test/file/code/quicksort.asm -o test/hold/quicksort @@ -122,3 +127,8 @@ task compile swift -O assembly -i test/file/code/quicksort/quicksort.swift -o te # task request -i url # wget # task get gematria word + +# task generate name -l afrikaans --full +# task screenshot c -O png +# task optimize gif +# task deoptimize gif diff --git a/test/file/code/quicksort/quicksort.php b/test/file/code/quicksort/quicksort.php index e69de29..ed5f0b4 100644 --- a/test/file/code/quicksort/quicksort.php +++ b/test/file/code/quicksort/quicksort.php @@ -0,0 +1,22 @@ +(arr: &mut [T], left: isize, right: isize) -> isize { i + 1 } + +fn main() { + println!("Hello, world!"); +}