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

http://github.com/nddrylliog/ooc · Java · 44 lines · 34 code · 10 blank · 0 comment · 7 complexity · 2c4dc3ac33169cf6a645e2aa4fa43674 MD5 · raw file

  1. package org.ooc.frontend.model;
  2. import org.ooc.frontend.model.tokens.Token;
  3. public abstract class ControlStatement extends Statement implements Scope {
  4. protected NodeList<Line> body;
  5. public ControlStatement(Token startToken) {
  6. super(startToken);
  7. this.body = new NodeList<Line>(startToken);
  8. }
  9. public NodeList<Line> getBody() {
  10. return body;
  11. }
  12. public VariableDecl getVariable(String name) {
  13. if(body.size() > 0) for(Line line: body) {
  14. Node node = line.getStatement();
  15. if(node instanceof VariableDecl) {
  16. VariableDecl varDecl = (VariableDecl) node;
  17. if(varDecl.getName().equals(name)) return varDecl;
  18. }
  19. }
  20. return null;
  21. }
  22. public void getVariables(NodeList<VariableDecl> variables) {
  23. if(body.size() > 0) for(Line line: body) {
  24. Node node = line.getStatement();
  25. if(node instanceof VariableDecl) {
  26. variables.add((VariableDecl) node);
  27. }
  28. }
  29. }
  30. public FunctionDecl getFunction(String name, String suffix, FunctionCall call) {
  31. return null;
  32. }
  33. public void getFunctions(NodeList<FunctionDecl> functions) {}
  34. }