Delete jet.runtime.Ranges intrinsics
All these "rangeTo" methods were pretty small and could be generated just right into "rangeTo" function calls
This commit is contained in:
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.generators.builtins;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GenerateRangeIntrinsics {
|
||||
private static String castIfNecessary(String what, String thisType, String otherType) {
|
||||
if (thisType.equals("byte") && otherType.equals("char") || thisType.equals("char") && otherType.equals("short")) {
|
||||
return "(" + otherType + ") " + what;
|
||||
}
|
||||
return what;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
PrintStream out = new PrintStream(new FileOutputStream("core/runtime.jvm/src/jet/runtime/Ranges.java"));
|
||||
try {
|
||||
String copyright = "injector-generator/copyright.txt";
|
||||
out.println(FileUtil.loadFile(new File(copyright)));
|
||||
|
||||
out.println("package jet.runtime;");
|
||||
out.println();
|
||||
|
||||
out.println("import jet.*;");
|
||||
out.println();
|
||||
|
||||
out.println("/* This file is generated by " + GenerateRangeIntrinsics.class.getName() + ". DO NOT EDIT! */");
|
||||
out.println("public class Ranges {");
|
||||
|
||||
List<String> strings = Arrays.asList("byte", "short", "int", "long", "float", "double", "char");
|
||||
for (String t1 : strings) {
|
||||
for (String t2 : strings) {
|
||||
String resType;
|
||||
if (t1.equals("double") || t2.equals("double")) {
|
||||
resType = "DoubleRange";
|
||||
}
|
||||
else if (t1.equals("float") || t2.equals("float")) {
|
||||
resType = "FloatRange";
|
||||
}
|
||||
else if (t1.equals("long") || t2.equals("long")) {
|
||||
resType = "LongRange";
|
||||
}
|
||||
else if (t1.equals("int") || t2.equals("int")) {
|
||||
resType = "IntRange";
|
||||
}
|
||||
else if (t1.equals("short") || t2.equals("short")) {
|
||||
resType = "ShortRange";
|
||||
}
|
||||
else if (t1.equals("char") || t2.equals("char")) {
|
||||
resType = "CharRange";
|
||||
}
|
||||
else {
|
||||
resType = "ByteRange";
|
||||
}
|
||||
|
||||
out.println(" public static " + resType + " rangeTo(" + t1 + " from, " + t2 + " to) {");
|
||||
out.println(" return new " + resType + "("
|
||||
+ castIfNecessary("from", t1, t2) + ", "
|
||||
+ castIfNecessary("to", t2, t1) + ");");
|
||||
out.println(" }");
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
|
||||
out.println(" public static IntRange arrayIndices(int length) {");
|
||||
out.println(" return new IntRange(0, length - 1);");
|
||||
out.println(" }");
|
||||
out.println();
|
||||
|
||||
out.println(" private Ranges() {}");
|
||||
out.println("}");
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
private GenerateRangeIntrinsics() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user