file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
crates/swc_typescript/tests/typescript.rs
Rust
use std::path::PathBuf; use swc_common::{comments::SingleThreadedComments, Mark}; use swc_ecma_codegen::to_code_with_comments; use swc_ecma_parser::{parse_file_as_program, Syntax, TsSyntax}; use swc_ecma_transforms_base::{fixer::paren_remover, resolver}; use swc_typescript::fast_dts::{FastDts, FastDtsOptions}; use tes...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_visit/src/lib.rs
Rust
//! Visitor generator for the rust language. //! //! //! There are three variants of visitor in swc. Those are `Fold`, `VisitMut`, //! `Visit`. //! //! # Comparisons //! //! ## `Fold` vs `VisitMut` //! //! `Fold` and `VisitMut` do almost identical tasks, but `Fold` is easier to use //! while being slower and weak to st...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_visit/src/util/map.rs
Rust
use std::ptr; /// Copied from `syntax::ptr::P` of rustc. pub trait Map<T> { /// Transform the inner value, consuming `self` and producing a new `P<T>`. /// /// # Memory leak /// /// This will leak `self` if the given closure panics. fn map<F>(self, f: F) -> Self where F: FnOnce(T) -...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_visit/src/util/mod.rs
Rust
//! Some utilities for generated visitors. pub mod map; pub mod move_map;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_visit/src/util/move_map.rs
Rust
use std::{iter, ptr}; /// Modifiers vector in-place. pub trait MoveMap<T>: Sized { /// Map in place. fn move_map<F>(self, mut f: F) -> Self where F: FnMut(T) -> T, { self.move_flat_map(|e| iter::once(f(e))) } /// This will be very slow if you try to extend vector using this met...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml/src/lib.rs
Rust
pub extern crate swc_xml_ast as ast; pub extern crate swc_xml_codegen as codegen; pub extern crate swc_xml_parser as parser; pub extern crate swc_xml_visit as visit;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_ast/src/base.rs
Rust
use is_macro::Is; use string_enum::StringEnum; use swc_atoms::Atom; use swc_common::{ast_node, EqIgnoreSpan, Span}; #[ast_node("Document")] #[derive(Eq, Hash, EqIgnoreSpan)] pub struct Document { pub span: Span, pub children: Vec<Child>, } #[derive(StringEnum, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Hash...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_ast/src/lib.rs
Rust
#![deny(clippy::all)] #![allow(clippy::large_enum_variant)] //! AST definitions for XML. pub use self::{base::*, token::*}; mod base; mod token;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_ast/src/token.rs
Rust
#[cfg(feature = "serde-impl")] use serde::{Deserialize, Serialize}; use swc_atoms::Atom; use swc_common::{ast_node, EqIgnoreSpan, Span}; #[ast_node("TokenAndSpan")] #[derive(Eq, Hash, EqIgnoreSpan)] pub struct TokenAndSpan { pub span: Span, pub token: Token, } #[derive(Debug, Clone, PartialEq, Eq, PartialOrd,...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_codegen/src/ctx.rs
Rust
use std::ops::{Deref, DerefMut}; use crate::{writer::XmlWriter, CodeGenerator}; impl<'b, W> CodeGenerator<'b, W> where W: XmlWriter, { /// Original context is restored when returned guard is dropped. #[inline] pub(super) fn with_ctx(&mut self, ctx: Ctx) -> WithCtx<'_, 'b, W> { let orig_ctx = s...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_codegen/src/emit.rs
Rust
use std::fmt::Result; use swc_common::Spanned; /// /// # Type parameters /// /// ## `T` /// /// The type of the ast node. pub trait Emit<T> where T: Spanned, { fn emit(&mut self, node: &T) -> Result; } impl<T, E> Emit<&'_ T> for E where E: Emit<T>, T: Spanned, { #[allow(clippy::only_used_in_recur...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_codegen/src/lib.rs
Rust
#![deny(clippy::all)] #![allow(clippy::needless_update)] #![allow(non_local_definitions)] pub use std::fmt::Result; use std::{iter::Peekable, str::Chars}; use swc_common::Spanned; use swc_xml_ast::*; use swc_xml_codegen_macros::emitter; use writer::XmlWriter; pub use self::emit::*; use self::{ctx::Ctx, list::ListFor...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_codegen/src/list.rs
Rust
#![allow(non_upper_case_globals)] use bitflags::bitflags; bitflags! { #[derive(PartialEq, Eq, Clone, Copy)] pub struct ListFormat: u16 { const None = 0; // Line separators /// Prints the list on a single line (default). const SingleLine = 0; /// Prints the list on multi...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_codegen/src/macros.rs
Rust
macro_rules! emit { ($g:expr,$n:expr) => {{ use crate::Emit; $g.emit(&$n)?; }}; } macro_rules! write_raw { ($g:expr,$span:expr,$n:expr) => {{ $g.wr.write_raw(Some($span), $n)?; }}; ($g:expr,$n:expr) => {{ $g.wr.write_raw(None, $n)?; }}; } macro_rules! write_mu...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_codegen/src/writer/basic.rs
Rust
use std::fmt::{Result, Write}; use rustc_hash::FxHashSet; use swc_common::{BytePos, LineCol, Span}; use super::XmlWriter; #[derive(Clone, Copy, PartialEq, Eq, Debug, Default)] pub enum IndentType { Tab, #[default] Space, } #[derive(Clone, Copy, PartialEq, Eq, Debug, Default)] pub enum LineFeed { #[d...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_codegen/src/writer/mod.rs
Rust
use std::fmt::Result; use auto_impl::auto_impl; use swc_common::Span; pub mod basic; #[auto_impl(&mut, Box)] pub trait XmlWriter { fn write_space(&mut self) -> Result; fn write_newline(&mut self) -> Result; fn write_raw(&mut self, span: Option<Span>, text: &str) -> Result; fn write_multiline_raw(&...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_codegen/tests/fixture.rs
Rust
#![allow(clippy::needless_update)] use std::{ mem::take, path::{Path, PathBuf}, }; use swc_common::{FileName, Span}; use swc_xml_ast::*; use swc_xml_codegen::{ writer::basic::{BasicXmlWriter, BasicXmlWriterConfig, IndentType, LineFeed}, CodeGenerator, CodegenConfig, Emit, }; use swc_xml_parser::{parse...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_codegen_macros/src/lib.rs
Rust
#![deny(clippy::all)] extern crate proc_macro; use quote::ToTokens; use syn::{parse_quote, FnArg, ImplItemFn, Type, TypeReference}; #[proc_macro_attribute] pub fn emitter( _attr: proc_macro::TokenStream, item: proc_macro::TokenStream, ) -> proc_macro::TokenStream { let item: ImplItemFn = syn::parse(item)...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_parser/src/error.rs
Rust
use std::borrow::Cow; use swc_common::{ errors::{DiagnosticBuilder, Handler}, Span, }; /// Size is same as a size of a pointer. #[derive(Debug, Clone, PartialEq, Eq)] pub struct Error { inner: Box<(Span, ErrorKind)>, } impl Error { pub fn kind(&self) -> &ErrorKind { &self.inner.1 } p...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_parser/src/lexer/mod.rs
Rust
use std::{collections::VecDeque, mem::take}; use rustc_hash::FxHashSet; use swc_atoms::Atom; use swc_common::{input::Input, BytePos, Span}; use swc_xml_ast::{AttributeToken, Token, TokenAndSpan}; use crate::{ error::{Error, ErrorKind}, parser::input::ParserInput, }; #[derive(Debug, Clone)] pub enum State { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_parser/src/lib.rs
Rust
#![cfg_attr(docsrs, feature(doc_cfg))] #![deny(unused_must_use)] #![deny(clippy::all)] #![allow(clippy::needless_return)] #![allow(clippy::nonminimal_bool)] #![allow(clippy::wrong_self_convention)] use swc_common::{input::StringInput, SourceFile}; use swc_xml_ast::Document; use crate::{ error::Error, lexer::L...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_parser/src/parser/input.rs
Rust
use std::{fmt::Debug, mem::take}; use swc_common::{BytePos, Span}; use swc_xml_ast::{Token, TokenAndSpan}; use super::PResult; use crate::error::Error; pub trait ParserInput: Iterator<Item = TokenAndSpan> { fn start_pos(&mut self) -> BytePos; fn last_pos(&mut self) -> BytePos; fn take_errors(&mut self)...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_parser/src/parser/macros.rs
Rust
macro_rules! span { ($parser:expr, $start:expr) => {{ let last_pos = $parser.input.last_pos()?; swc_common::Span::new($start, last_pos) }}; } macro_rules! bump { ($parser:expr) => { $parser.input.bump()?.unwrap().token }; } macro_rules! get_tag_name { ($node:expr) => {{ ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_parser/src/parser/mod.rs
Rust
use std::{cell::RefCell, mem, rc::Rc}; use node::*; use open_elements_stack::*; use swc_common::{Span, DUMMY_SP}; use swc_xml_ast::*; use self::input::{Buffer, ParserInput}; use crate::error::{Error, ErrorKind}; #[macro_use] mod macros; pub mod input; mod node; mod open_elements_stack; pub type PResult<T> = Result<...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_parser/src/parser/node.rs
Rust
#![allow(dead_code)] use std::{ cell::{Cell, RefCell}, fmt, mem, rc::{Rc, Weak}, }; use swc_atoms::Atom; use swc_common::Span; use swc_xml_ast::*; #[derive(Debug, Clone)] pub struct TokenAndInfo { pub span: Span, pub acknowledged: bool, pub token: Token, } #[derive(Debug, Clone)] pub enum Da...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_parser/src/parser/open_elements_stack.rs
Rust
use crate::parser::RcNode; pub struct OpenElementsStack { pub items: Vec<RcNode>, } impl OpenElementsStack { pub fn new() -> Self { OpenElementsStack { items: Vec::with_capacity(16), } } pub fn pop_until_tag_name_popped(&mut self, tag_name: &[&str]) -> Option<RcNode> { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_parser/tests/fixture.rs
Rust
#![deny(warnings)] #![allow(clippy::if_same_then_else)] #![allow(clippy::needless_update)] #![allow(clippy::redundant_clone)] #![allow(clippy::while_let_on_iterator)] use std::path::PathBuf; use swc_common::{errors::Handler, input::SourceFileInput, Spanned}; use swc_xml_ast::*; use swc_xml_parser::{ lexer::Lexer,...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_visit/src/generated.rs
Rust
#![doc = r" This file is generated by `tools/generate-code`. DO NOT MODIFY."] #![allow(unused_variables)] #![allow(clippy::all)] pub use ::swc_visit::All; use swc_xml_ast::*; #[doc = r" A visitor trait for traversing the AST."] pub trait Visit { #[doc = "Visit a node of type `swc_atoms :: Atom`.\n\nBy default, this...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/swc_xml_visit/src/lib.rs
Rust
#![cfg_attr(docsrs, feature(doc_cfg))] #![deny(clippy::all)] #![allow(clippy::ptr_arg)] pub use crate::generated::*; mod generated;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing/src/diag_errors.rs
Rust
use std::sync::RwLock; use swc_common::{ errors::{Diagnostic, DiagnosticBuilder, Emitter, Handler, HandlerFlags, SourceMapperDyn}, sync::Lrc, }; /// Creates a new handler for testing. pub(crate) fn new_handler( _: Lrc<SourceMapperDyn>, treat_err_as_bug: bool, ) -> (Handler, BufferedError) { let e ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing/src/errors/mod.rs
Rust
use swc_common::errors::{DiagnosticBuilder, Emitter}; pub(crate) mod stderr; pub(crate) fn multi_emitter(a: Box<dyn Emitter>, b: Box<dyn Emitter>) -> Box<dyn Emitter> { Box::new(MultiEmitter { a, b }) } struct MultiEmitter { a: Box<dyn Emitter>, b: Box<dyn Emitter>, } impl Emitter for MultiEmitter { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing/src/errors/stderr.rs
Rust
use std::fmt; use swc_common::{ errors::{DiagnosticBuilder, Emitter}, sync::Lrc, SourceMap, }; use swc_error_reporters::{GraphicalReportHandler, PrettyEmitter, PrettyEmitterConfig}; use tracing::{info, metadata::LevelFilter, Level}; /// This emitter is controlled by the env var `RUST_LOG`. /// /// This em...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing/src/json.rs
Rust
use serde_json::Value; fn normalize_value_recursively(v: &mut Value, normalize: &mut dyn FnMut(&str, &mut Value)) { match v { Value::Array(arr) => { for v in arr { normalize_value_recursively(v, normalize); } } Value::Object(obj) => { for...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing/src/lib.rs
Rust
use std::{ env, fmt::{self, Debug, Display, Formatter}, fs::{create_dir_all, rename, File}, io::Write, path::{Component, Path, PathBuf}, process::Command, str::FromStr, sync::RwLock, thread, }; use difference::Changeset; use once_cell::sync::Lazy; pub use pretty_assertions::{assert_...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing/src/macros.rs
Rust
#[allow(unused_macros)] macro_rules! try_panic { ($e:expr) => {{ $e.unwrap_or_else(|err| { panic!("{} failed with {}", stringify!($e), err); }) }}; }
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing/src/output.rs
Rust
use std::{ env, fmt, fs::{self, create_dir_all, File}, io::Read, ops::Deref, path::Path, }; use serde::Serialize; use tracing::debug; use crate::paths; #[must_use] pub struct TestOutput<R> { /// Errors produced by `swc_common::error::Handler`. pub errors: StdErr, pub result: R, } pub...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing/src/paths.rs
Rust
use std::{env, path::PathBuf, sync::Arc}; use once_cell::sync::Lazy; pub fn manifest_dir() -> PathBuf { env::var("CARGO_MANIFEST_DIR") .map(PathBuf::from) .map(|p| { p.canonicalize() .expect("failed to canonicalize `CARGO_MANIFEST_DIR`") }) .unwrap_or_el...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing/src/string_errors.rs
Rust
use std::{ fmt, io::{self, Write}, sync::{Arc, RwLock}, }; use swc_common::{ errors::{Handler, HandlerFlags}, sync::Lrc, SourceMap, }; use swc_error_reporters::{ GraphicalReportHandler, GraphicalTheme, PrettyEmitter, PrettyEmitterConfig, }; use super::StdErr; use crate::errors::{multi_emit...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing_macros/src/fixture.rs
Rust
use std::{ env, path::{Component, PathBuf}, }; use anyhow::{Context, Error}; use glob::glob; use once_cell::sync::Lazy; use proc_macro2::{Span, TokenStream}; use quote::quote; use regex::Regex; use relative_path::RelativePath; use syn::{ parse::{Parse, ParseStream}, parse2, punctuated::Punctuated, ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing_macros/src/lib.rs
Rust
use proc_macro::TokenStream; use quote::{quote, ToTokens}; use syn::ItemFn; mod fixture; /// Create tests from files. /// /// **NOTE: Path should be relative to the directory of `Cargo.toml` file**. /// This is limitation of current proc macro api. /// /// # Why /// /// If you create test dynamically, running a speci...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
crates/testing_macros/tests/test.rs
Rust
#![deny(unused)] use std::path::PathBuf; use testing_macros::fixture; #[fixture("tests/simple/*.ts")] fn simple(_path: PathBuf) {} #[fixture("tests/ignore/**/*.ts")] fn ignored(_path: PathBuf) {} #[fixture("tests/simple/**/*.ts")] #[fixture("tests/simple/**/*.tsx")] fn multiple(_path: PathBuf) {} #[fixture("tests...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/bench-node.sh
Shell
#!/usr/bin/env bash set -eu echo "Binary load time" hyperfine --warmup 10 --runs 5 'node ./node-swc/benches/load.mjs' echo "Load + minify antd, all core" hyperfine --warmup 5 --runs 5 "node ./node-swc/benches/minify.mjs $PWD/crates/swc_ecma_minifier/benches/full/antd.js" echo "Load + minify antd, 2 core" hyperfine...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/bench/build-crate.sh
Shell
#!/usr/bin/env bash set -eu crate=$1 # If crate has feature 'concurrent', build it with feature if [[ $(./scripts/cargo/list-features.sh $crate) == *"concurrent"* ]]; then echo "Building $crate with feature 'concurrent'" cargo codspeed build -p $crate --features concurrent else echo "Building $crate" ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/bench/list-crates-with-bench.sh
Shell
#!/usr/bin/env bash set -eu WS_CRATES=$(./scripts/cargo/get-workspace-crates-json.sh) echo "$WS_CRATES" | jq -r -c '[.[] | select(.targets[] | .kind | contains(["bench"])) | .name] | sort | unique' | jq -r -c '[.[] | select(. != "swc_plugin_runner" and . != "swc_allocator" and . != "swc")]'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/bisect/list-commits.sh
Shell
#!/usr/bin/env bash set -eu commits=$(git rev-list --ancestry-path $1...$2) # Filter out commits made by `swc-bot` filtered_commits=$(echo "$commits" | while read -r commit; do author=$(git show -s --format='%an' "$commit") if [[ "$author" != "SWC Bot" ]]; then echo "$commit" fi done) # Print the...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/cargo/get-crates-with-benchmark.sh
Shell
#!/usr/bin/env bash set -eu cargo metadata --format-version 1 --no-deps \ | jq -r -j '[.packages[] | select(.source == null and .name != "xtask") | .name]' \ | tr -d '\012\015'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/cargo/get-crates.sh
Shell
#!/usr/bin/env bash set -eu cargo metadata --format-version 1 --no-deps | jq -r -j '[.packages[] | select(.source == null and .name != "xtask") | .name]' | tr -d '\012\015'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/cargo/get-workspace-crates-json.sh
Shell
#!/usr/bin/env bash set -eu cargo metadata --format-version 1 --no-deps | jq -r -j '[.packages[] | select(.source == null and .name != "xtask")]'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/cargo/list-crates.sh
Shell
#!/usr/bin/env bash set -eu # Prints json for workspace crates cargo metadata --format-version 1 | jq -r '.packages[] | select(.source == null)'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/cargo/list-features.sh
Shell
#!/usr/bin/env bash set -eu # Prints json for workspace crates cargo metadata --format-version 1 | jq -r '.packages[] | select(.source == null and .name == "'$1'") | .features'
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/cargo/patch-section.sh
Shell
#!/usr/bin/env bash set -eu SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) function toLine { # >&2 echo "toLine: $@" arr=(${1//,/ }) # >&2 echo "arr: ${arr[0]} ${arr[1]}" dir="$(dirname ${arr[1]})" echo "${arr[0]} = { path = '$dir' }" } export -f toLine $SCRIPT_...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/cargo/print-pulblished-files.sh
Shell
#!/usr/bin/env bash set -eu SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) crates=$(\ cargo metadata --format-version 1 \ | jq -r '.workspace_members[]' \ | cut -f1 -d" " \ | sort \ ) for crate in $crates do cargo publish -p $crate --dry-run --no-verif...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/cli.sh
Shell
#!/usr/bin/env bash set -eu cargo install --offline --debug --path cli
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/cli_upload_gh_release.sh
Shell
#!/bin/sh cd ./packages/core/ # Naive substitution to napi artifacts for the cli binary. for filename in artifacts_cli/* do echo "Trying to upload $filename" BINDING_NAME=${filename#*.} BINDING_ABI=${BINDING_NAME%%.*} CLI_BINARY_PATH=${filename%%.*} if [ -f "$CLI_BINARY_PATH" ]; then chmod +x $CLI_B...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/doc.sh
Shell
#!/bin/sh BASEDIR=$(dirname "$0") RUSTDOC="$BASEDIR/rustdoc.sh" cargo doc $@
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/git-diff.sh
Shell
#!/usr/bin/env bash # # Used to generate `swc-bump` set -eu git diff --name-only HEAD upstream/main | grep -E '^crates/' | sed -e "s/^crates\///" | sed 's/\/.*//' | uniq
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/github/get-all-crates.sh
Shell
#!/usr/bin/env bash set -eu function prepend() { while read line; do echo "${1}${line}"; done; } cargo metadata --format-version 1 \ | jq -r '.workspace_members[]' \ | cut -f1 -d" " \ | sort \ | prepend '- '
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/github/get-test-matrix.mjs
JavaScript
#!/usr/bin/env zx import * as path from 'node:path'; import * as fs from 'node:fs/promises'; import { parse, } from 'yaml' const scriptDir = __dirname; const repoRootDir = path.resolve(scriptDir, '../../'); const testsYmlPath = path.resolve(repoRootDir, 'tests.yml'); const testsYml = parse(await fs.readFile(testsYmlPa...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/github/run-cargo-hack.sh
Shell
#!/usr/bin/env bash set -eu SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) crate=$1 echo "Running cargo hack for crate $crate" # yq query syntax is weird, so we have to use jq json_str="$(yq -o=json $SCRIPT_DIR/../../tests.yml)" if echo $json_str | jq -e ".check.\"$crate\"" > /dev...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/github/test-concurrent.sh
Shell
#!/usr/bin/env bash set -eu echo "Checking if '$1' has feature 'concurrent'" # Get crates with feature named `concurrent` CRATES=$(./scripts/cargo/list-crates.sh | \ jq -r 'select(.features.concurrent != null) | .name') if [[ "swc" == "$1" ]]; then echo "Skipping swc itself" exit 0 fi if [[ $CRATES == ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/link.sh
Shell
#!/usr/bin/env bash set -eu yarn run build:dev yarn link (cd swr && yarn run build)
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/publish.sh
Shell
#!/usr/bin/env bash set -eu SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) git pull || true yarn version="$1" swc_core_version="$(cargo tree -i -p swc_core --depth 0 | awk '{print $2}')" echo "Publishing $version with swc_core $swc_core_version" # Update swc_core (cd ./bindings &&...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/repo/count-files.sh
Shell
#!/usr/bin/env bash # # This script counts the number of files per each directory. # # set -eu find . -type d -empty -delete find . -maxdepth 3 -mindepth 1 -type d | while read dir; do if [[ $dir == ./.git* ]]; then continue fi if git check-ignore "$dir" > /dev/null ; then # echo "Ignorin...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/repo/profile-git.sh
Shell
#!/usr/bin/env zsh set -eu find . -type d -empty -delete export GIT_TRACE2_PERF_BRIEF=true export GIT_TRACE2_PERF=/tmp/git-perf rm -f $GIT_TRACE2_PERF time git status -z -u # time git status -uno # git add -A cat $GIT_TRACE2_PERF
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/setup-env.sh
Shell
#!/usr/bin/env bash set -eu NODE_PLATFORM_NAME=$(node -e "console.log(require('os').platform())") (cd scripts/npm/core-$NODE_PLATFORM_NAME && npm link) npm link @swc/core-$NODE_PLATFORM_NAME
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/sourcemap/decode.js
JavaScript
// Copied from https://gist.github.com/bengourley/c3c62e41c9b579ecc1d51e9d9eb8b9d2 // // This program reads a sourcemap from stdin // and replaces the "mappings" property with // human readable content. It writes the output // to stdout. // // 1. install the dependencies: // npm i concat-stream vlq // // 2. optiona...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/sourcemap/vlq.js
JavaScript
(function (global, factory) { typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : ((global = typeof globalThis !== "undefined" ? globalThis : global || self), ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/test.sh
Shell
#!/usr/bin/env bash set -eux yarn run build:dev yarn run tsc # yarn test npm link mkdir -p tests/integration/three-js swc tests/integration/three-js/repo/ -d tests/integration/three-js/build/ (cd tests/integration/three-js/build/test && qunit -r failonlyreporter unit/three.source.unit.js)
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/update-all-swc-crates.sh
Shell
#!/usr/bin/env bash set -eu echo "Listing all swc crates" swc_crates=$(cargo metadata --format-version=1 --all-features | jq '.packages .[] | select(.repository == "https://github.com/swc-project/swc.git" or .repository == "https://github.com/swc-project/plugins.git") | .name' -r) swc_deps=$(cargo metadata --format-...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/update-all.sh
Shell
#!/usr/bin/env bash set -u export UPDATE=1 export DIFF=0 function crate() { until cargo test -p $1 --no-fail-fast do git add -A git commit -m 'Update test refs' done git add -A git commit -m 'Update test refs' } crate swc crate swc_ecma_codegen crate swc_ecma_parser crate swc...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
scripts/update_fallback_dependencies.js
JavaScript
// For some native targets, we'll make `@swc/wasm` as dependency to ensure it can gracefully fallback // While we migrate native builds into `@swc/wasm`. const path = require("path"); const fs = require("fs"); const targets = [ "freebsd-x64", "win32-ia32-msvc", "linux-arm-gnueabihf", "android-arm64", ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
tools/generate-code/src/generators/mod.rs
Rust
pub mod visitor;
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
tools/generate-code/src/generators/visitor.rs
Rust
use std::collections::HashSet; use inflector::Inflector; use proc_macro2::{Span, TokenStream}; use quote::{quote, ToTokens}; use swc_cached::regex::CachedRegex; use syn::{ parse_quote, Arm, Attribute, Expr, Field, Fields, File, GenericArgument, Ident, Item, Lit, LitInt, Path, PathArguments, Stmt, TraitItem, Ty...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
tools/generate-code/src/main.rs
Rust
#![allow(clippy::only_used_in_recursion)] use std::path::{Path, PathBuf}; use anyhow::{bail, Context, Result}; use clap::Parser; use proc_macro2::Span; use swc_cached::regex::CachedRegex; use syn::{Ident, Item}; use crate::types::qualify_types; mod generators; mod types; #[derive(Debug, Parser)] struct CliArgs { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
tools/generate-code/src/types.rs
Rust
use std::collections::HashMap; use syn::{ parse_quote, visit_mut::{visit_file_mut, VisitMut}, File, Ident, ItemUse, Path, PathSegment, TypePath, UseTree, }; pub fn qualify_types(mut file: File) -> File { let use_items = collect_use_items(&file); let mut map = HashMap::new(); for item in use_...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
tools/swc-releaser/src/main.rs
Rust
use std::{ collections::{hash_map::Entry, HashMap}, env, path::{Path, PathBuf}, process::Command, }; use anyhow::{Context, Result}; use cargo_metadata::{semver::Version, DependencyKind}; use changesets::ChangeType; use clap::{Parser, Subcommand}; use indexmap::IndexSet; use petgraph::{prelude::DiGraphM...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/bench.rs
Rust
use std::process::Command; use anyhow::Result; use clap::Args; use crate::util::{repository_root, run_cmd}; /// Run one or more benchmarks #[derive(Debug, Args)] pub(super) struct BenchCmd { #[clap(long, short = 'p')] package: String, /// Build benchmarks in debug mode. #[clap(long)] debug: bool...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/clean.rs
Rust
use std::path::Path; use anyhow::Result; use clap::Args; use walkdir::WalkDir; use crate::util::{repository_root, run_cmd}; /// Clean cargo target directories #[derive(Debug, Args)] pub(super) struct CleanCmd {} impl CleanCmd { pub fn run(self) -> Result<()> { let root_dir = repository_root()?; ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/es/minifier.rs
Rust
use anyhow::Result; use clap::{Args, Subcommand}; #[derive(Debug, Args)] pub(super) struct MinifierCmd { #[clap(subcommand)] cmd: Cmd, } impl MinifierCmd { pub fn run(self) -> Result<()> { match self.cmd {} } } #[derive(Debug, Subcommand)] enum Cmd {}
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/es/mod.rs
Rust
use anyhow::Result; use clap::{Args, Subcommand}; use self::minifier::MinifierCmd; mod minifier; /// Commands for ECMAScript crates. #[derive(Debug, Args)] pub(super) struct EsCmd { #[clap(subcommand)] cmd: Cmd, } impl EsCmd { pub fn run(self) -> Result<()> { match self.cmd { Cmd::Mi...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/git/mod.rs
Rust
use anyhow::Result; use clap::{Args, Subcommand}; use self::reduce::ReduceCmd; mod reduce; #[derive(Debug, Args)] pub(super) struct GitCmd { #[clap(subcommand)] cmd: Inner, } #[derive(Debug, Subcommand)] enum Inner { Reduce(ReduceCmd), } impl GitCmd { pub fn run(self) -> Result<()> { match ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/git/reduce/core_ver.rs
Rust
use anyhow::Result; use clap::Args; use crate::util::get_commit_for_core_version; /// Reduce the difference of the versions of `swc_core`s to the list of commits /// and pull requests. #[derive(Debug, Args)] pub(super) struct CoreVerCmd { from: String, to: String, } impl CoreVerCmd { pub fn run(self) ->...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/git/reduce/mod.rs
Rust
use anyhow::Result; use clap::{Args, Subcommand}; use self::core_ver::CoreVerCmd; mod core_ver; #[derive(Debug, Args)] pub(super) struct ReduceCmd { #[clap(subcommand)] cmd: Inner, } #[derive(Debug, Subcommand)] enum Inner { CoreVer(CoreVerCmd), } impl ReduceCmd { pub fn run(self) -> Result<()> { ...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/main.rs
Rust
use anyhow::Result; use clap::{Parser, Subcommand}; use npm::NpmCmd; use crate::{bench::BenchCmd, clean::CleanCmd, es::EsCmd, git::GitCmd}; mod bench; mod clean; mod es; mod git; mod npm; mod util; #[derive(Debug, Parser)] struct CliArgs { #[clap(subcommand)] cmd: Cmd, } #[derive(Debug, Subcommand)] enum Cm...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/npm/mod.rs
Rust
use anyhow::Result; use clap::{Args, Subcommand}; use self::nightly::NightlyCmd; mod nightly; mod util; #[derive(Debug, Args)] pub(super) struct NpmCmd { #[clap(subcommand)] cmd: Inner, } #[derive(Debug, Subcommand)] enum Inner { Nightly(NightlyCmd), } impl NpmCmd { pub fn run(self) -> Result<()> {...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/npm/nightly.rs
Rust
use std::process::{Command, Stdio}; use anyhow::{ensure, Context, Result}; use chrono::Utc; use clap::Args; use semver::{Prerelease, Version}; use crate::{ npm::util::{bump_swc_cli, set_version}, util::{repository_root, wrap}, }; #[derive(Debug, Args)] pub(super) struct NightlyCmd {} impl NightlyCmd { p...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/npm/util.rs
Rust
use std::process::{Command, Stdio}; use anyhow::{Context, Result}; use semver::Version; use crate::util::{repository_root, wrap}; pub fn set_version(version: &Version) -> Result<()> { wrap(|| { let mut c = Command::new("npm"); c.current_dir(repository_root()?).stderr(Stdio::inherit()); c....
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
xtask/src/util/mod.rs
Rust
use std::{ env, path::{Path, PathBuf}, process::{Command, Stdio}, }; use anyhow::{bail, Context, Result}; use serde_derive::Deserialize; pub fn wrap<F, Ret>(op: F) -> Result<Ret> where F: FnOnce() -> Result<Ret>, { op() } pub fn repository_root() -> Result<PathBuf> { let dir = env::var("CARGO...
willcrichton/ilc-swc
1
Rust
willcrichton
Will Crichton
Brown University
src/bitset/bitvec.rs
Rust
//! A bit-set from the [`bitvec`] crate. use bitvec::{prelude::Lsb0, store::BitStore}; use crate::{ bitset::BitSet, pointer::{ArcFamily, RcFamily, RefFamily}, }; pub use ::bitvec::{self, vec::BitVec}; impl BitSet for BitVec { fn empty(size: usize) -> Self { bitvec::bitvec![usize, Lsb0; 0; size] ...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
src/bitset/mod.rs
Rust
//! Abstraction over bit-set implementations. /// Interface for bit-set implementations. /// /// Implement this trait if you want to provide a custom bit-set /// beneath the indexical abstractions. pub trait BitSet: Clone + PartialEq { /// Constructs a new bit-set with a domain of size `size`. fn empty(size: u...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
src/bitset/roaring.rs
Rust
#![allow(clippy::cast_possible_truncation)] //! A bit-set based on [`RoaringBitmap`]. //! //! If you want roaring's SIMD support, add `roaring-simd` to //! your indexical feature list. pub use roaring::{self, RoaringBitmap}; use crate::{ bitset::BitSet, pointer::{ArcFamily, RcFamily, RefFamily}, }; /// Wrap...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
src/bitset/rustc.rs
Rust
//! The Rust compiler's [`BitSet`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_index/bit_set/struct.BitSet.html). extern crate rustc_driver; pub extern crate rustc_index; extern crate rustc_mir_dataflow; use crate::{ IndexedValue, bitset::BitSet, pointer::{ArcFamily, PointerFamily, RcFamily, RefFam...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
src/bitset/simd.rs
Rust
#![allow(clippy::cast_possible_truncation)] //! A custom SIMD-accelerated bit-set. //! //! Implementation is largely derived from the `bitsvec` crate: <https://github.com/psiace/bitsvec> //! //! The main difference is I made a much more efficient iterator that computes the indices //! of the 1-bits. //! //! **WARNING:...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
src/domain.rs
Rust
use index_vec::{Idx, IndexVec}; use rustc_hash::FxHashMap; use std::fmt; use crate::IndexedValue; /// An indexed collection of objects. /// /// Contains a reverse-mapping from `T` to `T::Index` for efficient lookups of indices. #[derive(Clone)] #[cfg_attr(feature = "serde", derive(serde::Serialize))] pub struct Index...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
src/lib.rs
Rust
#![doc = include_str!("../README.md")] //! ## Design //! The key idea is that the [`IndexedDomain`] is shared pervasively //! across all Indexical types. All types can then use the [`IndexedDomain`] to convert between indexes and objects, usually via the [`ToIndex`] trait. //! //! [`IndexSet`](set::IndexSet) and [`Inde...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
src/map.rs
Rust
//! Map-like collections for indexed keys. use std::{ collections::hash_map, ops::{Index, IndexMut}, }; use rustc_hash::FxHashMap; use crate::{ FromIndexicalIterator, IndexedDomain, IndexedValue, ToIndex, pointer::{ArcFamily, PointerFamily, RcFamily, RefFamily}, vec::IndexVec, }; /// A mapping f...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
src/matrix.rs
Rust
//! An unordered collections of pairs `(R, C)`, implemented with a sparse bit-matrix. #![allow(clippy::needless_pass_by_value)] use rustc_hash::FxHashMap; use std::{fmt, hash::Hash}; use crate::{ IndexedDomain, IndexedValue, ToIndex, bitset::BitSet, pointer::PointerFamily, set::IndexSet, }; /// An unordered col...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
src/pointer.rs
Rust
//! Abstraction over smart pointers. use std::marker::PhantomData; use std::ops::Deref; use std::rc::Rc; use std::sync::Arc; /// Abstraction over smart pointers. /// /// Used so to make the indexical data structures generic with respect /// to choice of `Rc` or `Arc` (or your own clonable smart pointer!). pub trait P...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
src/set.rs
Rust
//! An unordered collections of `T`s, implemented with a bit-set. use std::{borrow::Borrow, fmt}; use index_vec::Idx; use crate::{ FromIndexicalIterator, IndexedDomain, IndexedValue, ToIndex, bitset::BitSet, pointer::PointerFamily, }; /// An unordered collections of `T`s, implemented with a bit-set. pub str...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University
src/test_utils.rs
Rust
use crate::{bitset::BitSet, define_index_type}; define_index_type! { pub struct StrIdx for String = u32; } pub type TestIndexSet<T> = crate::bitset::bitvec::RcIndexSet<T>; pub type TestIndexMatrix<R, C> = crate::bitset::bitvec::RcIndexMatrix<R, C>; pub fn impl_test<T: BitSet>() { let mut bv = T::empty(10); ...
willcrichton/indexical
56
Human-friendly indexed collections
Rust
willcrichton
Will Crichton
Brown University