PageRenderTime 243ms CodeModel.GetById 121ms app.highlight 5ms RepoModel.GetById 116ms app.codeStats 0ms

/src/org/ooc/frontend/model/IntLiteral.java

http://github.com/nddrylliog/ooc
Java | 66 lines | 50 code | 16 blank | 0 comment | 0 complexity | 2986013db90ba06845c9b83c4ec4636c MD5 | raw file
 1package org.ooc.frontend.model;
 2
 3import java.io.IOException;
 4import java.math.BigInteger;
 5
 6import org.ooc.frontend.Visitor;
 7import org.ooc.frontend.model.tokens.Token;
 8
 9public class IntLiteral extends Literal {
10
11	public static enum Format {
12		DEC,
13		OCT,
14		HEX,
15		BIN,
16	}
17	
18	protected BigInteger value;
19	protected Format format;
20	public static Type type = new Type("Int", Token.defaultToken);
21	
22	public IntLiteral(long value, Format format, Token startToken) {
23		this(new BigInteger(String.valueOf(value)), format, startToken);
24	}
25	
26	public IntLiteral(BigInteger value, Format format, Token startToken) {
27		super(startToken);
28		this.value = value;
29		this.format = format;
30	}
31	
32	public Type getType() {
33		return type;
34	}
35	
36	public BigInteger getValue() {
37		return value;
38	}
39	
40	public Format getFormat() {
41		return format;
42	}
43	
44	public void accept(Visitor visitor) throws IOException {
45		visitor.visit(this);
46	}
47	
48	public boolean hasChildren() {
49		return true;
50	}
51	
52	public void acceptChildren(Visitor visitor) throws IOException {
53		visitor.visit(type);
54	}
55	
56	@Override
57	public boolean replace(Node oldie, Node kiddo) {
58		return false;
59	}
60	
61	@Override
62	public String toString() {
63		return String.valueOf(value);
64	}
65	
66}