From 8e79108e518ae31a8a354f26a998c84ff68f8455 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Mon, 15 Jul 2024 16:34:17 +0300 Subject: [PATCH] * changed twasmreader.HandlePlainInstruction to return an instruction --- compiler/wasm32/rawasmtext.pas | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/compiler/wasm32/rawasmtext.pas b/compiler/wasm32/rawasmtext.pas index d11156295c..22252c76ed 100644 --- a/compiler/wasm32/rawasmtext.pas +++ b/compiler/wasm32/rawasmtext.pas @@ -62,7 +62,7 @@ Unit rawasmtext; function is_valtype(const s: string):boolean; procedure HandleInstruction; procedure HandleFoldedInstruction; - procedure HandlePlainInstruction; + function HandlePlainInstruction: TWasmInstruction; procedure HandleBlockInstruction;virtual;abstract; public function Assemble: tlinkedlist;override; @@ -683,15 +683,14 @@ Unit rawasmtext; end; - procedure twasmreader.HandlePlainInstruction; - var - instr: TWasmInstruction; + function twasmreader.HandlePlainInstruction: TWasmInstruction; begin + result:=nil; case actasmtoken of AS_OPCODE: begin - instr:=TWasmInstruction.create(TWasmOperand); - instr.opcode:=actopcode; + result:=TWasmInstruction.create(TWasmOperand); + result.opcode:=actopcode; Consume(AS_OPCODE); case actopcode of { instructions, which require 0 operands } @@ -759,15 +758,15 @@ Unit rawasmtext; begin if actasmtoken=AS_INTNUM then begin - instr.operands[1].opr.typ:=OPR_CONSTANT; - instr.operands[1].opr.val:=actinttoken; + result.operands[1].opr.typ:=OPR_CONSTANT; + result.operands[1].opr.val:=actinttoken; Consume(AS_INTNUM); end else begin { error: expected integer } - instr.Free; - instr:=nil; + result.Free; + result:=nil; Consume(AS_INTNUM); end; end;