All files / utils PrimitiveKindUtils.ts

100% Statements 2/2
100% Branches 0/0
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                      157x                               10917x          
import TPrimitiveKind from "../types/TPrimitiveKind";
 
/**
 * Utility functions for working with C-Next primitive types.
 */
class PrimitiveKindUtils {
  /**
   * The C-Next primitive type names. A name set, not a width table (#1760
   * review): the widths here were read by nothing but their own tests, and
   * gave `bool` 1 where TYPE_WIDTH, the one width table, gives 8.
   */
  private static readonly PRIMITIVES: ReadonlySet<string> = new Set<string>([
    "bool",
    "u8",
    "i8",
    "u16",
    "i16",
    "u32",
    "i32",
    "u64",
    "i64",
    "f32",
    "f64",
    "void",
  ]);
 
  static isPrimitive(type: string): type is TPrimitiveKind {
    return PrimitiveKindUtils.PRIMITIVES.has(type);
  }
}
 
export default PrimitiveKindUtils;