mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 00:47:28 +01:00
Rename String(*token.Map) to Str(*token.Map)
This commit is contained in:
1 parent
638d8eee77
commit
7601fb45ce
15 files changed
+219
-219
No files matched your search
@@ -431,11 +431,11 @@ func (g *gen) sizeof(typ *a.TypeExpr) (uint32, error) {
|
||||
return 8, nil
|
||||
}
|
||||
}
|
||||
return 0, fmt.Errorf("unknown sizeof for %q", typ.String(g.tm))
|
||||
return 0, fmt.Errorf("unknown sizeof for %q", typ.Str(g.tm))
|
||||
}
|
||||
|
||||
func (g *gen) gatherStatuses(b *buffer, n *a.Status) error {
|
||||
raw := n.Message().String(g.tm)
|
||||
raw := n.Message().Str(g.tm)
|
||||
msg, ok := t.Unescape(raw)
|
||||
if !ok {
|
||||
return fmt.Errorf("bad status message %q", raw)
|
||||
@@ -459,7 +459,7 @@ func (g *gen) writeConst(b *buffer, n *a.Const) error {
|
||||
b.writes("static ")
|
||||
}
|
||||
b.writes("const ")
|
||||
if err := g.writeCTypeName(b, n.XType(), g.pkgPrefix, n.Name().String(g.tm)); err != nil {
|
||||
if err := g.writeCTypeName(b, n.XType(), g.pkgPrefix, n.Name().Str(g.tm)); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(" = ")
|
||||
@@ -484,7 +484,7 @@ func (g *gen) writeConstList(b *buffer, n *a.Expr) error {
|
||||
}
|
||||
b.writeb('}')
|
||||
default:
|
||||
return fmt.Errorf("invalid const value %q", n.String(g.tm))
|
||||
return fmt.Errorf("invalid const value %q", n.Str(g.tm))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -495,7 +495,7 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error {
|
||||
// set "self->private_impl.status = WUFFS_ETC__ERROR_BAD_WUFFS_VERSION;"
|
||||
// regardless of the sizeof(*self) struct reserved by the caller and even
|
||||
// if the caller and callee were built with different versions.
|
||||
structName := n.Name().String(g.tm)
|
||||
structName := n.Name().Str(g.tm)
|
||||
b.writes("typedef struct {\n")
|
||||
b.writes("// Do not access the private_impl's fields directly. There is no API/ABI\n")
|
||||
b.writes("// compatibility or safety guarantee if you do so. Instead, use the\n")
|
||||
@@ -513,7 +513,7 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error {
|
||||
|
||||
for _, o := range n.Fields() {
|
||||
o := o.Field()
|
||||
if err := g.writeCTypeName(b, o.XType(), fPrefix, o.Name().String(g.tm)); err != nil {
|
||||
if err := g.writeCTypeName(b, o.XType(), fPrefix, o.Name().Str(g.tm)); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(";\n")
|
||||
@@ -546,7 +546,7 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error {
|
||||
if k.usesScratch {
|
||||
b.writes("uint64_t scratch;\n")
|
||||
}
|
||||
b.printf("} %s%s[%d];\n", cPrefix, o.Name().String(g.tm), maxDepth)
|
||||
b.printf("} %s%s[%d];\n", cPrefix, o.Name().Str(g.tm), maxDepth)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -556,7 +556,7 @@ func (g *gen) writeStruct(b *buffer, n *a.Struct) error {
|
||||
}
|
||||
|
||||
func (g *gen) writeInitializerSignature(b *buffer, n *a.Struct, public bool) error {
|
||||
structName := n.Name().String(g.tm)
|
||||
structName := n.Name().Str(g.tm)
|
||||
if public {
|
||||
b.printf("// %s%s__initialize is an initializer function.\n", g.pkgPrefix, structName)
|
||||
b.printf("//\n")
|
||||
@@ -605,7 +605,7 @@ func (g *gen) writeInitializerImpl(b *buffer, n *a.Struct) error {
|
||||
f := f.Field()
|
||||
if dv := f.DefaultValue(); dv != nil {
|
||||
// TODO: set default values for array types.
|
||||
b.printf("self->private_impl.%s%s = %d;\n", fPrefix, f.Name().String(g.tm), dv.ConstValue())
|
||||
b.printf("self->private_impl.%s%s = %d;\n", fPrefix, f.Name().Str(g.tm), dv.ConstValue())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,7 +622,7 @@ func (g *gen) writeInitializerImpl(b *buffer, n *a.Struct) error {
|
||||
}
|
||||
b.printf("%s%s__initialize(&self->private_impl.%s%s,"+
|
||||
"WUFFS_VERSION, WUFFS_BASE__ALREADY_ZEROED);\n",
|
||||
g.pkgPrefix, x.Name().String(g.tm), fPrefix, f.Name().String(g.tm))
|
||||
g.pkgPrefix, x.Name().Str(g.tm), fPrefix, f.Name().Str(g.tm))
|
||||
}
|
||||
|
||||
b.writes("}\n\n")
|
||||
|
||||
@@ -52,7 +52,7 @@ func (g *gen) writeExpr(b *buffer, n *a.Expr, rp replacementPolicy, pp parenthes
|
||||
} else if cv.Cmp(one) == 0 {
|
||||
b.writes("true")
|
||||
} else {
|
||||
return fmt.Errorf("%v has type bool but constant value %v is neither 0 or 1", n.String(g.tm), cv)
|
||||
return fmt.Errorf("%v has type bool but constant value %v is neither 0 or 1", n.Str(g.tm), cv)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
||||
} else {
|
||||
b.writes(vPrefix)
|
||||
}
|
||||
b.writes(id1.String(g.tm))
|
||||
b.writes(id1.Str(g.tm))
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -305,7 +305,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
||||
p0, p1 := "", ""
|
||||
if o := n.LHS().Expr().LHS().Expr(); o != nil {
|
||||
// TODO: don't hard-code these.
|
||||
switch o.String(g.tm) {
|
||||
switch o.Str(g.tm) {
|
||||
case "in.dst":
|
||||
p0 = bPrefix + "wend_dst"
|
||||
p1 = bPrefix + "wptr_dst"
|
||||
@@ -423,7 +423,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
||||
lhs := n.LHS().Expr()
|
||||
if lhs.ID1().Key() == t.KeyIn {
|
||||
b.writes(aPrefix)
|
||||
b.writes(n.ID1().String(g.tm))
|
||||
b.writes(n.ID1().Str(g.tm))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -436,13 +436,13 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
|
||||
b.writes(".")
|
||||
}
|
||||
b.writes("private_impl." + fPrefix)
|
||||
b.writes(n.ID1().String(g.tm))
|
||||
b.writes(n.ID1().Str(g.tm))
|
||||
return nil
|
||||
|
||||
case t.KeyError, t.KeyStatus, t.KeySuspension:
|
||||
status := g.statusMap[n.ID1()]
|
||||
if status.name == "" {
|
||||
msg := builtin.TrimQuotes(n.ID1().String(g.tm))
|
||||
msg := builtin.TrimQuotes(n.ID1().Str(g.tm))
|
||||
z := builtin.StatusMap[msg]
|
||||
if z.Message == "" {
|
||||
return fmt.Errorf("no status code for %q", msg)
|
||||
@@ -530,7 +530,7 @@ func (g *gen) writeCTypeName(b *buffer, n *a.TypeExpr, varNamePrefix string, var
|
||||
b.writes(varName)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("cannot convert Wuffs type %q to C", n.String(g.tm))
|
||||
return fmt.Errorf("cannot convert Wuffs type %q to C", n.Str(g.tm))
|
||||
}
|
||||
|
||||
// maxNumPointers is an arbitrary implementation restriction.
|
||||
@@ -545,13 +545,13 @@ func (g *gen) writeCTypeName(b *buffer, n *a.TypeExpr, varNamePrefix string, var
|
||||
// TODO: "nptr T", not just "ptr T".
|
||||
if p := innermost.Decorator().Key(); p == t.KeyPtr {
|
||||
if numPointers == maxNumPointers {
|
||||
return fmt.Errorf("cannot convert Wuffs type %q to C: too many ptr's", n.String(g.tm))
|
||||
return fmt.Errorf("cannot convert Wuffs type %q to C: too many ptr's", n.Str(g.tm))
|
||||
}
|
||||
numPointers++
|
||||
continue
|
||||
}
|
||||
// TODO: fix this.
|
||||
return fmt.Errorf("cannot convert Wuffs type %q to C", n.String(g.tm))
|
||||
return fmt.Errorf("cannot convert Wuffs type %q to C", n.Str(g.tm))
|
||||
}
|
||||
|
||||
fallback := true
|
||||
@@ -562,7 +562,7 @@ func (g *gen) writeCTypeName(b *buffer, n *a.TypeExpr, varNamePrefix string, var
|
||||
}
|
||||
}
|
||||
if fallback {
|
||||
b.printf("%s%s", g.pkgPrefix, innermost.Name().String(g.tm))
|
||||
b.printf("%s%s", g.pkgPrefix, innermost.Name().Str(g.tm))
|
||||
}
|
||||
|
||||
for i := 0; i < numPointers; i++ {
|
||||
|
||||
@@ -59,9 +59,9 @@ func (k *funk) jumpTarget(n a.Loop) (uint32, error) {
|
||||
|
||||
func (g *gen) funcCName(n *a.Func) string {
|
||||
if r := n.Receiver(); r != 0 {
|
||||
return g.pkgPrefix + r.String(g.tm) + "__" + n.Name().String(g.tm)
|
||||
return g.pkgPrefix + r.Str(g.tm) + "__" + n.Name().Str(g.tm)
|
||||
}
|
||||
return g.pkgPrefix + n.Name().String(g.tm)
|
||||
return g.pkgPrefix + n.Name().Str(g.tm)
|
||||
}
|
||||
|
||||
func (g *gen) writeFuncSignature(b *buffer, n *a.Func) error {
|
||||
@@ -88,7 +88,7 @@ func (g *gen) writeFuncSignature(b *buffer, n *a.Func) error {
|
||||
|
||||
comma := false
|
||||
if r := n.Receiver(); r != 0 {
|
||||
b.printf("%s%s *self", g.pkgPrefix, r.String(g.tm))
|
||||
b.printf("%s%s *self", g.pkgPrefix, r.Str(g.tm))
|
||||
comma = true
|
||||
}
|
||||
for _, o := range n.In().Fields() {
|
||||
@@ -97,7 +97,7 @@ func (g *gen) writeFuncSignature(b *buffer, n *a.Func) error {
|
||||
}
|
||||
comma = true
|
||||
o := o.Field()
|
||||
if err := g.writeCTypeName(b, o.XType(), aPrefix, o.Name().String(g.tm)); err != nil {
|
||||
if err := g.writeCTypeName(b, o.XType(), aPrefix, o.Name().Str(g.tm)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -224,7 +224,7 @@ func (g *gen) writeFuncImplBodyResume(b *buffer) error {
|
||||
if g.currFunk.suspendible {
|
||||
// TODO: don't hard-code [0], and allow recursive coroutines.
|
||||
b.printf("uint32_t coro_susp_point = self->private_impl.%s%s[0].coro_susp_point;\n",
|
||||
cPrefix, g.currFunk.astFunc.Name().String(g.tm))
|
||||
cPrefix, g.currFunk.astFunc.Name().Str(g.tm))
|
||||
b.printf("if (coro_susp_point) {\n")
|
||||
if err := g.writeResumeSuspend(b, g.currFunk.astFunc.Body(), false); err != nil {
|
||||
return err
|
||||
@@ -256,14 +256,14 @@ func (g *gen) writeFuncImplBodySuspend(b *buffer) error {
|
||||
b.writes("\ngoto ok;\n") // Avoid the "unused label" warning.
|
||||
b.writes("ok:\n")
|
||||
b.printf("self->private_impl.%s%s[0].coro_susp_point = 0;\n",
|
||||
cPrefix, g.currFunk.astFunc.Name().String(g.tm))
|
||||
cPrefix, g.currFunk.astFunc.Name().Str(g.tm))
|
||||
b.writes("goto exit; }\n\n") // Close the coroutine switch.
|
||||
|
||||
b.writes("goto suspend;\n") // Avoid the "unused label" warning.
|
||||
b.writes("suspend:\n")
|
||||
|
||||
b.printf("self->private_impl.%s%s[0].coro_susp_point = coro_susp_point;\n",
|
||||
cPrefix, g.currFunk.astFunc.Name().String(g.tm))
|
||||
cPrefix, g.currFunk.astFunc.Name().Str(g.tm))
|
||||
if err := g.writeResumeSuspend(b, g.currFunk.astFunc.Body(), true); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -319,7 +319,7 @@ func (g *gen) writeFuncImplArgChecks(b *buffer, n *a.Func) error {
|
||||
|
||||
switch {
|
||||
case oTyp.Decorator().Key() == t.KeyPtr:
|
||||
checks = append(checks, fmt.Sprintf("!%s%s", aPrefix, o.Name().String(g.tm)))
|
||||
checks = append(checks, fmt.Sprintf("!%s%s", aPrefix, o.Name().Str(g.tm)))
|
||||
|
||||
case oTyp.IsRefined():
|
||||
bounds := [2]*big.Int{}
|
||||
@@ -345,7 +345,7 @@ func (g *gen) writeFuncImplArgChecks(b *buffer, n *a.Func) error {
|
||||
if i != 0 {
|
||||
op = '>'
|
||||
}
|
||||
checks = append(checks, fmt.Sprintf("%s%s %c %s", aPrefix, o.Name().String(g.tm), op, bound))
|
||||
checks = append(checks, fmt.Sprintf("%s%s %c %s", aPrefix, o.Name().Str(g.tm), op, bound))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
return fmt.Errorf("TODO: iterate over more than one variable")
|
||||
}
|
||||
v := vars[0].Var()
|
||||
name := v.Name().String(g.tm)
|
||||
name := v.Name().Str(g.tm)
|
||||
b.writes("{\n")
|
||||
|
||||
// TODO: don't assume that the slice is a slice of u8. In particular,
|
||||
@@ -252,7 +252,7 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
b.writes("return ")
|
||||
if len(g.currFunk.astFunc.Out().Fields()) == 0 {
|
||||
if retExpr != nil {
|
||||
return fmt.Errorf("return expression %q incompatible with empty return type", retExpr.String(g.tm))
|
||||
return fmt.Errorf("return expression %q incompatible with empty return type", retExpr.Str(g.tm))
|
||||
}
|
||||
} else if retExpr == nil {
|
||||
// TODO: should a bare "return" imply "return out"?
|
||||
@@ -277,15 +277,15 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
// cv := n.XType().ArrayLength().ConstValue()
|
||||
// // TODO: check that cv is within size_t's range.
|
||||
// g.printf("{ size_t i; for (i = 0; i < %d; i++) { %s%s[i] = $DEFAULT_VALUE; }}\n",
|
||||
// cv, vPrefix, n.Name().String(g.tm))
|
||||
// cv, vPrefix, n.Name().Str(g.tm))
|
||||
return fmt.Errorf("TODO: array initializers for non-zero default values")
|
||||
}
|
||||
// TODO: arrays of arrays.
|
||||
name := n.Name().String(g.tm)
|
||||
name := n.Name().Str(g.tm)
|
||||
b.printf("memset(%s%s, 0, sizeof(%s%s));\n", vPrefix, name, vPrefix, name)
|
||||
|
||||
default:
|
||||
b.printf("%s%s = ", vPrefix, n.Name().String(g.tm))
|
||||
b.printf("%s%s = ", vPrefix, n.Name().Str(g.tm))
|
||||
if v := n.Value(); v != nil {
|
||||
if err := g.writeExpr(b, v, replaceCallSuspendibles, parenthesesMandatory, 0); err != nil {
|
||||
return err
|
||||
@@ -482,7 +482,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
g.currFunk.usesScratch = true
|
||||
// TODO: don't hard-code [0], and allow recursive coroutines.
|
||||
scratchName := fmt.Sprintf("self->private_impl.%s%s[0].scratch",
|
||||
cPrefix, g.currFunk.astFunc.Name().String(g.tm))
|
||||
cPrefix, g.currFunk.astFunc.Name().Str(g.tm))
|
||||
|
||||
b.printf("%s = ", scratchName)
|
||||
x := n.Args()[0].Arg().Value()
|
||||
@@ -521,7 +521,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
|
||||
} else if isThisMethod(g.tm, n, "decode_header", 1) {
|
||||
b.printf("status = %s%s__decode_header(self, %ssrc);\n",
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm), aPrefix)
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().Str(g.tm), aPrefix)
|
||||
if err := g.writeLoadExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -531,7 +531,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
|
||||
} else if isThisMethod(g.tm, n, "decode_lsd", 1) {
|
||||
b.printf("status = %s%s__decode_lsd(self, %ssrc);\n",
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm), aPrefix)
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().Str(g.tm), aPrefix)
|
||||
if err := g.writeLoadExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -539,7 +539,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
|
||||
} else if isThisMethod(g.tm, n, "decode_extension", 1) {
|
||||
b.printf("status = %s%s__decode_extension(self, %ssrc);\n",
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm), aPrefix)
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().Str(g.tm), aPrefix)
|
||||
if err := g.writeLoadExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -547,7 +547,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
|
||||
} else if isThisMethod(g.tm, n, "decode_id", 2) {
|
||||
b.printf("status = %s%s__decode_id(self, %sdst, %ssrc);\n",
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm), aPrefix, aPrefix)
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().Str(g.tm), aPrefix, aPrefix)
|
||||
if err := g.writeLoadExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -563,7 +563,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
|
||||
b.printf("%sstatus %s%d = %s%s__decode_blocks(self, %sdst, %ssrc);\n",
|
||||
g.pkgPrefix, tPrefix, temp,
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm), aPrefix, aPrefix)
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().Str(g.tm), aPrefix, aPrefix)
|
||||
if err := g.writeLoadExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -571,7 +571,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
|
||||
} else if isThisMethod(g.tm, n, "decode_uncompressed", 2) {
|
||||
b.printf("status = %s%s__decode_uncompressed(self, %sdst, %ssrc);\n",
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm), aPrefix, aPrefix)
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().Str(g.tm), aPrefix, aPrefix)
|
||||
if err := g.writeLoadExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -579,7 +579,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
|
||||
} else if isThisMethod(g.tm, n, "decode_huffman_fast", 2) {
|
||||
b.printf("status = %s%s__decode_huffman_fast(self, %sdst, %ssrc);\n",
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm), aPrefix, aPrefix)
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().Str(g.tm), aPrefix, aPrefix)
|
||||
if err := g.writeLoadExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -587,7 +587,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
|
||||
} else if isThisMethod(g.tm, n, "decode_huffman_slow", 2) {
|
||||
b.printf("status = %s%s__decode_huffman_slow(self, %sdst, %ssrc);\n",
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm), aPrefix, aPrefix)
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().Str(g.tm), aPrefix, aPrefix)
|
||||
if err := g.writeLoadExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -595,7 +595,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
|
||||
} else if isThisMethod(g.tm, n, "init_fixed_huffman", 0) {
|
||||
b.printf("status = %s%s__init_fixed_huffman(self);\n",
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm))
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().Str(g.tm))
|
||||
if err := g.writeLoadExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -603,7 +603,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
|
||||
} else if isThisMethod(g.tm, n, "init_dynamic_huffman", 1) {
|
||||
b.printf("status = %s%s__init_dynamic_huffman(self, %ssrc);\n",
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm), aPrefix)
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().Str(g.tm), aPrefix)
|
||||
if err := g.writeLoadExprDerivedVars(b, n); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -611,7 +611,7 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
|
||||
} else if isThisMethod(g.tm, n, "init_huff", 4) {
|
||||
b.printf("status = %s%s__init_huff(self,",
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().String(g.tm))
|
||||
g.pkgPrefix, g.currFunk.astFunc.Receiver().Str(g.tm))
|
||||
for i, o := range n.Args() {
|
||||
if i != 0 {
|
||||
b.writes(",")
|
||||
@@ -667,14 +667,14 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
|
||||
// TODO: check if tPrefix_temp is an error, and return?
|
||||
|
||||
default:
|
||||
return fmt.Errorf("cannot convert Wuffs call %q to C", n.String(g.tm))
|
||||
return fmt.Errorf("cannot convert Wuffs call %q to C", n.Str(g.tm))
|
||||
}
|
||||
|
||||
} else {
|
||||
// TODO: fix this.
|
||||
//
|
||||
// This might involve calling g.writeExpr with replaceNothing??
|
||||
return fmt.Errorf("cannot convert Wuffs call %q to C", n.String(g.tm))
|
||||
return fmt.Errorf("cannot convert Wuffs call %q to C", n.Str(g.tm))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -706,7 +706,7 @@ func (g *gen) writeReadUXX(b *buffer, n *a.Expr, name string, size uint32, endia
|
||||
g.currFunk.usesScratch = true
|
||||
// TODO: don't hard-code [0], and allow recursive coroutines.
|
||||
scratchName := fmt.Sprintf("self->private_impl.%s%s[0].scratch",
|
||||
cPrefix, g.currFunk.astFunc.Name().String(g.tm))
|
||||
cPrefix, g.currFunk.astFunc.Name().Str(g.tm))
|
||||
|
||||
b.printf("if (WUFFS_BASE__LIKELY(%srend_src - %srptr_src >= %d)) {", bPrefix, bPrefix, size/8)
|
||||
b.printf("%s%d = wuffs_base__load_u%d%s(%srptr_src);\n", tPrefix, temp1, size, endianness, bPrefix)
|
||||
|
||||
@@ -79,7 +79,7 @@ func (g *gen) findDerivedVars() {
|
||||
func (g *gen) writeLoadDerivedVar(b *buffer, name t.ID, typ *a.TypeExpr, header bool) error {
|
||||
// TODO: remove this hack. We're picking up the wrong name for "src:r,
|
||||
// dummy:in.src".
|
||||
if name.String(g.tm) == "dummy" {
|
||||
if name.Str(g.tm) == "dummy" {
|
||||
name = g.tm.ByName("src")
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func (g *gen) writeLoadDerivedVar(b *buffer, name t.ID, typ *a.TypeExpr, header
|
||||
if _, ok := g.currFunk.derivedVars[name]; !ok {
|
||||
return nil
|
||||
}
|
||||
nameStr := name.String(g.tm)
|
||||
nameStr := name.Str(g.tm)
|
||||
switch typ.Name().Key() {
|
||||
case t.KeyReader1:
|
||||
if header {
|
||||
@@ -156,7 +156,7 @@ func (g *gen) writeLoadDerivedVar(b *buffer, name t.ID, typ *a.TypeExpr, header
|
||||
func (g *gen) writeSaveDerivedVar(b *buffer, name t.ID, typ *a.TypeExpr, footer bool) error {
|
||||
// TODO: remove this hack. We're picking up the wrong name for "src:r,
|
||||
// dummy:in.src".
|
||||
if name.String(g.tm) == "dummy" {
|
||||
if name.Str(g.tm) == "dummy" {
|
||||
name = g.tm.ByName("src")
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ func (g *gen) writeSaveDerivedVar(b *buffer, name t.ID, typ *a.TypeExpr, footer
|
||||
if _, ok := g.currFunk.derivedVars[name]; !ok {
|
||||
return nil
|
||||
}
|
||||
nameStr := name.String(g.tm)
|
||||
nameStr := name.Str(g.tm)
|
||||
switch typ.Name().Key() {
|
||||
case t.KeyReader1:
|
||||
b.printf("if (%s%s.buf) {", aPrefix, nameStr)
|
||||
@@ -223,7 +223,7 @@ func (g *gen) writeLoadExprDerivedVars(b *buffer, n *a.Expr) error {
|
||||
for _, o := range n.Args() {
|
||||
o := o.Arg()
|
||||
// TODO: don't hard-code these.
|
||||
if s := o.Value().String(g.tm); s != "in.dst" && s != "in.src" {
|
||||
if s := o.Value().Str(g.tm); s != "in.dst" && s != "in.src" {
|
||||
continue
|
||||
}
|
||||
if err := g.writeLoadDerivedVar(b, o.Name(), o.Value().MType(), false); err != nil {
|
||||
@@ -243,7 +243,7 @@ func (g *gen) writeSaveExprDerivedVars(b *buffer, n *a.Expr) error {
|
||||
for _, o := range n.Args() {
|
||||
o := o.Arg()
|
||||
// TODO: don't hard-code these.
|
||||
if s := o.Value().String(g.tm); s != "in.dst" && s != "in.src" {
|
||||
if s := o.Value().Str(g.tm); s != "in.dst" && s != "in.src" {
|
||||
continue
|
||||
}
|
||||
if err := g.writeSaveDerivedVar(b, o.Name(), o.Value().MType(), false); err != nil {
|
||||
@@ -294,7 +294,7 @@ func (g *gen) visitVars(b *buffer, block []*a.Node, depth uint32, f func(*gen, *
|
||||
}
|
||||
|
||||
func (g *gen) writeResumeSuspend1(b *buffer, n *a.Var, suspend bool) error {
|
||||
local := fmt.Sprintf("%s%s", vPrefix, n.Name().String(g.tm))
|
||||
local := fmt.Sprintf("%s%s", vPrefix, n.Name().Str(g.tm))
|
||||
|
||||
if typ := n.XType(); typ.HasPointers() {
|
||||
if suspend {
|
||||
@@ -319,7 +319,7 @@ func (g *gen) writeResumeSuspend1(b *buffer, n *a.Var, suspend bool) error {
|
||||
} else {
|
||||
lhs := local
|
||||
// TODO: don't hard-code [0], and allow recursive coroutines.
|
||||
rhs := fmt.Sprintf("self->private_impl.%s%s[0].%s", cPrefix, g.currFunk.astFunc.Name().String(g.tm), lhs)
|
||||
rhs := fmt.Sprintf("self->private_impl.%s%s[0].%s", cPrefix, g.currFunk.astFunc.Name().Str(g.tm), lhs)
|
||||
if suspend {
|
||||
lhs, rhs = rhs, lhs
|
||||
}
|
||||
@@ -342,7 +342,7 @@ func (g *gen) writeResumeSuspend1(b *buffer, n *a.Var, suspend bool) error {
|
||||
}
|
||||
|
||||
return fmt.Errorf("cannot resume or suspend a local variable %q of type %q",
|
||||
n.Name().String(g.tm), n.XType().String(g.tm))
|
||||
n.Name().Str(g.tm), n.XType().Str(g.tm))
|
||||
}
|
||||
|
||||
func (g *gen) writeResumeSuspend(b *buffer, block []*a.Node, suspend bool) error {
|
||||
@@ -359,7 +359,7 @@ func (g *gen) writeVars(b *buffer, block []*a.Node, skipPointerTypes bool, skipI
|
||||
if skipIterateVariables && n.IterateVariable() {
|
||||
return nil
|
||||
}
|
||||
if err := g.writeCTypeName(b, n.XType(), vPrefix, n.Name().String(g.tm)); err != nil {
|
||||
if err := g.writeCTypeName(b, n.XType(), vPrefix, n.Name().Str(g.tm)); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(";\n")
|
||||
|
||||
Reference in new issue
Block a user