HomeForumSourceResearchGuide
Sign in to contribute to source. how it works
Component util.compiler.TypeTable by barry
expand copy to clipboardexpand
uses OpParser

data Entry {
	char name[]
	int offset
}

component provides TypeTable requires data.adt.List {
	List list

	TypeTable:TypeTable()
		{
		list = new List()
		}
	
	void TypeTable:add(store char name[], int offset)
		{
		list.add(new Entry(name, offset))
		}

	int TypeTable:getOffsetOf(char name[])
		{
		for (Entry l = list.getFirst(); l != null; l = list.getNext())
			{
			if (l.name == name) return l.offset
			}
		
		throw new Exception("type record '$name' not found in type table")
		}
	
	TypeOffsetEntry[] TypeTable:getOffsets()
		{
		TypeOffsetEntry result[] = new TypeOffsetEntry[list.getLength()]

		int i = 0
		for (Entry l = list.getFirst(); l != null; l = list.getNext())
			{
			result[i] = new TypeOffsetEntry(l.name, l.offset)
			i ++
			}
		
		return result
		}
	
	}
Revision history
To propose a new revision to this entity, use dana source put -uc your/new/version.dn -n util.compiler.TypeTable -m "reason for update" -u yourUsername
Version 1 (this version) by barry
Notes for this version: New compiler components