2007-12-24 16:19:51 +08:00
|
|
|
package net.loveruby.cflat.ast;
|
2009-04-27 01:55:46 +08:00
|
|
|
import net.loveruby.cflat.entity.*;
|
2007-12-24 16:19:51 +08:00
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
public class Declarations {
|
2009-05-17 15:39:00 +08:00
|
|
|
Set<DefinedVariable> defvars = new LinkedHashSet<DefinedVariable>();
|
|
|
|
Set<UndefinedVariable> vardecls = new LinkedHashSet<UndefinedVariable>();
|
|
|
|
Set<DefinedFunction> defuns = new LinkedHashSet<DefinedFunction>();
|
|
|
|
Set<UndefinedFunction> funcdecls = new LinkedHashSet<UndefinedFunction>();
|
|
|
|
Set<Constant> constants = new LinkedHashSet<Constant>();
|
|
|
|
Set<StructNode> defstructs = new LinkedHashSet<StructNode>();
|
|
|
|
Set<UnionNode> defunions = new LinkedHashSet<UnionNode>();
|
|
|
|
Set<TypedefNode> typedefs = new LinkedHashSet<TypedefNode>();
|
2007-12-24 16:19:51 +08:00
|
|
|
|
|
|
|
public void add(Declarations decls) {
|
2009-05-17 15:39:00 +08:00
|
|
|
defvars.addAll(decls.defvars);
|
|
|
|
vardecls.addAll(decls.vardecls);
|
|
|
|
funcdecls.addAll(decls.funcdecls);
|
|
|
|
constants.addAll(decls.constants);
|
|
|
|
defstructs.addAll(decls.defstructs);
|
|
|
|
defunions.addAll(decls.defunions);
|
|
|
|
typedefs.addAll(decls.typedefs);
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addDefvar(DefinedVariable var) {
|
|
|
|
defvars.add(var);
|
|
|
|
}
|
|
|
|
|
2008-09-29 02:46:56 +08:00
|
|
|
public void addDefvars(List<DefinedVariable> vars) {
|
|
|
|
defvars.addAll(vars);
|
2008-01-21 00:19:13 +08:00
|
|
|
}
|
|
|
|
|
2008-09-29 02:46:56 +08:00
|
|
|
public List<DefinedVariable> defvars() {
|
|
|
|
return new ArrayList<DefinedVariable>(defvars);
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addVardecl(UndefinedVariable var) {
|
|
|
|
vardecls.add(var);
|
|
|
|
}
|
|
|
|
|
2008-09-29 02:46:56 +08:00
|
|
|
public List<UndefinedVariable> vardecls() {
|
|
|
|
return new ArrayList<UndefinedVariable>(vardecls);
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
|
2009-05-17 15:39:00 +08:00
|
|
|
public void addConstant(Constant c) {
|
|
|
|
constants.add(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Constant> constants() {
|
|
|
|
return new ArrayList<Constant>(constants);
|
|
|
|
}
|
|
|
|
|
2008-09-29 02:46:56 +08:00
|
|
|
public void addDefun(DefinedFunction func) {
|
2007-12-24 16:19:51 +08:00
|
|
|
defuns.add(func);
|
|
|
|
}
|
|
|
|
|
2008-09-29 02:46:56 +08:00
|
|
|
public List<DefinedFunction> defuns() {
|
|
|
|
return new ArrayList<DefinedFunction>(defuns);
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addFuncdecl(UndefinedFunction func) {
|
|
|
|
funcdecls.add(func);
|
|
|
|
}
|
|
|
|
|
2008-09-29 02:46:56 +08:00
|
|
|
public List<UndefinedFunction> funcdecls() {
|
|
|
|
return new ArrayList<UndefinedFunction>(funcdecls);
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addDefstruct(StructNode n) {
|
|
|
|
defstructs.add(n);
|
|
|
|
}
|
|
|
|
|
2008-09-29 02:46:56 +08:00
|
|
|
public List<StructNode> defstructs() {
|
|
|
|
return new ArrayList<StructNode>(defstructs);
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addDefunion(UnionNode n) {
|
|
|
|
defunions.add(n);
|
|
|
|
}
|
|
|
|
|
2008-09-29 02:46:56 +08:00
|
|
|
public List<UnionNode> defunions() {
|
|
|
|
return new ArrayList<UnionNode>(defunions);
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addTypedef(TypedefNode n) {
|
|
|
|
typedefs.add(n);
|
|
|
|
}
|
|
|
|
|
2008-09-29 02:46:56 +08:00
|
|
|
public List<TypedefNode> typedefs() {
|
|
|
|
return new ArrayList<TypedefNode>(typedefs);
|
2007-12-24 16:19:51 +08:00
|
|
|
}
|
|
|
|
}
|