Generate runtime conversion diagnostics
Instead of inserting a comment with error description into the generated code, generate a call to a function that will print out a conversion error when executed. Do not print generic "partially converted" message anymore. Remove --verbose and --no_warnings options. Bug: 204062171 Test: internal Change-Id: Ib126e16dc76f49635e4939e670922f2561781049
This commit is contained in:
@@ -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(")")
|
||||
@@ -414,7 +412,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
|
||||
}
|
||||
@@ -607,8 +605,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) {
|
||||
@@ -617,15 +615,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")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user