src/Opcodes.h
changeset 172 48cffae8c9e0
parent 86 32ad0523b309
child 195 c1ba166f3fc4
     1.1 --- a/src/Opcodes.h	Sun Aug 12 13:22:56 2012 -0700
     1.2 +++ b/src/Opcodes.h	Sun Aug 12 20:48:49 2012 -0700
     1.3 @@ -1,19 +1,20 @@
     1.4 -/*
     1.5 +/* vim: set ts=4 sw=4 tw=99 et:
     1.6 + *
     1.7   * Copyright (C) 2012 David Anderson
     1.8   *
     1.9 - * This file is part of JITCraft.
    1.10 + * This file is part of SourcePawn.
    1.11   *
    1.12 - * JITCraft is free software: you can redistribute it and/or modify it under
    1.13 + * SourcePawn is free software: you can redistribute it and/or modify it under
    1.14   * the terms of the GNU General Public License as published by the Free
    1.15   * Software Foundation, either version 3 of the License, or (at your option)
    1.16   * any later version.
    1.17   * 
    1.18 - * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
    1.19 + * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
    1.20   * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.21   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    1.22   *
    1.23   * You should have received a copy of the GNU General Public License along with
    1.24 - * JITCraft. If not, see http://www.gnu.org/licenses/.
    1.25 + * SourcePawn. If not, see http://www.gnu.org/licenses/.
    1.26   */
    1.27  #ifndef _include_opcodes_h_
    1.28  #define _include_opcodes_h_
    1.29 @@ -69,6 +70,14 @@
    1.30      }
    1.31  }
    1.32  
    1.33 +static const unsigned MAX_TABLESWITCH_ENTRIES = 256;
    1.34 +
    1.35 +static inline unsigned
    1.36 +TableSwitchEntries(int low, int high)
    1.37 +{
    1.38 +    return unsigned(high - low) + 1;
    1.39 +}
    1.40 +
    1.41  static inline int
    1.42  READ_INT32(bytecode *pc)
    1.43  {
    1.44 @@ -85,6 +94,18 @@
    1.45      return *reinterpret_cast<float *>(pc + 1);
    1.46  }
    1.47  
    1.48 +static inline int
    1.49 +READ_TABLESWITCH_LOW(bytecode *pc)
    1.50 +{
    1.51 +    return READ_INT32(pc);
    1.52 +}
    1.53 +
    1.54 +static inline int
    1.55 +READ_TABLESWITCH_HIGH(bytecode *pc)
    1.56 +{
    1.57 +    return READ_INT32(pc + sizeof(int));
    1.58 +}
    1.59 +
    1.60  class Code;
    1.61  
    1.62  void Disassemble(Code *code, FILE *fp);