Skip to content

Commit

Permalink
add readonly tlbvariable
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyProgrammist committed Dec 30, 2023
1 parent 44ce461 commit 2783327
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
12 changes: 0 additions & 12 deletions src/codegen/generators/typescript/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,13 @@ export class TypescriptGenerator implements CodeGenerator {
constructor.variables.forEach((variable) => {
if (variable.negated) {
if (variable.deriveExpr) {
if (variable.name == undefined) {
throw new Error('')
}
subStructLoadProperties.push(tObjectProperty(tIdentifier(variable.name), convertToAST(variable.deriveExpr, constructor)));
}
}
})

constructor.variables.forEach(variable => {
if (variable.type == '#' && !variable.isField) {
if (variable.name == undefined) {
throw new Error('')
}
subStructProperties.push(tTypedIdentifier(tIdentifier(variable.name), tIdentifier('number')));
let parameter = constructor.parametersMap.get(variable.name)
if (parameter && !parameter.variable.isConst && !parameter.variable.negated) {
Expand Down Expand Up @@ -126,9 +120,6 @@ export class TypescriptGenerator implements CodeGenerator {
constructor.parameters.forEach(param => {
if (param.variable.isConst && !param.variable.negated) {
let argName = param.variable.name;
if (argName == undefined) {
throw new Error('')
}
if (param.argName) {
argName = param.argName
}
Expand Down Expand Up @@ -178,9 +169,6 @@ export class TypescriptGenerator implements CodeGenerator {
let anyConstructor = tlbType.constructors[0];
if (anyConstructor) {
anyConstructor.parameters.forEach(element => {
if (element.variable.name == undefined) {
throw new Error('')
}
if (element.variable.type == 'Type') {
loadFunctionParameters.push(tTypedIdentifier(tIdentifier('load' + element.variable.name), tArrowFunctionType([tTypedIdentifier(tIdentifier('slice'), tIdentifier('Slice'))], tIdentifier(element.variable.name))))

Expand Down
9 changes: 1 addition & 8 deletions src/codegen/generators/typescript/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ export function getNegationDerivationFunctionBody(tlbCode: TLBCodeNew, typeName:
tlbType.constructors.forEach(constructor => {
let parameter = constructor.parameters[parameterIndex];
if (parameter) {
if (parameter.variable.name == undefined) {
throw new Error('')
}
let getExpression: Expression;
getExpression = convertToAST(parameter.paramExpr, constructor);
let statements = [];
Expand Down Expand Up @@ -116,14 +113,10 @@ export function convertToAST(mathExpr: TLBMathExpr, constructor: TLBConstructorN
throw new Error(`Type ${constructor.tlbType}, constructor ${constructor.name}: couldn't convert to math expression: ${mathExpr}`)
}

export function getTypeParametersExpression(parameters: Array<TLBParameterNew> | Array<TLBParameter>) {
export function getTypeParametersExpression(parameters: Array<TLBParameterNew>) {
let structTypeParameters: Array<Identifier> = [];
parameters.forEach(element => {
if (element.variable.type == 'Type') {
if (element.variable.name == undefined) {
throw new Error('')
}

structTypeParameters.push(tIdentifier(element.variable.name));
}
});
Expand Down

0 comments on commit 2783327

Please sign in to comment.