Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyProgrammist committed Jan 9, 2024
1 parent cb51940 commit 6f72a73
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 55 deletions.
29 changes: 21 additions & 8 deletions src/generators/typescript/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,15 +709,28 @@ export class TypescriptGenerator implements CodeGenerator {
fieldStoreSuffix: "Address",
};
} else if (fieldType.kind == "TLBHashmapType") {
if (fieldType.key.kind == 'TLBExprMathType' && fieldType.value.kind == 'TLBNumberType') {
result.loadExpr = tFunctionCall(tMemberExpression(id(currentSlice), id('loadDict')), [
tFunctionCall(tMemberExpression(id('Dictionary.Keys'), id('Uint')), [convertToAST(fieldType.key.expr, ctx.constructor)]),
tFunctionCall(tMemberExpression(id('Dictionary.Values'), id('Uint')), [convertToAST(fieldType.value.bits, ctx.constructor)]),
])
let key: Expression | undefined
let value: Expression | undefined
let valueType: TypeExpression | undefined
if (fieldType.key.kind == 'TLBExprMathType') {
key = tFunctionCall(tMemberExpression(id('Dictionary.Keys'), id('Uint')), [convertToAST(fieldType.key.expr, ctx.constructor)]);
} else {
key = id('hello')
}
if (fieldType.value.kind == 'TLBNumberType') {
value = tFunctionCall(tMemberExpression(id('Dictionary.Values'), id('Uint')), [convertToAST(fieldType.value.bits, ctx.constructor)]);
valueType = id('number')
} else {
value = tFunctionCall(tMemberExpression(id('Dictionary.Values'), id('Cell')), [])
valueType = id('Cell')
}
if (key && value && valueType) {
result.loadExpr = tFunctionCall(tMemberExpression(id(currentSlice), id('loadDict')), [key, value])
result.storeStmtInside = tExpressionStatement(tFunctionCall(tMemberExpression(id(currentCell), id('storeDict')), [tMemberExpression(id(ctx.typeName), id(fieldName)), key, value]))
result.storeStmtOutside = result.storeStmtInside
result.typeParamExpr = tTypeWithParameters(id('Dictionary'), tTypeParametersExpression([id('number'), valueType]))
}
result.storeStmtInside = tExpressionStatement(tFunctionCall(tMemberExpression(id(currentCell), id('storeDict')), [tMemberExpression(id(ctx.typeName), id(fieldName))]))
result.storeStmtOutside = result.storeStmtInside
result.typeParamExpr = tTypeWithParameters(id('Dictionary'), tTypeParametersExpression([id('number'), id('number')]))

} else if (fieldType.kind == "TLBExprMathType") {
result.loadExpr = convertToAST(fieldType.expr, ctx.constructor);
result.storeStmtOutside = tExpressionStatement(result.loadExpr);
Expand Down
Loading

0 comments on commit 6f72a73

Please sign in to comment.