Eigenstate: myrddin-dev mailing list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/5] Wrap function argument type name emissions in getname


This strips prefixes from a few more places that they should be
stripped.
---
 myrglue.myr | 60 ++++++++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/myrglue.myr b/myrglue.myr
index c9cd975..0a0a5be 100644
--- a/myrglue.myr
+++ b/myrglue.myr
@@ -29,7 +29,7 @@ const emitmyrproto = {f, ctx
 		name = getname(ctx, name)
 		name = pfxstrip(ctx, name)
 		std.htput(defnames, name, void)
-		protostruct(f, name, st)
+		protostruct(ctx, f, name, st)
 	;;
 	bio.put(f, "\n")
 	for (name, en) : ctx.enums
@@ -43,13 +43,13 @@ const emitmyrproto = {f, ctx
 		name = getname(ctx, name)
 		if !std.hthas(defnames, name)
 			std.htput(defnames, name, void)
-			protodef(f, name, &td, defnames)
+			protodef(ctx, f, name, &td, defnames)
 		;;
 	;;
 	bio.put(f, "\n")
 	for (name, fn) : ctx.funcs
 		name = pfxstrip(ctx, name)
-		protofunc(f, name, fn)
+		protofunc(ctx, f, name, fn)
 	;;
 
 	for name : ctx.fwstructs
@@ -66,7 +66,7 @@ const emitmyrproto = {f, ctx
 
 	for (i, s) : iter.byenum(anonstructs)
 		n = std.bfmt(buf[:], "_anon{}", i)
-		protostruct(f, n, s)
+		protostruct(ctx, f, n, s)
 	;;
 
 	bio.put(f, ";;\n")
@@ -76,7 +76,7 @@ const emitmyrproto = {f, ctx
 const emitmyrglue = {f, ctx
 }
 
-const protostruct = {f, name, ty : cb.cstruct#
+const protostruct = {ctx, f, name, ty : cb.cstruct#
 	var nanon, pfx
 
 	nanon = 0
@@ -89,7 +89,7 @@ const protostruct = {f, name, ty : cb.cstruct#
 			bio.put(f, "\t\t{}{} : ", pfx, n)
 		| `std.None:	bio.put(f, "\t\t_a{} : ", nanon++)
 		;;
-		myrtype(f, &mty)
+		myrtype(ctx, f, &mty)
 		bio.put(f, "\n")
 	;;
 	bio.put(f, "\t;;\n")
@@ -110,7 +110,7 @@ const protoenum = {f, name, ty
 	bio.put(f, "\n")
 }
 
-const protodef = {f, name, ty, defnames
+const protodef = {ctx, f, name, ty, defnames
 	var pfx
 
 	pfx =  myrname(name) ? "_" : ""
@@ -121,25 +121,25 @@ const protodef = {f, name, ty, defnames
 		| (`Tag t, true):	
 			bio.put(f, "\ttype {} = void /* incomplete: {} */", name, name)
 		| (`Body b, true):
-			protostruct(f, name, b)
+			protostruct(ctx, f, name, b)
 		| (_, false):
 			bio.put(f, "\ttype {}{} = ", pfx, name)
-			myrtype(f, ty)
+			myrtype(ctx, f, ty)
 		;;
 	| _: 
 		bio.put(f, "\ttype {}{} = ", pfx, name)
-		myrtype(f, ty)
+		myrtype(ctx, f, ty)
 	;;
 	bio.put(f, "\n")
 }
 
-const protofunc = {f, name, fn
+const protofunc = {ctx, f, name, fn
 	var pfx
 
 	pfx = (myrname(name) ? "_" : "")
 	if abiclean(fn)
 		bio.put(f, "\textern const {}{}\t: (", pfx, name)
-		args(f, fn)
+		args(ctx, f, fn)
 		bio.put(f, ")\n")
 	else
 		std.fatal("abi-dirty functions not yet supported\n")
@@ -150,7 +150,7 @@ const abiclean = {fn
 	-> true
 }
 
-const args = {f, fn
+const args = {ctx, f, fn
 	var sep, pfx
 	var narg
 
@@ -161,18 +161,18 @@ const args = {f, fn
 		| (`std.Some n, ty):
 			pfx = (myrname(n) ? "_" : "")
 			bio.put(f, "{}{}{} : ", sep, pfx, n)
-			myrtype(f, &ty)
+			myrtype(ctx, f, &ty)
 		| (`std.None, ty):
 			bio.put(f, "{}a{} : ", sep, narg++)
-			myrtype(f, &ty)
+			myrtype(ctx, f, &ty)
 		;;
 		sep = ", "
 	;;
 	bio.put(f, " -> ")
-	myrtype(f, &fn.rty)
+	myrtype(ctx, f, &fn.rty)
 }
 
-const myrtype : (f : bio.file#, ty : cb.ctype# -> void)= {f, ty
+const myrtype : (ctx : bindctx#, f : bio.file#, ty : cb.ctype# -> void)= {ctx, f, ty
 	match ty
 	| &`cb.Tyvoid:		bio.write(f, "void")
 	| &`cb.Tylong:		bio.write(f, "int64")
@@ -185,36 +185,36 @@ const myrtype : (f : bio.file#, ty : cb.ctype# -> void)= {f, ty
 	| &`cb.Tyuint:		bio.write(f, "uint")
 	| &`cb.Tyushort:	bio.write(f, "uint16")
 	| &`cb.Tyuchar:		bio.write(f, "byte")
-	| &`cb.Typtr ct:	myrptr(f, ct)
-	| &`cb.Tyarr ca:	myrarr(f, ca)
-	| &`cb.Tystruct st:	myrstruct(f, st)
-	| &`cb.Tyenum e:	myrenum(f, e)
+	| &`cb.Typtr ct:	myrptr(ctx, f, ct)
+	| &`cb.Tyarr ca:	myrarr(ctx, f, ca)
+	| &`cb.Tystruct st:	myrstruct(ctx, f, st)
+	| &`cb.Tyenum e:	myrenum(ctx, f, e)
 	| &`cb.Tyfunc cfunc:	bio.put(f, "cfunc")
-	| &`cb.Tydefn cdefn:	bio.put(f, "{}", cdefn.name)
+	| &`cb.Tydefn cdefn:	bio.put(f, "{}", getname(ctx, cdefn.name))
 	;;
 }
 
-const myrptr = {f, ct
-	myrtype(f, ct);
+const myrptr = {ctx, f, ct
+	myrtype(ctx, f, ct);
 	bio.write(f, "#")
 }
 
-const myrarr = {f, ca
-	myrtype(f, &ca.subty);
+const myrarr = {ctx, f, ca
+	myrtype(ctx, f, &ca.subty);
 	match ca.len
 	| `std.Some n:	bio.put(f, "[{}]", n)
 	| `std.None:	bio.put(f, "[...]")
 	;;
 }
 
-const myrstruct = {f, s
+const myrstruct = {ctx, f, s
 	match s
 	| &`cb.Tag n:
 		bio.put(f, "void /* incomplete: {} */", n)
 	| &`cb.Body d:
 		match d.tag
 		| `std.Some n:
-			bio.put(f, "{}", n)
+			bio.put(f, "{}", getname(ctx, n))
 		| `std.None:
 			bio.put(f, "_anon{}", anonstructs.len)
 			std.slpush(&anonstructs, d)
@@ -222,13 +222,13 @@ const myrstruct = {f, s
 	;;
 }
 
-const myrenum = {f, e
+const myrenum = {ctx, f, e
 	match e
 	| &`cb.Tag n:
 		bio.put(f, "{}", n)
 	| &`cb.Body d:
 		match d.tag
-		| `std.Some n:	bio.put(f, "{}", n)
+		| `std.Some n:	bio.put(f, "{}", getname(ctx, n))
 		| `std.None:	bio.put(f, "int")
 		;;
 	;;
-- 
2.26.2


References:
[PATCH 0/5] mcbind patches, round 2"S. Gilles" <sgilles@xxxxxxx>