Beispiel #1
0
func NominalWrapping(childExpression Expression, nominalType typegraph.TGTypeDecl, basis compilergraph.GraphNode) Expression {
	return &NominalWrappingNode{
		expressionBase{domBase{basis}},
		childExpression,
		nominalType.GetTypeReference(),
		nominalType.GetTypeReference(),
		true,
	}
}
Beispiel #2
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()
}
Beispiel #3
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")
	}
}
Beispiel #4
0
// computeTypeSignature computes and returns the type signature for the given type.
func computeTypeSignature(typedecl typegraph.TGTypeDecl) typeSignature {
	// We only need non-field members, as fields are never in interfaces.
	nonFieldMembers := typedecl.NonFieldMembers()

	staticSignatures := make([]memberSignature, 0, len(nonFieldMembers))
	dynamicSignatures := make([]memberSignature, 0, len(nonFieldMembers))

	for _, member := range nonFieldMembers {
		// We only need exported members as interfaces cannot contain or match
		// private members.
		if !member.IsExported() {
			continue
		}

		signature := computeMemberSignature(member)
		if signature.IsDynamic() {
			dynamicSignatures = append(dynamicSignatures, signature)
		} else {
			staticSignatures = append(staticSignatures, signature)
		}
	}

	return typeSignature{staticSignatures, dynamicSignatures}
}
Beispiel #5
0
// GetStaticTypePath returns the global path for the given defined type.
func (p Pather) GetStaticTypePath(typedecl typegraph.TGTypeDecl, referenceType typegraph.TypeReference) string {
	instanceTypeRef := typedecl.GetTypeReference().TransformUnder(referenceType)
	return p.TypeReferenceCall(instanceTypeRef)
}