shithub: riscv

Download patch

ref: c52251c9b681430ec41ca6a3a73bf3e4ab7e3ddb
parent: c22fa6d5eb2ee6751c8e0946ab35e1328597a9b4
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Feb 23 20:31:58 EST 2017

libaml: make heap size field int, implement BankField definitions

--- a/sys/src/libaml/aml.c
+++ b/sys/src/libaml/aml.c
@@ -17,7 +17,7 @@
 
 struct Heap {
 	Heap	*link;
-	short	size;
+	int	size;
 	uchar	mark;
 	char	tag;
 };
@@ -139,7 +139,7 @@
 	Obad, Onop, Odebug,
 	Ostr, Obyte, Oword, Odword, Oqword, Oconst,
 	Onamec, Oname, Oscope, Oalias,
-	Oreg, Ofld, Oxfld, Opkg, Ovpkg, Oenv, Obuf, Omet, 
+	Oreg, Ofld, Oxfld, Obfld, Opkg, Ovpkg, Oenv, Obuf, Omet, 
 	Odev, Ocpu, Othz, Oprc,
 	Oadd, Osub, Omod, Omul, Odiv, Oshl, Oshr, Oand, Onand, Oor,
 	Onor, Oxor, Onot, Olbit, Orbit, Oinc, Odec,
@@ -282,6 +282,7 @@
 	int a;
 
 	a = sizeof(Heap) + size;
+	assert(a >= 0);
 	h = amlalloc(a);
 	h->size = size;
 	h->tag = tag;
@@ -393,6 +394,9 @@
 	int i, s;
 	Name *x;
 
+	if(dot == nil)
+		return nil;
+
 	s = !new;
 	if(*path == '\\'){
 		path++;
@@ -1335,6 +1339,12 @@
 			goto Out;
 		flags = ival(FP->arg[2]);
 		break;
+	case Obfld:
+		df = deref(FP->arg[1]);
+		if(df == nil || TAG(df) != 'f')
+			goto Out;
+		flags = ival(FP->arg[3]);
+		break;
 	}
 	p = PC;
 	if(p >= FP->end)
@@ -1374,6 +1384,12 @@
 			f->indexv = mki((bitoff/(wa*8))*wa);
 			f->index = FP->arg[0];
 			break;
+		case Obfld:
+			f->reg = FP->arg[0];
+			f->bitoff = bitoff;
+			f->indexv = FP->arg[2];
+			f->index = df;
+			break;
 		}
 		bitoff += n;
 		d->v = f;
@@ -1916,6 +1932,7 @@
 	[Oreg]		"OperationRegion",	"N1ii",		evalreg,
 	[Ofld]		"Field",		"{n1",		evalfield,
 	[Oxfld]		"IndexField",		"{nn1",		evalfield,
+	[Obfld]		"BankField",		"{nni1",	evalfield,
 
 	[Ocfld]		"CreateField",		"*iiN",		evalcfield,
 	[Ocfld0]	"CreateBitField",	"*iN",		evalcfield,
@@ -2038,7 +2055,7 @@
 /* 68 */	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,
 /* 70 */	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,
 /* 78 */	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,
-/* 80 */	Oreg,	Ofld,	Odev,	Ocpu,	Oprc,	Othz,	Oxfld,	Obad,
+/* 80 */	Oreg,	Ofld,	Odev,	Ocpu,	Oprc,	Othz,	Oxfld,	Obfld,
 /* 88 */	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,
 /* 90 */	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,
 /* 98 */	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,	Obad,