vm/src/test/java/org/apidesign/vm4brwsr/StaticMethod.java
branchmodel
changeset 878 ecbd252fd3a7
parent 877 3392f250c784
parent 871 6168fb585ab4
child 879 af170d42b5b3
     1.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethod.java	Fri Mar 22 16:59:47 2013 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,135 +0,0 @@
     1.4 -/**
     1.5 - * Back 2 Browser Bytecode Translator
     1.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     1.7 - *
     1.8 - * This program is free software: you can redistribute it and/or modify
     1.9 - * it under the terms of the GNU General Public License as published by
    1.10 - * the Free Software Foundation, version 2 of the License.
    1.11 - *
    1.12 - * This program is distributed in the hope that it will be useful,
    1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.15 - * GNU General Public License for more details.
    1.16 - *
    1.17 - * You should have received a copy of the GNU General Public License
    1.18 - * along with this program. Look for COPYING file in the top folder.
    1.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
    1.20 - */
    1.21 -package org.apidesign.vm4brwsr;
    1.22 -
    1.23 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
    1.24 -
    1.25 -/**
    1.26 - *
    1.27 - * @author Jaroslav Tulach <jtulach@netbeans.org>
    1.28 - */
    1.29 -public class StaticMethod {
    1.30 -    private static int cnt;
    1.31 -    private static Object NULL;
    1.32 -
    1.33 -    public static int minusOne() {
    1.34 -        return -1;
    1.35 -    }
    1.36 -    
    1.37 -    public static Object none(int x, int y) {
    1.38 -        Object toRet = null;
    1.39 -        for (int i = x; i < y; i++) {
    1.40 -            if (i == 2) {
    1.41 -                toRet = null;
    1.42 -            } else {
    1.43 -                toRet = new Object();
    1.44 -            }
    1.45 -        }
    1.46 -        return toRet;
    1.47 -    }
    1.48 -    
    1.49 -    public static boolean isNull() {
    1.50 -        return NULL == null;
    1.51 -    }
    1.52 -    
    1.53 -    public static int sum(int x, int y) {
    1.54 -        return x + y;
    1.55 -    }
    1.56 -    public static float power(float x) {
    1.57 -        return x * x;
    1.58 -    }
    1.59 -    public static double minus(double x, long y) {
    1.60 -        return x - y;
    1.61 -    }
    1.62 -    public static int div(byte c, double d) {
    1.63 -        return (int)(d / c);
    1.64 -    }
    1.65 -    public static int mix(int a, long b, byte c, double d) {
    1.66 -        return (int)((b / a + c) * d);
    1.67 -    }
    1.68 -    public static long xor(int a, long b) {
    1.69 -        return a ^ b;
    1.70 -    }
    1.71 -    public static long orOrAnd(boolean doOr, int a, int b) {
    1.72 -        return doOr ? a | b : a & b;
    1.73 -    }
    1.74 -    public static int shiftLeft(int what, int much) {
    1.75 -        return what << much;
    1.76 -    }
    1.77 -    public static int shiftArithmRight(int what, int much, boolean signed) {
    1.78 -        if (signed) {
    1.79 -            return what >> much;
    1.80 -        } else {
    1.81 -            return what >>> much;
    1.82 -        }
    1.83 -    }
    1.84 -    public static long factRec(int n) {
    1.85 -        if (n <= 1) {
    1.86 -            return 1;
    1.87 -        } else {
    1.88 -            return n * factRec(n - 1);
    1.89 -        }
    1.90 -    }
    1.91 -    public static long factIter(int n) {
    1.92 -        long res = 1;
    1.93 -        for (int i = 2; i <= n; i++) {
    1.94 -            res *= i;
    1.95 -        }
    1.96 -        return res;
    1.97 -    }
    1.98 -    public static int inc4() {
    1.99 -        cnt++;
   1.100 -        cnt+=2;
   1.101 -        cnt++;
   1.102 -        return cnt;
   1.103 -    }
   1.104 -    
   1.105 -    @JavaScriptBody(
   1.106 -        args={"i","j"}, body="\n\r\treturn (i + j).toString();"
   1.107 -    )
   1.108 -    public static String i2s(int i, int j) {
   1.109 -        throw new IllegalStateException();
   1.110 -    }
   1.111 -    
   1.112 -    public static String castNull(boolean n) {
   1.113 -        Object value = n ? null : "Ahoj";
   1.114 -        return (String)value;
   1.115 -    }
   1.116 -    
   1.117 -    public static String swtch(int what) {
   1.118 -        switch (what) {
   1.119 -            case 0: return "Jarda";
   1.120 -            case 1: return "Darda";
   1.121 -            case 2: return "Parda";
   1.122 -            default: return "Marda";
   1.123 -        }
   1.124 -    }
   1.125 -    public static String swtch2(int what) {
   1.126 -        switch (what) {
   1.127 -            case 0: return "Jarda";
   1.128 -            case 11: return "Darda";
   1.129 -            case 22: return "Parda";
   1.130 -            default: return "Marda";
   1.131 -        }
   1.132 -    }
   1.133 -    
   1.134 -    static {
   1.135 -        // check order of initializers
   1.136 -        StaticUse.NON_NULL.equals(new Object());
   1.137 -    }
   1.138 -}