summaryrefslogtreecommitdiffstats
path: root/src/Int.vala
blob: 5df38573b805d7ca3734961f3741ef5229bb2f02 (plain)
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
namespace Eva {
  public class Int : Object, Term {
    public long value {get; construct;}
    
    public Int(long v) {
      Object(value: v);
    }
    
    public string to_string() {
      return value.to_string();
    }
    
    protected bool do_match(Term o, Gee.Map<string, Term> vars, Gee.Map<string, string> aliases) {
      if(o is Var) {
        return o.do_match(this, vars, aliases);
      }
      
      if(o is Int) {
        return value == (o as Int).value;
      }
      else if(o is UInt) {
        return value == (o as UInt).value;
      }
      else {
        return false;
      }
    }
    
    public void encode(Erl.Buffer buffer) {
      buffer.encode_long(value);
    }
  }
}