コード例 #1
0
ファイル: WyilFileReader.java プロジェクト: ejrh/Whiley
 private Code readBinaryAssign(int opcode, boolean wideBase, boolean wideRest) throws IOException {
   int target = readBase(wideBase);
   int leftOperand = readBase(wideBase);
   int rightOperand = readBase(wideBase);
   int typeIdx = readRest(wideRest);
   Type type = typePool[typeIdx];
   switch (opcode) {
     case Code.OPCODE_append:
     case Code.OPCODE_appendl:
     case Code.OPCODE_appendr:
       {
         if (!(type instanceof Type.EffectiveList)) {
           throw new RuntimeException("expecting list type");
         }
         Code.BinListKind kind = Code.BinListKind.values()[opcode - Code.OPCODE_append];
         return Code.BinListOp((Type.EffectiveList) type, target, leftOperand, rightOperand, kind);
       }
     case Code.OPCODE_sappend:
     case Code.OPCODE_sappendl:
     case Code.OPCODE_sappendr:
       {
         if (!(type instanceof Type.Strung)) {
           throw new RuntimeException("expecting string type");
         }
         Code.BinStringKind kind = Code.BinStringKind.values()[opcode - Code.OPCODE_sappend];
         return Code.BinStringOp(target, leftOperand, rightOperand, kind);
       }
     case Code.OPCODE_indexof:
       {
         if (!(type instanceof Type.EffectiveIndexible)) {
           throw new RuntimeException("expecting indexible type");
         }
         return Code.IndexOf((Type.EffectiveIndexible) type, target, leftOperand, rightOperand);
       }
     case Code.OPCODE_add:
     case Code.OPCODE_sub:
     case Code.OPCODE_mul:
     case Code.OPCODE_div:
     case Code.OPCODE_rem:
     case Code.OPCODE_range:
     case Code.OPCODE_bitwiseor:
     case Code.OPCODE_bitwisexor:
     case Code.OPCODE_bitwiseand:
     case Code.OPCODE_lshr:
     case Code.OPCODE_rshr:
       {
         Code.BinArithKind kind = Code.BinArithKind.values()[opcode - Code.OPCODE_add];
         return Code.BinArithOp(type, target, leftOperand, rightOperand, kind);
       }
     case Code.OPCODE_union:
     case Code.OPCODE_unionl:
     case Code.OPCODE_unionr:
     case Code.OPCODE_intersect:
     case Code.OPCODE_intersectl:
     case Code.OPCODE_intersectr:
     case Code.OPCODE_difference:
     case Code.OPCODE_differencel:
       {
         if (!(type instanceof Type.EffectiveSet)) {
           throw new RuntimeException("expecting set type");
         }
         Code.BinSetKind kind = Code.BinSetKind.values()[opcode - Code.OPCODE_union];
         return Code.BinSetOp((Type.EffectiveSet) type, target, leftOperand, rightOperand, kind);
       }
   }
   throw new RuntimeException("unknown opcode encountered (" + opcode + ")");
 }