public static final int optionsFromScheme(Value value, Value type) { if (value instanceof Symbol) { if (value == CASE_INSENSITIVE) { if (type == REGEX_PERL5) return Perl5Compiler.CASE_INSENSITIVE_MASK; else if (type == REGEX_GLOB) return GlobCompiler.CASE_INSENSITIVE_MASK; else if (type == REGEX_AWK) return AwkCompiler.CASE_INSENSITIVE_MASK; else throw new RuntimeException("Unknown compiler " + type); } else if (value == EXTENDED) { if (type == REGEX_PERL5) return Perl5Compiler.EXTENDED_MASK; else throw new RuntimeException("The extended mask is supported only by Perl5 regexps"); } else if (value == SINGLELINE) { if (type == REGEX_PERL5) return Perl5Compiler.SINGLELINE_MASK; else throw new RuntimeException("The singleline mask is supported only by Perl5 regexps"); } else if (value == MULTILINE) { if (type == REGEX_PERL5) return Perl5Compiler.MULTILINE_MASK; else if (type == REGEX_GLOB) throw new RuntimeException("Glob compiler doesn't support this option: " + value); else if (type == REGEX_AWK) return AwkCompiler.MULTILINE_MASK; } else throw new RuntimeException("Unsupported regexp option " + value); } else if (value instanceof Pair) { int options = 0; Pair pv = (Pair) value; while (pv != EMPTYLIST) { options |= optionsFromScheme(pv.car(), type); pv = (Pair) pv.cdr(); } return options; } else throw new RuntimeException("Invalid format for options " + value); // Not reached, but keeps the Java compiler happy return 0; }
public static void main(String args[]) { Pair p; p = new Pair(2, new Pair(88, null)); System.out.println(p.car()); System.out.println(p.cdr().car()); System.out.println(p.ww); System.out.println(p.yy); System.out.println(p.car); System.out.println(p.cdr.car); System.out.println(p.V4[0]); System.out.println(p.V4[1]); System.out.println(p.V3[0]); System.out.println(p.V3[1]); System.out.println(SpecialPair.w); System.out.println(SpecialPair.x); System.out.println(SpecialPair.V1[0]); System.out.println(SpecialPair.V1.length); System.out.println(A.fa()); A a = new A(); A[] va = new A[2]; System.out.println(a.fb()); System.out.println(a.w); // A strange case, should we generate code for va[0]? // System.out.println(va[0].w); }