structorunionbasetype.java

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

JAVA
127
字号
/*
 * Created on Jun 3, 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.NesCEmitter;
import isis.anp.nesc.ot.Attribute;
import isis.anp.nesc.ot.Outline;
import isis.anp.nesc.ot.StructOrUnionSpecifier;

import java.util.ArrayList;
import java.util.Iterator;

import antlr.RecognitionException;

/**
 * @author sallai
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public abstract class StructOrUnionBaseType extends CompoundType {

	ArrayList declarationList;
	ArrayList attributeList;
	
	boolean isSpecifierComplete;

	protected StructOrUnionBaseType() {
	}
	
	public StructOrUnionBaseType(StructOrUnionSpecifier s) {
		this.setDefNode(s.getDefNode());
		this.setNameNode(s.getSpecifierNameNode());
		this.setDeclarationList(s.getDeclarationList());
		this.setAttributeList(s.getAttributeList());
		isSpecifierComplete = s.isComplete();
	}

	public void setDeclarationList(ArrayList declaratorList) {
		this.declarationList = declaratorList;
	}

	public ArrayList getDeclaratorList() {
		return this.declarationList;
	}

	public boolean isComplete() {
		return (declarationList!=null);
	}

	public void outline(Outline o) {
		o.append(getTypeQualifierString());
		o.ensureSpace();
		o.append(getName());
		o.ensureSpace();

//		if (isComplete()) {
//			o.append("<complete:"+ declarationList.hashCode()+">");			
//		} else {
//			o.append("<incomplete>");
//		}
//		o.ensureSpace();
		
		if (isSpecifierComplete()) {

			if (this.declarationList != null) {
				o.append("{\n");
				o.incTabs();
				Iterator i = this.declarationList.iterator();
				while (i.hasNext()) {
					TNode d = (TNode) i.next();
					o.addTabs();
//					o.append("<structDeclaration" + d.hashCode() + ">\n");
					NesCEmitter e = new NesCEmitter(o);
					try {
						e.structDeclaration(d);
						o.append(";\n");
					} catch(RecognitionException ex) {
						o.append("/* Exception while printing out enumerator constant: +" + ex.toString() +" */");
					}
					
				}
				o.decTabs();
				o.addTabs();
				o.append("}");
				
				Iterator j = getAttributeList().iterator();
				while (j.hasNext()) {
					Attribute a = (Attribute) j.next();
					o.ensureSpace();
					a.outline(o);
				}
				
				o.ensureSpace();
			}
		}
	}

	/**
	 * @return Returns the declaredAsComplete.
	 */
	public boolean isSpecifierComplete() {
		return isSpecifierComplete;
	}
	
	public void complete(CompoundType typeProduct) {
		((StructOrUnionBaseType)typeProduct).setDeclarationList(getDeclaratorList());
	}	
	/**
	 * @return Returns the attributeList.
	 */
	public ArrayList getAttributeList() {
		return attributeList;
	}
	/**
	 * @param attributeList The attributeList to set.
	 */
	public void setAttributeList(ArrayList attributeList) {
		this.attributeList = attributeList;
	}
	
}

⌨️ 快捷键说明

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