Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyProgrammist committed Dec 2, 2023
1 parent 1128170 commit 81997d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/codegen/combinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ export function handleCombinator(expr: ParserExpression, fieldName: string, isFi
}
result.typeParamExpr = tIdentifier(result.paramType);
}
if (result.argStoreExpr != undefined) {
result.storeExpr = tFunctionCall(tMemberExpression(tIdentifier(currentCell), tIdentifier('store' + result.fieldLoadStoreSuffix)), insideStoreParameters);
}
if (result.argLoadExpr == undefined && result.argStoreExpr != undefined || result.argLoadExpr != undefined && result.argStoreExpr == undefined) {
throw new Error('argLoadExpr and argStoreExpr should be both defined or both undefined')
}
Expand Down
16 changes: 2 additions & 14 deletions src/codegen/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,15 @@ export function handleField(field: FieldDefinition, slicePrefix: Array<number>,
if (field.expr instanceof CombinatorExpr || field.expr instanceof NameExpr || field.expr instanceof BuiltinZeroArgs || field.expr instanceof BuiltinOneArgExpr) {
let tmpTypeName = field.expr.name;
let fieldInfo = handleCombinator(field.expr, field.name, true, variableCombinatorName, variableSubStructName, currentSlice, currentCell, constructor, jsCodeDeclarations, tmpTypeName, 0, tlbCode, subStructLoadProperties);

if (fieldInfo.loadExpr) {
addLoadProperty(field.name, fieldInfo.loadExpr, fieldInfo.typeParamExpr, constructorLoadStatements, subStructLoadProperties);
}

if (fieldInfo.typeParamExpr) {
subStructProperties.push(tTypedIdentifier(tIdentifier(field.name), fieldInfo.typeParamExpr));
}

if (fieldInfo.argLoadExpr == undefined) {
if (fieldInfo.storeExpr) {
subStructStoreStatements.push(tExpressionStatement(fieldInfo.storeExpr))
}
} else if (fieldInfo.argLoadExpr != undefined && fieldInfo.argStoreExpr != undefined) {
let storeParams: Expression[] = [tMemberExpression(tIdentifier(variableCombinatorName), tIdentifier(field.name))];
if (fieldInfo.paramType != 'BitString' && fieldInfo.paramType != 'Slice') {
storeParams.push(fieldInfo.argStoreExpr);
}
subStructStoreStatements.push(tExpressionStatement(tFunctionCall(tMemberExpression(tIdentifier(currentCell), tIdentifier('store' + fieldInfo.fieldLoadStoreSuffix)), storeParams)))
if (fieldInfo.storeExpr) {
subStructStoreStatements.push(tExpressionStatement(fieldInfo.storeExpr))
}

fieldInfo.negatedVariablesLoads.forEach(element => {
addLoadProperty(element.name, element.expression, undefined, constructorLoadStatements, subStructLoadProperties)
});
Expand Down

0 comments on commit 81997d7

Please sign in to comment.