aboutsummaryrefslogtreecommitdiff
path: root/project/QBarInterpreter/src/com/modulus/qbar/core/QBSyntheticUtilityNamespace.java
blob: 8153ae8fcb46705f9ce9ddc56a345e30e0558fac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.modulus.qbar.core;

import com.modulus.dataread.expressions.Statement;
import com.modulus.qbar.core.parser.QBParser;

public class QBSyntheticUtilityNamespace extends QBUtilityNamespace {
	private static final long serialVersionUID = 1941492008845020291L;
	
	private String name;
	
	public QBSyntheticUtilityNamespace(Statement stat, QBParser parser, QBNamespace superNamespace) {
		String header = stat.getHeader();
		this.setSuper(superNamespace);
		// chop off `Namespace`
		name = header.substring(9).trim();
		
		for(Statement child : stat.getChildren())
			parser.readStatement(child, this);
		
		this.set("this", this);
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public void construct() {
		QBObject obj = this.getNoError("construct");
		if( obj instanceof QBFunction ){
			((QBFunction) obj).execute( new QBObject[]{} );
		}
	}
	
	

}