package org.simantics.scl.compiler.constants; import java.util.Arrays; import org.cojen.classfile.TypeDesc; import org.objectweb.asm.Label; import org.objectweb.asm.Opcodes; import org.simantics.scl.compiler.common.exceptions.InternalCompilerError; import org.simantics.scl.compiler.internal.codegen.continuations.Cont; import org.simantics.scl.compiler.internal.codegen.references.IVal; import org.simantics.scl.compiler.internal.codegen.references.Val; import org.simantics.scl.compiler.internal.codegen.utils.Constants; import org.simantics.scl.compiler.internal.codegen.utils.LocalVariable; import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder; import org.simantics.scl.compiler.types.TVar; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; public class StringInterpolation extends FunctionValue { public static final TypeDesc STRING_BUILDER = TypeDesc.forClass(StringBuilder.class); private final String[] textParts; public StringInterpolation(Type[] parameterTypes, String[] textParts) { super(TVar.EMPTY_ARRAY, Types.NO_EFFECTS, Types.STRING, parameterTypes); this.textParts = textParts; } public StringInterpolation(String[] textParts) { this(stringTypeArray(textParts.length-1), textParts); } @Override public String toString() { StringBuilder b = new StringBuilder(); b.append('"'); boolean first = true; for(String textPart : textParts) { if(first) first = false; else b.append("\\(.)"); b.append(textPart); } b.append('"'); return b.toString(); } private static Type[] stringTypeArray(int length) { Type[] result = new Type[length]; for(int i=0;i