mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 16:52:18 +01:00
Prepare for more generic funcs, not just slices
This commit is contained in:
1 parent
33746151aa
commit
a9d5adc3fc
3 files changed
+15
-14
No files matched your search
+11
-10
@@ -134,18 +134,19 @@ var Funcs = []string{
|
|||||||
"image_config.initialize!(pixfmt u32, pixsub u32, width u32, height u32, num_loops u32)()",
|
"image_config.initialize!(pixfmt u32, pixsub u32, width u32, height u32, num_loops u32)()",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The "T" types here are generic placeholders for every "slice U" type. After
|
||||||
|
// parsing these SliceFunc strings (e.g. in the lang/check package), replace
|
||||||
|
// "T" with the "◊" diamond to denote a generic slice method, to avoid
|
||||||
|
// ambiguity with a user-defined, non-generic "T" type.
|
||||||
|
|
||||||
const (
|
const (
|
||||||
GenericReplaceFrom = t.IDSLICE
|
PlaceholderOldName = t.IDCapitalT
|
||||||
GenericReplaceTo = t.IDDiamond
|
PlaceholderNewName = t.IDDiamond
|
||||||
)
|
)
|
||||||
|
|
||||||
var SliceFuncs = []string{
|
var SliceFuncs = []string{
|
||||||
// The "SLICE" types here are generic placeholders for every "slice T"
|
"T.copy_from_slice(s T)(ret u64)",
|
||||||
// type. After parsing these strings (e.g. in the lang/check package),
|
"T.length()(ret u64)",
|
||||||
// replace "SLICE" with the "◊" diamond to denote a generic slice method,
|
"T.prefix(up_to u64)(ret T)",
|
||||||
// to avoid ambiguity with a user-defined, non-generic "SLICE" type.
|
"T.suffix(up_to u64)(ret T)",
|
||||||
"SLICE.copy_from_slice(s SLICE)(ret u64)",
|
|
||||||
"SLICE.length()(ret u64)",
|
|
||||||
"SLICE.prefix(up_to u64)(ret SLICE)",
|
|
||||||
"SLICE.suffix(up_to u64)(ret SLICE)",
|
|
||||||
}
|
}
|
||||||
@@ -110,8 +110,8 @@ func parseBuiltInFuncs(tm *t.Map, ss []string, generic bool) (map[t.QQID]*a.Func
|
|||||||
}
|
}
|
||||||
if generic {
|
if generic {
|
||||||
for i := range tokens {
|
for i := range tokens {
|
||||||
if tokens[i].ID == builtin.GenericReplaceFrom {
|
if tokens[i].ID == builtin.PlaceholderOldName {
|
||||||
tokens[i].ID = builtin.GenericReplaceTo
|
tokens[i].ID = builtin.PlaceholderNewName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -404,7 +404,7 @@ const (
|
|||||||
IDThis = ID(0xAB)
|
IDThis = ID(0xAB)
|
||||||
IDIn = ID(0xAC)
|
IDIn = ID(0xAC)
|
||||||
IDOut = ID(0xAD)
|
IDOut = ID(0xAD)
|
||||||
IDSLICE = ID(0xAE)
|
IDCapitalT = ID(0xAE)
|
||||||
IDBase = ID(0xAF)
|
IDBase = ID(0xAF)
|
||||||
|
|
||||||
IDMark = ID(0xB0)
|
IDMark = ID(0xB0)
|
||||||
@@ -588,7 +588,7 @@ var builtInsByID = [nBuiltInIDs]string{
|
|||||||
IDThis: "this",
|
IDThis: "this",
|
||||||
IDIn: "in",
|
IDIn: "in",
|
||||||
IDOut: "out",
|
IDOut: "out",
|
||||||
IDSLICE: "SLICE",
|
IDCapitalT: "T",
|
||||||
IDBase: "base",
|
IDBase: "base",
|
||||||
|
|
||||||
IDMark: "mark",
|
IDMark: "mark",
|
||||||
|
|||||||
Reference in new issue
Block a user