PageRenderTime 17ms CodeModel.GetById 9ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

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