EOS 2  1.1.0
Einfache Objektbasierte Sprache
Constant.java
gehe zur Dokumentation dieser Datei
1 package de.lathanda.eos.baseparser;
2 
3 import de.lathanda.eos.vm.Command;
4 import de.lathanda.eos.vm.commands.LoadConstant;
5 
6 import java.util.ArrayList;
7 
14 public class Constant extends Expression {
15 
16  private final Object value;
17  private final String image;
18 
19  public Constant(Object value, Type type) {
20  this.value = value;
21  this.type = type;
22  this.image = value.toString();
23  prio = 1000;
24  }
25 
26  public Constant(Object value, Type type, String image) {
27  this.value = value;
28  this.type = type;
29  this.image = image;
30  prio = 1000;
31  }
32 
33  public Object getValue() {
34  return value;
35  }
36 
37  @Override
38  public void compile(ArrayList<Command> ops, boolean autoWindow) throws Exception {
39  ops.add(new LoadConstant(value));
40  }
41 
42  @Override
43  public String toString() {
44  return value.toString();
45  }
46 
47  @Override
48  public void resolveNamesAndTypes(Expression with, Environment env) {
49  // nothing to do
50  }
51 
52  @Override
53  public String getLabel() {
54  return image;
55  }
56 
57 }
void resolveNamesAndTypes(Expression with, Environment env)
Definition: Constant.java:48
Constant(Object value, Type type, String image)
Definition: Constant.java:26
void compile(ArrayList< Command > ops, boolean autoWindow)
Definition: Constant.java:38
Constant(Object value, Type type)
Definition: Constant.java:19
Impressum