File: constant.hh

package info (click to toggle)
jlint 3.0-4.2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 776 kB
  • ctags: 662
  • sloc: cpp: 5,837; ansic: 1,496; makefile: 299; perl: 93; sh: 49
file content (105 lines) | stat: -rw-r--r-- 2,136 bytes parent folder | download | duplicates (5)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef CONSTANT_HH
#define CONSTANT_HH

#include "types.hh"
#include "utf_string.hh"

class constant { 
 public:
  byte tag;
  virtual int length() = 0;
  virtual type_tag type() { return tp_object; }
  constant(byte* p) { tag = *p; }
  constant() { tag = 0; } // for is_this
};

class const_class : public constant {
 public:   
  int name;
  const_class(byte* p) : constant(p) {
    name = unpack2(p+1);
  }
  int length() { return 3; }
};

class const_double : public constant {
 public:
  const_double(byte* p) : constant(p) {}
  int length() { return 9; }
  type_tag type() { return tp_double; }
};

class const_float : public constant {
 public:
  const_float(byte* p) : constant(p) {}
  int length() { return 5; }
  type_tag type() { return tp_float; }
};

class const_int : public constant {
 public:
  int value;
  const_int(byte* p) : constant(p) {
    value = unpack4(p+1);
  }
  int length() { return 5; }
  type_tag type() { return tp_int; }
};

class const_long : public constant {
 public:
  struct { 
    int4 high;
    int4 low;
  } value;
  const_long(byte* p) : constant(p) {
    value.high = unpack4(p+1);
    value.low  = unpack4(p+5);
  }
  int length() { return 9; }
  type_tag type() { return tp_long; }
};

class const_name_and_type : public constant {
 public:   
  int name;
  int desc;
  const_name_and_type(byte* p) : constant(p) {
    name = unpack2(p+1);
    desc = unpack2(p+3);
  }
  const_name_and_type(int n, int t) { // used for is_this
    name = n;
    desc = t;
  }
  int length() { return 5; }
};

class const_ref : public constant {
 public:   
  int cls;
  int name_and_type;
  const_ref(byte* p) : constant(p) {
    cls = unpack2(p+1);
    name_and_type = unpack2(p+3);
  }
  int length() { return 5; }
};

class const_string : public constant {
 public:   
  int str;
  const_string(byte* p) : constant(p) {
    str = unpack2(p+1);
  }
  int length() { return 3; }
  type_tag type() { return tp_string; }
};

class const_utf8 : public constant, public utf_string { 
 public:
  const_utf8(byte* p) : constant(p), utf_string(unpack2(p+1), p+3) {}
  int length() { return 3 + len; }
};

#endif