Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyProgrammist committed Dec 30, 2023
1 parent 67e6c2a commit aa449a0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/codegen/generators/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ export interface CodeGenerator {
jsCodeDeclarations: CommonGenDeclaration[]
jsCodeConstructorDeclarations: CommonGenDeclaration[]
jsCodeFunctionsDeclarations: CommonGenDeclaration[]
tlbCode: TLBCode

addTonCoreClassUsage(name: string): void
addBitLenFunction(): void
addTlbType(tlbType: TLBType, tlbCode: TLBCode): void
addTlbType(tlbType: TLBType): void
toCode(node: TheNode, code: CodeBuilder): CodeBuilder
}

Expand Down
4 changes: 2 additions & 2 deletions src/codegen/generators/typescript/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BinaryExpression, FunctionDeclaration, GenDeclaration, ObjectProperty,
import { addLoadProperty, convertToAST, getCondition, getParamVarExpr, getTypeParametersExpression, sliceLoad } from "./utils";
import { handleType } from "./handle_type";


export class TypescriptGenerator implements CodeGenerator {
jsCodeDeclarations: GenDeclaration[] = []
jsCodeConstructorDeclarations: GenDeclaration[] = []
Expand All @@ -24,7 +25,7 @@ export class TypescriptGenerator implements CodeGenerator {
tExpressionStatement(tIdentifier('return n.toString(2).length;'))
]))
}
addTlbType(tlbType: TLBType, tlbCode: TLBCode): void {
addTlbType(tlbType: TLBType): void {
let variableCombinatorName = goodVariableName(firstLower(tlbType.name), '0')
let subStructsUnion: TypeExpression[] = []
let subStructDeclarations: StructDeclaration[] = []
Expand All @@ -37,7 +38,6 @@ export class TypescriptGenerator implements CodeGenerator {
tlbType.constructors.forEach(constructor => {
let constructorLoadStatements: Statement[] = []
let subStructName: string = getSubStructName(tlbType, constructor);

let variableSubStructName = goodVariableName(firstLower(subStructName), '_' + constructor.name)

let subStructProperties: TypedIdentifier[] = [tTypedIdentifier(tIdentifier('kind'), tStringLiteral(subStructName))]
Expand Down
8 changes: 0 additions & 8 deletions src/codegen/generators/typescript/handle_field.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/codegen/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function generate(tree: Program, input: string) {
let splittedInput = input.split('\n')

fillConstructors(tree.declarations, tlbCode, splittedInput);

let codeGenerator: CodeGenerator = new TypescriptGenerator(tlbCode);

codeGenerator.addTonCoreClassUsage('Builder')
Expand All @@ -28,7 +28,7 @@ export function generate(tree: Program, input: string) {
jsCodeDeclarations.push(declaration)
})

tlbCode.types.forEach((tlbType: TLBType) => { codeGenerator.addTlbType(tlbType, tlbCode) });
tlbCode.types.forEach((tlbType: TLBType) => { codeGenerator.addTlbType(tlbType) });

let generatedCode = ''

Expand Down

0 comments on commit aa449a0

Please sign in to comment.