Exemplo n.º 1
0
	def _onDefStruct(self, ast, name, members):
		# since structs can refer to them selves using pointers we have to add this type right now
		structType = ESType.createStruct(name.text, [], [])
		self._addSymbol(fromTree=name, symbol=structType)

		esTypes = []
		names = []
		for x in members:
			# DO NOT dispatch x itself! that would add entries to a symbol table that does not exist
			# process name manually and dispatch type name
			self._dispatch(x.children[1])
			esTypes.append(x.children[1].esType)

			if x.children[0].text in names:
				self._raiseException(RecoverableCompileError, tree=x.children[0], inlineText='name already used')
			names.append(x.children[0].text)

		# add members
		# FIXME derive type name from package and module!
		t = ESType.createStruct(name.text, esTypes, names)
		structType.payload = t.payload
		structType.parents = t.parents

		ast.esType = structType