Skip to content

Commit

Permalink
Simplified intermediate emitting for structures.
Browse files Browse the repository at this point in the history
It is now equivalent to how functions are emitted.
  • Loading branch information
BenediktMagnus committed Mar 9, 2024
1 parent 0eb207f commit 4f6c50e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/transpiler/common/instructions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export { Instruction } from './instruction';
export { FunctionInstruction as Function } from './functionInstruction';
export { LabelInstruction as Label } from './labelInstruction';
export { RenderOptions as RenderOptions } from './renderOptions';
export { StructureInstruction as Structure } from './structureInstruction';
19 changes: 0 additions & 19 deletions src/transpiler/common/instructions/structureInstruction.ts

This file was deleted.

22 changes: 13 additions & 9 deletions src/transpiler/intermediate/transpilerIntermediate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,24 @@ export class TranspilerIntermediate

private transpileStructure (structureIntermediate: Intermediates.Structure): void
{
const fieldStrings: string[] = [];
this.instructions.push(
new Instructions.Instruction(
this.getIntermediateInstructionString(structureIntermediate),
structureIntermediate.symbol.name
),
new Instructions.Instruction('{'),
);

for (const field of structureIntermediate.symbol.fields)
{
const fieldString = `${field.name}: ${field.size}`;
fieldStrings.push(fieldString);
this.instructions.push(
new Instructions.Instruction(`${field.name}:`, `${field.size}`),
);
}

const instruction = new Instructions.Structure(
this.getIntermediateInstructionString(structureIntermediate),
structureIntermediate.symbol.name,
fieldStrings,
this.instructions.push(
new Instructions.Instruction('}'),
);

this.instructions.push(instruction);
}

private transpileFunction (functionIntermediate: Intermediates.Function): void
Expand Down

0 comments on commit 4f6c50e

Please sign in to comment.