compoundtype.java

来自「plugin for eclipse」· Java 代码 · 共 95 行

JAVA
95
字号
/*
 * Created on May 8, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package isis.anp.nesc.ot.types;

import isis.anp.common.TNode;
import isis.anp.nesc.ot.scope.Scope;
import isis.anp.nesc.ot.scope.Symbol;

/**
 * @author sallai
 * 
 * Struct or a union.
 */
public abstract class CompoundType extends AtomicType implements Symbol {
	// the "struct" or the "union" node
	TNode defNode;

	// the node holding the name of the stuct/union/enum (it can be null)
	TNode nameNode;

	// the name of the type
	String name;
	
	// parent scope
	Scope parentScope;

	public TNode getDefNode() {
		return defNode;
	}

	public void setDefNode(TNode defNode) {
		this.defNode = defNode;
		this.name = defNode.getText() + " /* no tag given */";
	}

	public TNode getNameNode() {
		return nameNode;
	}

	public void setNameNode(TNode nameNode) {
		this.nameNode = nameNode;
		if(nameNode!=null) {
			this.name = getDefNode().getText() + " " + nameNode.getText();
		}
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		String prefix = getDefNode().getText() + " ";
		if (name.startsWith(prefix)) {
			this.name = name;
			if (nameNode != null) {
				nameNode.setText(name.substring(prefix.length(),
						name.length() - 1));
			}
		}
	}

	public void setParentScope(Scope s) {
		this.parentScope = s;
	}
	
	public Scope getParentScope() {
		return parentScope;
	}
	
	public String getHierarchicalName() {
		StringBuffer sb = new StringBuffer();

		if (getParentScope() != null) {
			sb.append(getParentScope().getHierarchicalName());
		}
		sb.append("::");
		sb.append(getName());

		return sb.toString();
	}

	public abstract boolean isComplete();
	public abstract boolean isSpecifierComplete();

	/**
	 * @param typeProduct
	 */
	public abstract void complete(CompoundType typeProduct);
	

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?