diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/parser/contexts.h | 36 | ||||
-rw-r--r-- | src/parser/parsers.h | 30 |
2 files changed, 54 insertions, 12 deletions
diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 6505d11a4..4c15c0308 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -2448,9 +2448,21 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> { StringNewOp op, bool try_, Name* mem) { - auto m = getMemory(pos, mem); - CHECK_ERR(m); - return withLoc(pos, irBuilder.makeStringNew(op, try_, *m)); + Name memName; + switch (op) { + case StringNewUTF8: + case StringNewWTF8: + case StringNewLossyUTF8: + case StringNewWTF16: { + auto m = getMemory(pos, mem); + CHECK_ERR(m); + memName = *m; + break; + } + default: + break; + } + return withLoc(pos, irBuilder.makeStringNew(op, try_, memName)); } Result<> makeStringConst(Index pos, @@ -2469,9 +2481,21 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> { const std::vector<Annotation>& annotations, StringEncodeOp op, Name* mem) { - auto m = getMemory(pos, mem); - CHECK_ERR(m); - return withLoc(pos, irBuilder.makeStringEncode(op, *m)); + Name memName; + switch (op) { + case StringEncodeUTF8: + case StringEncodeLossyUTF8: + case StringEncodeWTF8: + case StringEncodeWTF16: { + auto m = getMemory(pos, mem); + CHECK_ERR(m); + memName = *m; + break; + } + default: + break; + } + return withLoc(pos, irBuilder.makeStringEncode(op, memName)); } Result<> makeStringConcat(Index pos, diff --git a/src/parser/parsers.h b/src/parser/parsers.h index 987f0f5aa..4c210624f 100644 --- a/src/parser/parsers.h +++ b/src/parser/parsers.h @@ -2330,9 +2330,18 @@ Result<> makeStringNew(Ctx& ctx, const std::vector<Annotation>& annotations, StringNewOp op, bool try_) { - auto mem = maybeMemidx(ctx); - CHECK_ERR(mem); - return ctx.makeStringNew(pos, annotations, op, try_, mem.getPtr()); + switch (op) { + case StringNewUTF8: + case StringNewWTF8: + case StringNewLossyUTF8: + case StringNewWTF16: { + auto mem = maybeMemidx(ctx); + CHECK_ERR(mem); + return ctx.makeStringNew(pos, annotations, op, try_, mem.getPtr()); + } + default: + return ctx.makeStringNew(pos, annotations, op, try_, nullptr); + } } template<typename Ctx> @@ -2359,9 +2368,18 @@ Result<> makeStringEncode(Ctx& ctx, Index pos, const std::vector<Annotation>& annotations, StringEncodeOp op) { - auto mem = maybeMemidx(ctx); - CHECK_ERR(mem); - return ctx.makeStringEncode(pos, annotations, op, mem.getPtr()); + switch (op) { + case StringEncodeUTF8: + case StringEncodeLossyUTF8: + case StringEncodeWTF8: + case StringEncodeWTF16: { + auto mem = maybeMemidx(ctx); + CHECK_ERR(mem); + return ctx.makeStringEncode(pos, annotations, op, mem.getPtr()); + } + default: + return ctx.makeStringEncode(pos, annotations, op, nullptr); + } } template<typename Ctx> |