-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
347 additions
and
2 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
src/main/java/com/caoccao/javet/buddy/ts2java/ast/expr/Ts2JavaAstIdent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.expr; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.BaseTs2JavaAst; | ||
import com.caoccao.javet.buddy.ts2java.ast.interfaces.*; | ||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemoFunction; | ||
import com.caoccao.javet.buddy.ts2java.compiler.JavaLocalVariable; | ||
import com.caoccao.javet.swc4j.ast.expr.Swc4jAstIdent; | ||
import net.bytebuddy.implementation.Implementation; | ||
import net.bytebuddy.implementation.bytecode.StackManipulation; | ||
import net.bytebuddy.implementation.bytecode.member.MethodVariableAccess; | ||
import net.bytebuddy.jar.asm.MethodVisitor; | ||
|
||
public class Ts2JavaAstIdent | ||
extends BaseTs2JavaAst<Swc4jAstIdent, Ts2JavaMemoFunction> | ||
implements ITs2JavaAstExpr<Swc4jAstIdent, Ts2JavaMemoFunction>, | ||
ITs2JavaAstProp<Swc4jAstIdent, Ts2JavaMemoFunction>, | ||
ITs2JavaAstTsModuleRef<Swc4jAstIdent, Ts2JavaMemoFunction>, | ||
ITs2JavaAstModuleExportName<Swc4jAstIdent, Ts2JavaMemoFunction>, | ||
ITs2JavaAstTsEntityName<Swc4jAstIdent, Ts2JavaMemoFunction>, | ||
ITs2JavaAstTsModuleName<Swc4jAstIdent, Ts2JavaMemoFunction>, | ||
ITs2JavaAstJsxObject<Swc4jAstIdent, Ts2JavaMemoFunction>, | ||
ITs2JavaAstJsxElementName<Swc4jAstIdent, Ts2JavaMemoFunction>, | ||
ITs2JavaAstTsThisTypeOrIdent<Swc4jAstIdent, Ts2JavaMemoFunction>, | ||
ITs2JavaAstTsEnumMemberId<Swc4jAstIdent, Ts2JavaMemoFunction> { | ||
protected final boolean optional; | ||
protected final String sym; | ||
|
||
public Ts2JavaAstIdent( | ||
ITs2JavaAst<?, ?> parent, | ||
Swc4jAstIdent ast, | ||
Ts2JavaMemoFunction memo) { | ||
super(parent, ast, memo); | ||
optional = ast.isOptional(); | ||
sym = ast.getSym(); | ||
} | ||
|
||
@Override | ||
public Size apply(MethodVisitor methodVisitor, Implementation.Context context) { | ||
visitLineNumber(methodVisitor); | ||
JavaLocalVariable localVariable = memo.getLocalVariable(sym); | ||
MethodVariableAccess methodVariableAccess = MethodVariableAccess.of(localVariable.getType()); | ||
StackManipulation stackManipulation = methodVariableAccess.loadFrom(localVariable.getOffset()); | ||
return stackManipulation.apply(methodVisitor, context); | ||
} | ||
|
||
@Override | ||
public void compile() { | ||
} | ||
|
||
public String getSym() { | ||
return sym; | ||
} | ||
|
||
public boolean isOptional() { | ||
return optional; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/caoccao/javet/buddy/ts2java/ast/interfaces/ITs2JavaAstJsxElementName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.interfaces; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemo; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstJsxElementName; | ||
|
||
public interface ITs2JavaAstJsxElementName<AST extends ISwc4jAstJsxElementName, Memo extends Ts2JavaMemo> | ||
extends ITs2JavaAst<AST, Memo> { | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/caoccao/javet/buddy/ts2java/ast/interfaces/ITs2JavaAstJsxObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.interfaces; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemo; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstJsxObject; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsModuleRef; | ||
|
||
public interface ITs2JavaAstJsxObject<AST extends ISwc4jAstJsxObject, Memo extends Ts2JavaMemo> | ||
extends ITs2JavaAst<AST, Memo> { | ||
} |
24 changes: 24 additions & 0 deletions
24
...main/java/com/caoccao/javet/buddy/ts2java/ast/interfaces/ITs2JavaAstModuleExportName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.interfaces; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemo; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstModuleExportName; | ||
|
||
public interface ITs2JavaAstModuleExportName<AST extends ISwc4jAstModuleExportName, Memo extends Ts2JavaMemo> | ||
extends ITs2JavaAst<AST, Memo> { | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/caoccao/javet/buddy/ts2java/ast/interfaces/ITs2JavaAstProp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.interfaces; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemo; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstProp; | ||
|
||
public interface ITs2JavaAstProp<AST extends ISwc4jAstProp, Memo extends Ts2JavaMemo> | ||
extends ITs2JavaAstPropOrSpread<AST, Memo> { | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/caoccao/javet/buddy/ts2java/ast/interfaces/ITs2JavaAstPropOrSpread.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.interfaces; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemo; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstPropOrSpread; | ||
|
||
public interface ITs2JavaAstPropOrSpread<AST extends ISwc4jAstPropOrSpread, Memo extends Ts2JavaMemo> | ||
extends ITs2JavaAst<AST, Memo> { | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/caoccao/javet/buddy/ts2java/ast/interfaces/ITs2JavaAstTsEntityName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.interfaces; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemo; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsEntityName; | ||
|
||
public interface ITs2JavaAstTsEntityName<AST extends ISwc4jAstTsEntityName, Memo extends Ts2JavaMemo> | ||
extends ITs2JavaAstTsModuleRef<AST, Memo>, ITs2JavaAstTsTypeQueryExpr<AST, Memo> { | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/caoccao/javet/buddy/ts2java/ast/interfaces/ITs2JavaAstTsEnumMemberId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.interfaces; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemo; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsEnumMemberId; | ||
|
||
public interface ITs2JavaAstTsEnumMemberId<AST extends ISwc4jAstTsEnumMemberId, Memo extends Ts2JavaMemo> | ||
extends ITs2JavaAst<AST, Memo> { | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/caoccao/javet/buddy/ts2java/ast/interfaces/ITs2JavaAstTsModuleName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.interfaces; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemo; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsModuleName; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsModuleRef; | ||
|
||
public interface ITs2JavaAstTsModuleName<AST extends ISwc4jAstTsModuleName, Memo extends Ts2JavaMemo> | ||
extends ITs2JavaAst<AST, Memo> { | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/caoccao/javet/buddy/ts2java/ast/interfaces/ITs2JavaAstTsModuleRef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.interfaces; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemo; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsModuleRef; | ||
|
||
public interface ITs2JavaAstTsModuleRef<AST extends ISwc4jAstTsModuleRef, Memo extends Ts2JavaMemo> | ||
extends ITs2JavaAst<AST, Memo> { | ||
} |
25 changes: 25 additions & 0 deletions
25
...ain/java/com/caoccao/javet/buddy/ts2java/ast/interfaces/ITs2JavaAstTsThisTypeOrIdent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.interfaces; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemo; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsModuleRef; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsThisTypeOrIdent; | ||
|
||
public interface ITs2JavaAstTsThisTypeOrIdent<AST extends ISwc4jAstTsThisTypeOrIdent, Memo extends Ts2JavaMemo> | ||
extends ITs2JavaAst<AST, Memo> { | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/caoccao/javet/buddy/ts2java/ast/interfaces/ITs2JavaAstTsTypeQueryExpr.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024. caoccao.com Sam Cao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.caoccao.javet.buddy.ts2java.ast.interfaces; | ||
|
||
import com.caoccao.javet.buddy.ts2java.ast.memo.Ts2JavaMemo; | ||
import com.caoccao.javet.swc4j.ast.interfaces.ISwc4jAstTsTypeQueryExpr; | ||
|
||
public interface ITs2JavaAstTsTypeQueryExpr<AST extends ISwc4jAstTsTypeQueryExpr, Memo extends Ts2JavaMemo> | ||
extends ITs2JavaAst<AST, Memo> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters