示例#1
0
// buildExpressions builds expressions for each of the nodes found in the iterator.
func (db *domBuilder) buildExpressions(iterator compilergraph.NodeIterator, option buildExprOption) []codedom.Expression {
	var expressions = make([]codedom.Expression, 0)
	for iterator.Next() {
		expr := db.buildExpression(iterator.Node())

		// If requested, check to see if the expression was used under a special exception where
		// a nominal type is used in place of its root data type. If so, we need to unwrap the
		// expression value.
		if option == buildExprCheckNominalShortcutting &&
			db.scopegraph.HasSecondaryLabel(iterator.Node(), proto.ScopeLabel_NOMINALLY_SHORTCUT_EXPR) {
			expr = codedom.NominalUnwrapping(expr, db.scopegraph.TypeGraph().AnyTypeReference(), iterator.Node())
		}

		expressions = append(expressions, expr)
	}
	return expressions
}
示例#2
0
文件: util.go 项目: Serulian/compiler
// salForIterator returns a SourceAndLocation for the given iterator. Note that
// the iterator *must* contain the NodePredicateSource and NodePredicateStartRune predicates.
func salForIterator(iterator compilergraph.NodeIterator) compilercommon.SourceAndLocation {
	return compilercommon.NewSourceAndLocation(
		compilercommon.InputSource(iterator.GetPredicate(parser.NodePredicateSource).String()),
		iterator.GetPredicate(parser.NodePredicateStartRune).Int())
}