From d739b61fb1d210a42749aa8d186718bed17c90c4 Mon Sep 17 00:00:00 2001 From: Aman Goel Date: Tue, 7 May 2024 23:28:21 +0000 Subject: [PATCH] [PEx] Minor corrections to IR --- .../Backend/PExplicit/PExplicitCodeGenerator.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Src/PCompiler/CompilerCore/Backend/PExplicit/PExplicitCodeGenerator.cs b/Src/PCompiler/CompilerCore/Backend/PExplicit/PExplicitCodeGenerator.cs index 748c0fc77..0ac3aef8e 100644 --- a/Src/PCompiler/CompilerCore/Backend/PExplicit/PExplicitCodeGenerator.cs +++ b/Src/PCompiler/CompilerCore/Backend/PExplicit/PExplicitCodeGenerator.cs @@ -1645,26 +1645,29 @@ private void WriteExpr(CompilationContext context, StringWriter output, IPExpr e context.Write(output, $".getValues()"); break; case MapAccessExpr mapAccessExpr: + context.Write(output, $"(({GetPExplicitType(mapAccessExpr.MapExpr.Type)})"); WriteExpr(context, output, mapAccessExpr.MapExpr); - context.Write(output, ".get("); + context.Write(output, ").get("); WriteExpr(context, output, mapAccessExpr.IndexExpr); context.Write(output, ")"); break; case SeqAccessExpr seqAccessExpr: + context.Write(output, $"(({GetPExplicitType(seqAccessExpr.SeqExpr.Type)})"); WriteExpr(context, output, seqAccessExpr.SeqExpr); - context.Write(output, ".get("); + context.Write(output, ").get("); WriteExpr(context, output, seqAccessExpr.IndexExpr); context.Write(output, ")"); break; case SetAccessExpr setAccessExpr: + context.Write(output, $"(({GetPExplicitType(setAccessExpr.SetExpr.Type)})"); WriteExpr(context, output, setAccessExpr.SetExpr); - context.Write(output, ".get("); + context.Write(output, ").get("); WriteExpr(context, output, setAccessExpr.IndexExpr); context.Write(output, ")"); break; case NamedTupleAccessExpr namedTupleAccessExpr: context.Write(output, $"(({GetPExplicitType(namedTupleAccessExpr.Type)})("); - context.Write(output, "("); + context.Write(output, $"(({GetPExplicitType(namedTupleAccessExpr.SubExpr.Type)})"); WriteExpr(context, output, namedTupleAccessExpr.SubExpr); context.Write(output, $").getField(\"{namedTupleAccessExpr.FieldName}\")))"); break; @@ -1674,7 +1677,7 @@ private void WriteExpr(CompilationContext context, StringWriter output, IPExpr e case TupleAccessExpr tupleAccessExpr: context.Write(output, $"({GetPExplicitType(tupleAccessExpr.Type)})("); var tupleType = (tupleAccessExpr.SubExpr.Type.Canonicalize() as TupleType); - context.Write(output, "("); + context.Write(output, $"(({GetPExplicitType(tupleAccessExpr.SubExpr.Type)})"); WriteExpr(context, output, tupleAccessExpr.SubExpr); context.Write(output, $").getField({tupleAccessExpr.FieldNo}))"); break;