com.carrotsearch.hppc.generator.intrinsics.Add Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hppc-template-processor Show documentation
Show all versions of hppc-template-processor Show documentation
Template Processor and Code Generation for HPPC.
The newest version!
package com.carrotsearch.hppc.generator.intrinsics;
import java.util.ArrayList;
import java.util.Locale;
import java.util.regex.Matcher;
import com.carrotsearch.hppc.generator.TemplateOptions;
import com.carrotsearch.hppc.generator.Type;
public class Add extends AbstractIntrinsicMethod {
@Override
public void invoke(Matcher m, StringBuilder sb, TemplateOptions templateOptions, String genericCast, ArrayList params) {
expectArgumentCount(m, params, 2);
Type type = inferTemplateType(m, templateOptions, genericCast);
if (type.isGeneric()) {
throw new RuntimeException("Can't add generic types: " + m.group());
}
ArrayList newArgs = new ArrayList<>(params);
newArgs.add(type.getType());
sb.append(String.format(Locale.ROOT, "((%3$s) ((%1$s) + (%2$s)))", newArgs.toArray()));
}
}