diff options
author | Piotr Fusik <piotr@fusion-lang.org> | 2024-02-26 18:31:17 +0100 |
---|---|---|
committer | Piotr Fusik <piotr@fusion-lang.org> | 2024-02-26 19:55:14 +0100 |
commit | 99c95da914860466196c997fe6b932ca722c45d3 (patch) | |
tree | f47fe2d574b3dfb8c3d457e45eeab08a221789b6 | |
parent | 9107a5ccdb428d5a7dcc619adb23388efc729372 (diff) |
[cleanup] Refactor string.Substring.
-rw-r--r-- | GenC.fu | 20 | ||||
-rw-r--r-- | GenCCpp.fu | 19 | ||||
-rw-r--r-- | GenCl.fu | 5 | ||||
-rw-r--r-- | GenCpp.fu | 19 | ||||
-rw-r--r-- | libfut.cpp | 69 | ||||
-rw-r--r-- | libfut.cs | 57 | ||||
-rw-r--r-- | libfut.hpp | 7 | ||||
-rw-r--r-- | libfut.js | 75 |
8 files changed, 126 insertions, 145 deletions
@@ -118,11 +118,15 @@ public class GenC : GenCCpp WriteTemporaryOrExpr(expr, FuPriority.Argument); } - void WriteStringPtrAddCast!(FuCallExpr call) + void WriteStringPtrAdd!(FuExpr? obj, bool utf8GetString, List<FuExpr#> args, bool cast) { - if (IsUTF8GetString(call)) - Write("(const char *) "); - WriteStringPtrAdd(call); + if (utf8GetString) { + if (cast) + Write("(const char *) "); + WriteArrayPtrAdd(args[0], args[1]); + } + else + WriteArrayPtrAdd(obj, args[0]); } static bool IsDictionaryClassStgIndexing(FuExpr expr) @@ -180,7 +184,7 @@ public class GenC : GenCCpp if (call != null) { GetStringSubstringLength(call).Accept(this, FuPriority.Argument); Write(", "); - WriteStringPtrAddCast(call); + WriteStringPtrAdd(call.Method.Left, IsUTF8GetString(call), call.Arguments, true); } else if (expr.Type is FuClassType klass && klass.Class.Id != FuId.StringClass) { // TODO: abstract, virtual, override @@ -773,6 +777,8 @@ public class GenC : GenCCpp WriteChar(')'); } + static FuExpr GetStringSubstringLength(FuCallExpr call) => call.Arguments[IsUTF8GetString(call) ? 2 : 1]; + void WriteStringStorageValue!(FuExpr expr) { FuCallExpr? call = IsStringSubstring(expr); @@ -780,7 +786,7 @@ public class GenC : GenCCpp Include("string.h"); this.StringSubstring = true; Write("FuString_Substring("); - WriteStringPtrAddCast(call); + WriteStringPtrAdd(call.Method.Left, IsUTF8GetString(call), call.Arguments, true); Write(", "); GetStringSubstringLength(call).Accept(this, FuPriority.Argument); WriteChar(')'); @@ -1572,7 +1578,7 @@ public class GenC : GenCCpp WriteChar('('); Include("string.h"); Write("memcmp("); - WriteStringPtrAdd(call); + WriteStringPtrAdd(call.Method.Left, IsUTF8GetString(call), call.Arguments, false); Write(", "); VisitLiteralString(literal); Write(", "); @@ -1,6 +1,6 @@ // GenCCpp.fu - C/C++ code generator // -// Copyright (C) 2011-2023 Piotr Fusik +// Copyright (C) 2011-2024 Piotr Fusik // // This file is part of Fusion Transpiler, // see https://github.com/fusionlanguage/fut @@ -154,25 +154,14 @@ public abstract class GenCCpp : GenCCppD protected static bool IsUTF8GetString(FuCallExpr call) => call.Method.Symbol.Id == FuId.UTF8GetString; - protected static FuExpr GetStringSubstringPtr(FuCallExpr call) => IsUTF8GetString(call) ? call.Arguments[0] : call.Method.Left; - - protected static FuExpr GetStringSubstringOffset(FuCallExpr call) => call.Arguments[IsUTF8GetString(call) ? 1 : 0]; - - protected static FuExpr GetStringSubstringLength(FuCallExpr call) => call.Arguments[IsUTF8GetString(call) ? 2 : 1]; - - protected void WriteStringPtrAdd!(FuCallExpr call) - { - WriteArrayPtrAdd(GetStringSubstringPtr(call), GetStringSubstringOffset(call)); - } - protected static FuExpr? IsTrimSubstring(FuBinaryExpr expr) { FuCallExpr? call = IsStringSubstring(expr.Right); if (call != null && !IsUTF8GetString(call) - && expr.Left is FuSymbolReference leftSymbol && GetStringSubstringPtr(call).IsReferenceTo(leftSymbol.Symbol) // TODO: more complex expr - && GetStringSubstringOffset(call).IsLiteralZero()) - return GetStringSubstringLength(call); + && expr.Left is FuSymbolReference leftSymbol && call.Method.Left.IsReferenceTo(leftSymbol.Symbol) // TODO: more complex expr + && call.Arguments[0].IsLiteralZero()) + return call.Arguments[1]; return null; } @@ -1,6 +1,6 @@ // GenCl.fu - OpenCL C code generator // -// Copyright (C) 2020-2023 Piotr Fusik +// Copyright (C) 2020-2024 Piotr Fusik // // This file is part of Fusion Transpiler, // see https://github.com/fusionlanguage/fut @@ -133,12 +133,13 @@ public class GenCl : GenC if (IsUTF8GetString(call)) { this.BytesEqualsString = true; Write("FuBytes_Equals("); + WriteArrayPtrAdd(call.Arguments[0], call.Arguments[1]); } else { this.StringStartsWith = true; Write("FuString_StartsWith("); + WriteArrayPtrAdd(call.Method.Left, call.Arguments[0]); } - WriteStringPtrAdd(call); Write(", "); VisitLiteralString(literal); WriteChar(')'); @@ -1578,16 +1578,19 @@ public class GenCpp : GenCCpp FuCallExpr? call = IsStringSubstring(expr); if (call != null && type.Id == FuId.StringStorageType - && GetStringSubstringPtr(call).Type.Id != FuId.StringStorageType) { + && (IsUTF8GetString(call) ? call.Arguments[0] : call.Method.Left).Type.Id != FuId.StringStorageType) { Write("std::string("); - bool cast = IsUTF8GetString(call); - if (cast) + if (IsUTF8GetString(call)) { Write("reinterpret_cast<const char *>("); - WriteStringPtrAdd(call); - if (cast) - WriteChar(')'); - Write(", "); - GetStringSubstringLength(call).Accept(this, FuPriority.Argument); + WriteArrayPtrAdd(call.Arguments[0], call.Arguments[1]); + Write("), "); + call.Arguments[2].Accept(this, FuPriority.Argument); + } + else { + WriteArrayPtrAdd(call.Method.Left, call.Arguments[0]); + Write(", "); + call.Arguments[1].Accept(this, FuPriority.Argument); + } WriteChar(')'); } else @@ -8913,32 +8913,12 @@ bool GenCCpp::isUTF8GetString(const FuCallExpr * call) return call->method->symbol->id == FuId::uTF8GetString; } -const FuExpr * GenCCpp::getStringSubstringPtr(const FuCallExpr * call) -{ - return isUTF8GetString(call) ? call->arguments[0].get() : call->method->left.get(); -} - -const FuExpr * GenCCpp::getStringSubstringOffset(const FuCallExpr * call) -{ - return call->arguments[isUTF8GetString(call) ? 1 : 0].get(); -} - -const FuExpr * GenCCpp::getStringSubstringLength(const FuCallExpr * call) -{ - return call->arguments[isUTF8GetString(call) ? 2 : 1].get(); -} - -void GenCCpp::writeStringPtrAdd(const FuCallExpr * call) -{ - writeArrayPtrAdd(getStringSubstringPtr(call), getStringSubstringOffset(call)); -} - const FuExpr * GenCCpp::isTrimSubstring(const FuBinaryExpr * expr) { const FuCallExpr * call = isStringSubstring(expr->right.get()); const FuSymbolReference * leftSymbol; - if (call != nullptr && !isUTF8GetString(call) && (leftSymbol = dynamic_cast<const FuSymbolReference *>(expr->left.get())) && getStringSubstringPtr(call)->isReferenceTo(leftSymbol->symbol) && getStringSubstringOffset(call)->isLiteralZero()) - return getStringSubstringLength(call); + if (call != nullptr && !isUTF8GetString(call) && (leftSymbol = dynamic_cast<const FuSymbolReference *>(expr->left.get())) && call->method->left->isReferenceTo(leftSymbol->symbol) && call->arguments[0]->isLiteralZero()) + return call->arguments[1].get(); return nullptr; } @@ -9139,11 +9119,15 @@ void GenC::writeInterpolatedStringArgBase(const FuExpr * expr) writeTemporaryOrExpr(expr, FuPriority::argument); } -void GenC::writeStringPtrAddCast(const FuCallExpr * call) +void GenC::writeStringPtrAdd(const FuExpr * obj, bool utf8GetString, const std::vector<std::shared_ptr<FuExpr>> * args, bool cast) { - if (isUTF8GetString(call)) - write("(const char *) "); - writeStringPtrAdd(call); + if (utf8GetString) { + if (cast) + write("(const char *) "); + writeArrayPtrAdd((*args)[0].get(), (*args)[1].get()); + } + else + writeArrayPtrAdd(obj, (*args)[0].get()); } bool GenC::isDictionaryClassStgIndexing(const FuExpr * expr) @@ -9197,7 +9181,7 @@ void GenC::writeInterpolatedStringArg(const FuExpr * expr) if (call != nullptr) { getStringSubstringLength(call)->accept(this, FuPriority::argument); write(", "); - writeStringPtrAddCast(call); + writeStringPtrAdd(call->method->left.get(), isUTF8GetString(call), &call->arguments, true); } else { const FuClassType * klass; @@ -9732,6 +9716,11 @@ void GenC::writeNewArray(const FuType * elementType, const FuExpr * lengthExpr, writeChar(')'); } +const FuExpr * GenC::getStringSubstringLength(const FuCallExpr * call) +{ + return call->arguments[isUTF8GetString(call) ? 2 : 1].get(); +} + void GenC::writeStringStorageValue(const FuExpr * expr) { const FuCallExpr * call = isStringSubstring(expr); @@ -9739,7 +9728,7 @@ void GenC::writeStringStorageValue(const FuExpr * expr) include("string.h"); this->stringSubstring = true; write("FuString_Substring("); - writeStringPtrAddCast(call); + writeStringPtrAdd(call->method->left.get(), isUTF8GetString(call), &call->arguments, true); write(", "); getStringSubstringLength(call)->accept(this, FuPriority::argument); writeChar(')'); @@ -10512,7 +10501,7 @@ void GenC::writeSubstringEqual(const FuCallExpr * call, std::string_view literal writeChar('('); include("string.h"); write("memcmp("); - writeStringPtrAdd(call); + writeStringPtrAdd(call->method->left.get(), isUTF8GetString(call), &call->arguments, false); write(", "); visitLiteralString(literal); write(", "); @@ -12856,12 +12845,13 @@ void GenCl::writeSubstringEqual(const FuCallExpr * call, std::string_view litera if (isUTF8GetString(call)) { this->bytesEqualsString = true; write("FuBytes_Equals("); + writeArrayPtrAdd(call->arguments[0].get(), call->arguments[1].get()); } else { this->stringStartsWith = true; write("FuString_StartsWith("); + writeArrayPtrAdd(call->method->left.get(), call->arguments[0].get()); } - writeStringPtrAdd(call); write(", "); visitLiteralString(literal); writeChar(')'); @@ -14544,16 +14534,19 @@ void GenCpp::writeStronglyCoerced(const FuType * type, const FuExpr * expr) } else { const FuCallExpr * call = isStringSubstring(expr); - if (call != nullptr && type->id == FuId::stringStorageType && getStringSubstringPtr(call)->type->id != FuId::stringStorageType) { + if (call != nullptr && type->id == FuId::stringStorageType && (isUTF8GetString(call) ? call->arguments[0] : call->method->left)->type->id != FuId::stringStorageType) { write("std::string("); - bool cast = isUTF8GetString(call); - if (cast) + if (isUTF8GetString(call)) { write("reinterpret_cast<const char *>("); - writeStringPtrAdd(call); - if (cast) - writeChar(')'); - write(", "); - getStringSubstringLength(call)->accept(this, FuPriority::argument); + writeArrayPtrAdd(call->arguments[0].get(), call->arguments[1].get()); + write("), "); + call->arguments[2]->accept(this, FuPriority::argument); + } + else { + writeArrayPtrAdd(call->method->left.get(), call->arguments[0].get()); + write(", "); + call->arguments[1]->accept(this, FuPriority::argument); + } writeChar(')'); } else @@ -9091,22 +9091,11 @@ namespace Fusion protected static bool IsUTF8GetString(FuCallExpr call) => call.Method.Symbol.Id == FuId.UTF8GetString; - protected static FuExpr GetStringSubstringPtr(FuCallExpr call) => IsUTF8GetString(call) ? call.Arguments[0] : call.Method.Left; - - protected static FuExpr GetStringSubstringOffset(FuCallExpr call) => call.Arguments[IsUTF8GetString(call) ? 1 : 0]; - - protected static FuExpr GetStringSubstringLength(FuCallExpr call) => call.Arguments[IsUTF8GetString(call) ? 2 : 1]; - - protected void WriteStringPtrAdd(FuCallExpr call) - { - WriteArrayPtrAdd(GetStringSubstringPtr(call), GetStringSubstringOffset(call)); - } - protected static FuExpr IsTrimSubstring(FuBinaryExpr expr) { FuCallExpr call = IsStringSubstring(expr.Right); - if (call != null && !IsUTF8GetString(call) && expr.Left is FuSymbolReference leftSymbol && GetStringSubstringPtr(call).IsReferenceTo(leftSymbol.Symbol) && GetStringSubstringOffset(call).IsLiteralZero()) - return GetStringSubstringLength(call); + if (call != null && !IsUTF8GetString(call) && expr.Left is FuSymbolReference leftSymbol && call.Method.Left.IsReferenceTo(leftSymbol.Symbol) && call.Arguments[0].IsLiteralZero()) + return call.Arguments[1]; return null; } @@ -9355,11 +9344,15 @@ namespace Fusion WriteTemporaryOrExpr(expr, FuPriority.Argument); } - void WriteStringPtrAddCast(FuCallExpr call) + void WriteStringPtrAdd(FuExpr obj, bool utf8GetString, List<FuExpr> args, bool cast) { - if (IsUTF8GetString(call)) - Write("(const char *) "); - WriteStringPtrAdd(call); + if (utf8GetString) { + if (cast) + Write("(const char *) "); + WriteArrayPtrAdd(args[0], args[1]); + } + else + WriteArrayPtrAdd(obj, args[0]); } static bool IsDictionaryClassStgIndexing(FuExpr expr) @@ -9412,7 +9405,7 @@ namespace Fusion if (call != null) { GetStringSubstringLength(call).Accept(this, FuPriority.Argument); Write(", "); - WriteStringPtrAddCast(call); + WriteStringPtrAdd(call.Method.Left, IsUTF8GetString(call), call.Arguments, true); } else if (expr.Type is FuClassType klass && klass.Class.Id != FuId.StringClass) { Write(this.Namespace); @@ -10003,6 +9996,8 @@ namespace Fusion WriteChar(')'); } + static FuExpr GetStringSubstringLength(FuCallExpr call) => call.Arguments[IsUTF8GetString(call) ? 2 : 1]; + void WriteStringStorageValue(FuExpr expr) { FuCallExpr call = IsStringSubstring(expr); @@ -10010,7 +10005,7 @@ namespace Fusion Include("string.h"); this.StringSubstring = true; Write("FuString_Substring("); - WriteStringPtrAddCast(call); + WriteStringPtrAdd(call.Method.Left, IsUTF8GetString(call), call.Arguments, true); Write(", "); GetStringSubstringLength(call).Accept(this, FuPriority.Argument); WriteChar(')'); @@ -10787,7 +10782,7 @@ namespace Fusion WriteChar('('); Include("string.h"); Write("memcmp("); - WriteStringPtrAdd(call); + WriteStringPtrAdd(call.Method.Left, IsUTF8GetString(call), call.Arguments, false); Write(", "); VisitLiteralString(literal); Write(", "); @@ -13110,12 +13105,13 @@ namespace Fusion if (IsUTF8GetString(call)) { this.BytesEqualsString = true; Write("FuBytes_Equals("); + WriteArrayPtrAdd(call.Arguments[0], call.Arguments[1]); } else { this.StringStartsWith = true; Write("FuString_StartsWith("); + WriteArrayPtrAdd(call.Method.Left, call.Arguments[0]); } - WriteStringPtrAdd(call); Write(", "); VisitLiteralString(literal); WriteChar(')'); @@ -14891,16 +14887,19 @@ namespace Fusion } else { FuCallExpr call = IsStringSubstring(expr); - if (call != null && type.Id == FuId.StringStorageType && GetStringSubstringPtr(call).Type.Id != FuId.StringStorageType) { + if (call != null && type.Id == FuId.StringStorageType && (IsUTF8GetString(call) ? call.Arguments[0] : call.Method.Left).Type.Id != FuId.StringStorageType) { Write("std::string("); - bool cast = IsUTF8GetString(call); - if (cast) + if (IsUTF8GetString(call)) { Write("reinterpret_cast<const char *>("); - WriteStringPtrAdd(call); - if (cast) - WriteChar(')'); - Write(", "); - GetStringSubstringLength(call).Accept(this, FuPriority.Argument); + WriteArrayPtrAdd(call.Arguments[0], call.Arguments[1]); + Write("), "); + call.Arguments[2].Accept(this, FuPriority.Argument); + } + else { + WriteArrayPtrAdd(call.Method.Left, call.Arguments[0]); + Write(", "); + call.Arguments[1].Accept(this, FuPriority.Argument); + } WriteChar(')'); } else @@ -2012,10 +2012,6 @@ protected: void writeArrayPtrAdd(const FuExpr * array, const FuExpr * index); static const FuCallExpr * isStringSubstring(const FuExpr * expr); static bool isUTF8GetString(const FuCallExpr * call); - static const FuExpr * getStringSubstringPtr(const FuCallExpr * call); - static const FuExpr * getStringSubstringOffset(const FuCallExpr * call); - static const FuExpr * getStringSubstringLength(const FuCallExpr * call); - void writeStringPtrAdd(const FuCallExpr * call); static const FuExpr * isTrimSubstring(const FuBinaryExpr * expr); void writeStringLiteralWithNewLine(std::string_view s); virtual void writeUnreachable(const FuAssert * statement); @@ -2141,7 +2137,7 @@ private: std::set<FuId> compares; std::set<FuId> contains; std::vector<const FuVar *> varsToDestruct; - void writeStringPtrAddCast(const FuCallExpr * call); + void writeStringPtrAdd(const FuExpr * obj, bool utf8GetString, const std::vector<std::shared_ptr<FuExpr>> * args, bool cast); static bool isDictionaryClassStgIndexing(const FuExpr * expr); void writeTemporaryOrExpr(const FuExpr * expr, FuPriority parent); void writeUpcast(const FuClass * resultClass, const FuSymbol * klass); @@ -2164,6 +2160,7 @@ private: void writeListFreeName(FuId id); void addListFree(FuId id); void writeListFree(const FuClassType * elementType); + static const FuExpr * getStringSubstringLength(const FuCallExpr * call); void writeStringStorageValue(const FuExpr * expr); bool writeDestructMethodName(const FuClassType * klass); static bool hasDictionaryDestroy(const FuType * type); @@ -9434,32 +9434,12 @@ export class GenCCpp extends GenCCppD return call.method.symbol.id == FuId.U_T_F8_GET_STRING; } - static getStringSubstringPtr(call) - { - return GenCCpp.isUTF8GetString(call) ? call.arguments_[0] : call.method.left; - } - - static getStringSubstringOffset(call) - { - return call.arguments_[GenCCpp.isUTF8GetString(call) ? 1 : 0]; - } - - static getStringSubstringLength(call) - { - return call.arguments_[GenCCpp.isUTF8GetString(call) ? 2 : 1]; - } - - writeStringPtrAdd(call) - { - this.writeArrayPtrAdd(GenCCpp.getStringSubstringPtr(call), GenCCpp.getStringSubstringOffset(call)); - } - static isTrimSubstring(expr) { let call = GenCCpp.isStringSubstring(expr.right); let leftSymbol; - if (call != null && !GenCCpp.isUTF8GetString(call) && (leftSymbol = expr.left) instanceof FuSymbolReference && GenCCpp.getStringSubstringPtr(call).isReferenceTo(leftSymbol.symbol) && GenCCpp.getStringSubstringOffset(call).isLiteralZero()) - return GenCCpp.getStringSubstringLength(call); + if (call != null && !GenCCpp.isUTF8GetString(call) && (leftSymbol = expr.left) instanceof FuSymbolReference && call.method.left.isReferenceTo(leftSymbol.symbol) && call.arguments_[0].isLiteralZero()) + return call.arguments_[1]; return null; } @@ -9690,11 +9670,15 @@ export class GenC extends GenCCpp this.#writeTemporaryOrExpr(expr, FuPriority.ARGUMENT); } - #writeStringPtrAddCast(call) + #writeStringPtrAdd(obj, utf8GetString, args, cast) { - if (GenC.isUTF8GetString(call)) - this.write("(const char *) "); - this.writeStringPtrAdd(call); + if (utf8GetString) { + if (cast) + this.write("(const char *) "); + this.writeArrayPtrAdd(args[0], args[1]); + } + else + this.writeArrayPtrAdd(obj, args[0]); } static #isDictionaryClassStgIndexing(expr) @@ -9746,9 +9730,9 @@ export class GenC extends GenCCpp { let call = GenC.isStringSubstring(expr); if (call != null) { - GenC.getStringSubstringLength(call).accept(this, FuPriority.ARGUMENT); + GenC.#getStringSubstringLength(call).accept(this, FuPriority.ARGUMENT); this.write(", "); - this.#writeStringPtrAddCast(call); + this.#writeStringPtrAdd(call.method.left, GenC.isUTF8GetString(call), call.arguments_, true); } else { let klass; @@ -10354,6 +10338,11 @@ export class GenC extends GenCCpp this.writeChar(41); } + static #getStringSubstringLength(call) + { + return call.arguments_[GenC.isUTF8GetString(call) ? 2 : 1]; + } + #writeStringStorageValue(expr) { let call = GenC.isStringSubstring(expr); @@ -10361,9 +10350,9 @@ export class GenC extends GenCCpp this.include("string.h"); this.#stringSubstring = true; this.write("FuString_Substring("); - this.#writeStringPtrAddCast(call); + this.#writeStringPtrAdd(call.method.left, GenC.isUTF8GetString(call), call.arguments_, true); this.write(", "); - GenC.getStringSubstringLength(call).accept(this, FuPriority.ARGUMENT); + GenC.#getStringSubstringLength(call).accept(this, FuPriority.ARGUMENT); this.writeChar(41); } else if (expr.isNewString(false)) @@ -11168,7 +11157,7 @@ export class GenC extends GenCCpp this.writeChar(40); this.include("string.h"); this.write("memcmp("); - this.writeStringPtrAdd(call); + this.#writeStringPtrAdd(call.method.left, GenC.isUTF8GetString(call), call.arguments_, false); this.write(", "); this.visitLiteralString(literal); this.write(", "); @@ -11202,7 +11191,7 @@ export class GenC extends GenCCpp let call = GenC.isStringSubstring(left); let literal; if (call != null && (literal = right) instanceof FuLiteralString) { - let lengthExpr = GenC.getStringSubstringLength(call); + let lengthExpr = GenC.#getStringSubstringLength(call); let rightLength = literal.getAsciiLength(); if (rightLength >= 0) { let rightValue = literal.value; @@ -13534,12 +13523,13 @@ export class GenCl extends GenC if (GenCl.isUTF8GetString(call)) { this.#bytesEqualsString = true; this.write("FuBytes_Equals("); + this.writeArrayPtrAdd(call.arguments_[0], call.arguments_[1]); } else { this.#stringStartsWith = true; this.write("FuString_StartsWith("); + this.writeArrayPtrAdd(call.method.left, call.arguments_[0]); } - this.writeStringPtrAdd(call); this.write(", "); this.visitLiteralString(literal); this.writeChar(41); @@ -15325,16 +15315,19 @@ export class GenCpp extends GenCCpp } else { let call = GenCpp.isStringSubstring(expr); - if (call != null && type.id == FuId.STRING_STORAGE_TYPE && GenCpp.getStringSubstringPtr(call).type.id != FuId.STRING_STORAGE_TYPE) { + if (call != null && type.id == FuId.STRING_STORAGE_TYPE && (GenCpp.isUTF8GetString(call) ? call.arguments_[0] : call.method.left).type.id != FuId.STRING_STORAGE_TYPE) { this.write("std::string("); - let cast = GenCpp.isUTF8GetString(call); - if (cast) + if (GenCpp.isUTF8GetString(call)) { this.write("reinterpret_cast<const char *>("); - this.writeStringPtrAdd(call); - if (cast) - this.writeChar(41); - this.write(", "); - GenCpp.getStringSubstringLength(call).accept(this, FuPriority.ARGUMENT); + this.writeArrayPtrAdd(call.arguments_[0], call.arguments_[1]); + this.write("), "); + call.arguments_[2].accept(this, FuPriority.ARGUMENT); + } + else { + this.writeArrayPtrAdd(call.method.left, call.arguments_[0]); + this.write(", "); + call.arguments_[1].accept(this, FuPriority.ARGUMENT); + } this.writeChar(41); } else |