Merge changes from topics "dist_for_goals", "mk2star"

* changes:
  Generate runtime conversion diagnostics
  Convert dist-for-goals.
This commit is contained in:
Treehugger Robot
2021-11-18 22:04:52 +00:00
committed by Gerrit Code Review
6 changed files with 126 additions and 146 deletions

View File

@@ -18,8 +18,6 @@ import (
"fmt"
"strconv"
"strings"
mkparser "android/soong/androidmk/parser"
)
// Represents an expression in the Starlark code. An expression has
@@ -106,7 +104,7 @@ func (xi *interpolateExpr) emit(gctx *generationContext) {
format += "%s" + strings.ReplaceAll(chunk, "%", "%%")
}
gctx.writef("%q %% ", format)
emitarg := func(arg starlarkExpr) {
emitArg := func(arg starlarkExpr) {
if arg.typ() == starlarkTypeList {
gctx.write(`" ".join(`)
arg.emit(gctx)
@@ -116,12 +114,12 @@ func (xi *interpolateExpr) emit(gctx *generationContext) {
}
}
if len(xi.args) == 1 {
emitarg(xi.args[0])
emitArg(xi.args[0])
} else {
sep := "("
for _, arg := range xi.args {
gctx.write(sep)
emitarg(arg)
emitArg(arg)
sep = ", "
}
gctx.write(")")
@@ -427,7 +425,7 @@ func newStringListExpr(items []string) *listExpr {
return &v
}
// concatExpr generates epxr1 + expr2 + ... + exprN in Starlark.
// concatExpr generates expr1 + expr2 + ... + exprN in Starlark.
type concatExpr struct {
items []starlarkExpr
}
@@ -620,8 +618,8 @@ func (cx *callExpr) emitListVarCopy(gctx *generationContext) {
}
type badExpr struct {
node mkparser.Node
message string
errorLocation ErrorLocation
message string
}
func (b *badExpr) eval(_ map[string]starlarkExpr) (res starlarkExpr, same bool) {
@@ -630,15 +628,15 @@ func (b *badExpr) eval(_ map[string]starlarkExpr) (res starlarkExpr, same bool)
return
}
func (b *badExpr) emit(_ *generationContext) {
panic("implement me")
func (b *badExpr) emit(gctx *generationContext) {
gctx.emitConversionError(b.errorLocation, b.message)
}
func (_ *badExpr) typ() starlarkType {
return starlarkTypeUnknown
}
func (b *badExpr) emitListVarCopy(gctx *generationContext) {
func (_ *badExpr) emitListVarCopy(_ *generationContext) {
panic("implement me")
}