Skip to content

Commit

Permalink
Add to TypeScript transformer
Browse files Browse the repository at this point in the history
Copied from to Java transformer
  • Loading branch information
Minigugus committed Jun 8, 2024
1 parent 9f4a31f commit fa23a26
Show file tree
Hide file tree
Showing 6 changed files with 1,999 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod parser;
pub mod types;
pub mod printer;
pub mod bytecode;
pub mod transformer;
pub mod transform;
pub mod eval;
mod scope;

Expand Down
2 changes: 2 additions & 0 deletions src/transform.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod java;
pub mod ts;
4 changes: 2 additions & 2 deletions src/transformer.rs → src/transform/java.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mod match_op;

use alloc::{format, vec};
use alloc::borrow::Cow;
use alloc::collections::BTreeMap;
Expand All @@ -15,6 +13,8 @@ use crate::mlir::ops::{BlockBuilder, Body as Body0, RefId, RuntimeValue, Typed};
use crate::scope::{Loc, Scope, Scopes};
use crate::types::{EnumDef, EnumVariantFields, FunctionDef, Module, PrimitiveType, Scope as ScopeNode, StructDef, StructFields, Symbol, SymbolRef, TypeRef, value_kind_to_type_ref};

mod match_op;

type JavaSymbolRef = (usize, Rc<String>, Option<String>);

trait ToJavaResolver {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ use alloc::borrow::Cow;
use alloc::collections::BTreeMap;
use alloc::format;
use alloc::vec::Vec;

use crate::bytecode::{SkMatchCaseOp, SkMatchPatternOp, SymbolRefOrEnum};
use crate::mlir::ops::{BlockBuilder, Typed};
use crate::transformer::{JavaBody, JavaModule, JavaModuleBuilder, JavaOpN, JavaScope, JavaTerminatorOpN, JavaValueKind, JavaValueRef, ToJavaResolver};

use super::{JavaBody, JavaModule, JavaModuleBuilder, JavaOpN, JavaScope, JavaTerminatorOpN, JavaValueKind, JavaValueRef, ToJavaResolver};

impl JavaBody {
pub fn visit_match_case<'a>(
Expand Down Expand Up @@ -325,10 +327,12 @@ impl JavaBody {
mod tests {
use alloc::borrow::Cow;
use alloc::string::ToString;

use crate::lexer::Token;
use crate::transformer::JavaModule;
use crate::types::Module;

use super::JavaModule;

#[test]
fn it_transform_match_complex() -> Result<(), Cow<'static, str>> {
// tokenize
Expand Down
Loading

0 comments on commit fa23a26

Please sign in to comment.