예제 #1
0
func WrapIfPromising(childExpression Expression, member typegraph.TGMember, basis compilergraph.GraphNode) Expression {
	if member.IsPromising() {
		return AwaitPromise(childExpression, basis)
	}

	return childExpression
}
예제 #2
0
// GetStaticMemberPath returns the global path for the given statically defined type member.
func (p Pather) GetStaticMemberPath(member typegraph.TGMember, referenceType typegraph.TypeReference) string {
	// TODO(jschorr): We should generalize non-SRG support.
	if member.Name() == "new" && !member.IsPromising() {
		parentType, _ := member.ParentType()
		if strings.HasSuffix(parentType.ParentModule().Path(), ".webidl") {
			return "$t.nativenew(" + p.GetTypePath(parentType) + ")"
		}
	}

	name := p.GetMemberName(member)
	parent := member.Parent()
	if parent.IsType() {
		return p.GetStaticTypePath(parent.(typegraph.TGTypeDecl), referenceType) + "." + name
	} else {
		return p.GetModulePath(parent.(typegraph.TGModule)) + "." + name
	}
}