Exemplo n.º 1
0
// GetTypePath returns the global path for the given type.
func (p Pather) GetTypePath(typedecl typegraph.TGTypeDecl) string {
	if typedecl.TypeKind() == typegraph.GenericType {
		return typedecl.Name()
	}

	return p.GetModulePath(typedecl.ParentModule()) + "." + typedecl.Name()
}
Exemplo n.º 2
0
// generateType generates the given type into ES5.
func (gen *es5generator) generateType(typedef typegraph.TGTypeDecl) esbuilder.SourceBuilder {
	generating := generatingType{typedef, gen}

	switch typedef.TypeKind() {
	case typegraph.ClassType:
		return esbuilder.Template("class", classTemplateStr, generating)

	case typegraph.ImplicitInterfaceType:
		return esbuilder.Template("interface", interfaceTemplateStr, generating)

	case typegraph.NominalType:
		return esbuilder.Template("nominal", nominalTemplateStr, generating)

	case typegraph.StructType:
		return esbuilder.Template("struct", structTemplateStr, generating)

	case typegraph.ExternalInternalType:
		return esbuilder.Snippet("")

	default:
		panic("Unknown typedef kind")
	}
}