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 650603d commit bccc4a6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 41 deletions.
4 changes: 3 additions & 1 deletion src/codegen/generators/typescript/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { CodeBuilder } from "../CodeBuilder";
import { CodeGenerator } from "../generator";
import { BinaryExpression, Expression, FunctionDeclaration, GenDeclaration, ObjectProperty, Statement, StructDeclaration, TheNode, TypeExpression, TypeParametersExpression, TypedIdentifier, tArrowFunctionExpression, tArrowFunctionType, tBinaryExpression, tComment, tDeclareVariable, tExpressionStatement, tFunctionCall, tFunctionDeclaration, tIdentifier, tIfStatement, tImportDeclaration, tMemberExpression, tMultiStatement, tNumericLiteral, tObjectExpression, tObjectProperty, tReturnStatement, tStringLiteral, tStructDeclaration, tTernaryExpression, tTypeParametersExpression, tTypeWithParameters, tTypedIdentifier, tUnaryOpExpression, tUnionTypeDeclaration, tUnionTypeExpression, toCode } from "./tsgen";
import { addLoadProperty, convertToAST, getCondition, getNegationDerivationFunctionBody, getParamVarExpr, getTypeParametersExpression, sliceLoad } from "./utils";
import { ExprForParam, FieldInfoType, isBigInt } from "./handle_type";
import { isBigInt } from './utils';
import { ExprForParam } from './utils';
import { FieldInfoType } from './utils';


type ConstructorContext = {
Expand Down
36 changes: 0 additions & 36 deletions src/codegen/generators/typescript/handle_type.ts

This file was deleted.

36 changes: 32 additions & 4 deletions src/codegen/generators/typescript/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BuiltinZeroArgs, FieldCurlyExprDef, FieldNamedDef, Program, BuiltinOneArgExpr, NumberExpr, NameExpr, CombinatorExpr, FieldBuiltinDef, MathExpr, SimpleExpr, NegateExpr, CellRefExpr, FieldDefinition, FieldAnonymousDef, CondExpr, CompareExpr, Expression as ParserExpression } from '../../../ast/nodes'
import { tIdentifier, tArrowFunctionExpression, tArrowFunctionType, tBinaryExpression, tBinaryNumericLiteral, tDeclareVariable, tExpressionStatement, tFunctionCall, tFunctionDeclaration, tIfStatement, tImportDeclaration, tMemberExpression, tNumericLiteral, tObjectExpression, tObjectProperty, tReturnStatement, tStringLiteral, tStructDeclaration, tTypeWithParameters, tTypedIdentifier, tUnionTypeDeclaration, toCode, TypeWithParameters, ArrowFunctionExpression, tForCycle, tTypeParametersExpression, tUnaryOpExpression } from './tsgen'
import { TLBMathExpr, TLBVarExpr, TLBNumberExpr, TLBBinaryOp, TLBCode, TLBType, TLBConstructor, TLBParameter, TLBVariable, TLBUnaryOp } from '../../ast'
import { Expression, Statement, Identifier, BinaryExpression, ASTNode, TypeExpression, TypeParametersExpression, ObjectProperty, TypedIdentifier } from './tsgen'
import { tIdentifier, tArrowFunctionExpression, tArrowFunctionType, tBinaryExpression, tBinaryNumericLiteral, tDeclareVariable, tExpressionStatement, tFunctionCall, tFunctionDeclaration, tIfStatement, tImportDeclaration, tMemberExpression, tNumericLiteral, tObjectExpression, tObjectProperty, tReturnStatement, tStringLiteral, tStructDeclaration, tTypeWithParameters, tTypedIdentifier, tUnionTypeDeclaration, toCode, TypeWithParameters, ArrowFunctionExpression, tForCycle, tTypeParametersExpression, tUnaryOpExpression, Expression, Statement, TypeExpression } from './tsgen'
import { TLBMathExpr, TLBVarExpr, TLBNumberExpr, TLBBinaryOp, TLBCode, TLBType, TLBConstructor, TLBParameter, TLBVariable, TLBUnaryOp, TLBNumberType } from '../../ast'
import { Identifier, BinaryExpression, ASTNode, TypeParametersExpression, ObjectProperty, TypedIdentifier } from './tsgen'
import { getCalculatedExpression, getSubStructName, fillConstructors, firstLower, getCurrentSlice, bitLen, convertToMathExpr, splitForTypeValue, deriveMathExpression, goodVariableName } from '../../utils'


Expand Down Expand Up @@ -121,4 +121,32 @@ export function getCondition(conditions: Array<BinaryExpression>): Expression {
} else {
return tIdentifier('true');
}
}
}
export type FieldInfoType = {
typeParamExpr: TypeExpression | undefined
loadExpr: Expression | undefined
loadFunctionExpr: Expression | undefined
storeExpr: Statement | undefined
storeExpr2: Statement | undefined
storeFunctionExpr: Expression | undefined
negatedVariablesLoads: Array<{ name: string; expression: Expression} >
}
export type ExprForParam = {
argLoadExpr: Expression | undefined
argStoreExpr: Expression | undefined
paramType: string
fieldLoadSuffix: string
fieldStoreSuffix: string
}
export function isBigInt(fieldType: TLBNumberType) {
if (fieldType.bits instanceof TLBNumberExpr) {
if (fieldType.bits.n <= 64) {
return false
}
}
if (fieldType.maxBits && fieldType.maxBits <= 64) {
return false
}
return true
}

0 comments on commit bccc4a6

Please sign in to comment.