From ed1ecb1bf59f00f73c3322eea7be20d96fcdcbd0 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Sat, 23 Apr 2016 13:35:20 +0100 Subject: [PATCH] Converting land describe methods to specialize instdescribe. Copied from Perforce Change: 191607 ServerID: perforce.ravenbrook.com --- mps/code/cbs.c | 7 ++++--- mps/code/failover.c | 7 ++++--- mps/code/freelist.c | 7 ++++--- mps/code/land.c | 10 +++++----- mps/code/mpmst.h | 1 - 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/mps/code/cbs.c b/mps/code/cbs.c index abcce81dfb3..80750e66c34 100644 --- a/mps/code/cbs.c +++ b/mps/code/cbs.c @@ -1090,8 +1090,9 @@ fail: * See . */ -static Res cbsDescribe(Land land, mps_lib_FILE *stream, Count depth) +static Res cbsDescribe(Inst inst, mps_lib_FILE *stream, Count depth) { + Land land = CouldBeA(Land, inst); CBS cbs = CouldBeA(CBS, land); Res res; Res (*describe)(Tree, mps_lib_FILE *); @@ -1101,7 +1102,7 @@ static Res cbsDescribe(Land land, mps_lib_FILE *stream, Count depth) if (stream == NULL) return ResPARAM; - res = NextMethod(Land, CBS, describe)(land, stream, depth); + res = NextMethod(Inst, CBS, describe)(inst, stream, depth); if (res != ResOK) return res; @@ -1134,6 +1135,7 @@ static Res cbsDescribe(Land land, mps_lib_FILE *stream, Count depth) DEFINE_CLASS(Land, CBS, klass) { INHERIT_CLASS(klass, CBS, Land); + klass->protocol.describe = cbsDescribe; klass->protocol.finish = cbsFinish; klass->size = sizeof(CBSStruct); klass->init = cbsInit; @@ -1146,7 +1148,6 @@ DEFINE_CLASS(Land, CBS, klass) klass->findLast = cbsFindLast; klass->findLargest = cbsFindLargest; klass->findInZones = cbsFindInZones; - klass->describe = cbsDescribe; } DEFINE_CLASS(Land, CBSFast, klass) diff --git a/mps/code/failover.c b/mps/code/failover.c index ecabf01c62b..0a6e344a537 100644 --- a/mps/code/failover.c +++ b/mps/code/failover.c @@ -241,8 +241,9 @@ static Bool failoverFindInZones(Bool *foundReturn, Range rangeReturn, Range oldR } -static Res failoverDescribe(Land land, mps_lib_FILE *stream, Count depth) +static Res failoverDescribe(Inst inst, mps_lib_FILE *stream, Count depth) { + Land land = CouldBeA(Land, inst); Failover fo = CouldBeA(Failover, land); LandClass primaryClass, secondaryClass; Res res; @@ -252,7 +253,7 @@ static Res failoverDescribe(Land land, mps_lib_FILE *stream, Count depth) if (stream == NULL) return ResPARAM; - res = NextMethod(Land, Failover, describe)(land, stream, depth); + res = NextMethod(Inst, Failover, describe)(inst, stream, depth); if (res != ResOK) return res; @@ -273,6 +274,7 @@ static Res failoverDescribe(Land land, mps_lib_FILE *stream, Count depth) DEFINE_CLASS(Land, Failover, klass) { INHERIT_CLASS(klass, Failover, Land); + klass->protocol.describe = failoverDescribe; klass->protocol.finish = failoverFinish; klass->size = sizeof(FailoverStruct); klass->init = failoverInit; @@ -284,7 +286,6 @@ DEFINE_CLASS(Land, Failover, klass) klass->findLast = failoverFindLast; klass->findLargest = failoverFindLargest; klass->findInZones = failoverFindInZones; - klass->describe = failoverDescribe; } diff --git a/mps/code/freelist.c b/mps/code/freelist.c index f337824882b..e01f78edfa3 100644 --- a/mps/code/freelist.c +++ b/mps/code/freelist.c @@ -746,8 +746,9 @@ static Bool freelistDescribeVisitor(Land land, Range range, } -static Res freelistDescribe(Land land, mps_lib_FILE *stream, Count depth) +static Res freelistDescribe(Inst inst, mps_lib_FILE *stream, Count depth) { + Land land = CouldBeA(Land, inst); Freelist fl = CouldBeA(Freelist, land); Res res; Bool b; @@ -758,7 +759,7 @@ static Res freelistDescribe(Land land, mps_lib_FILE *stream, Count depth) if (stream == NULL) return ResPARAM; - res = NextMethod(Land, Freelist, describe)(land, stream, depth); + res = NextMethod(Inst, Freelist, describe)(inst, stream, depth); if (res != ResOK) return res; @@ -780,6 +781,7 @@ static Res freelistDescribe(Land land, mps_lib_FILE *stream, Count depth) DEFINE_CLASS(Land, Freelist, klass) { INHERIT_CLASS(klass, Freelist, Land); + klass->protocol.describe = freelistDescribe; klass->protocol.finish = freelistFinish; klass->size = sizeof(FreelistStruct); klass->init = freelistInit; @@ -792,7 +794,6 @@ DEFINE_CLASS(Land, Freelist, klass) klass->findLast = freelistFindLast; klass->findLargest = freelistFindLargest; klass->findInZones = freelistFindInZones; - klass->describe = freelistDescribe; } diff --git a/mps/code/land.c b/mps/code/land.c index b704af11783..1a13ec39fb6 100644 --- a/mps/code/land.c +++ b/mps/code/land.c @@ -391,7 +391,7 @@ Res LandFindInZones(Bool *foundReturn, Range rangeReturn, Range oldRangeReturn, Res LandDescribe(Land land, mps_lib_FILE *stream, Count depth) { - return Method(Land, land, describe)(land, stream, depth); + return Method(Inst, land, describe)(MustBeA(Inst, land), stream, depth); } @@ -451,7 +451,6 @@ Bool LandClassCheck(LandClass klass) CHECKL(FUNCHECK(klass->findLast)); CHECKL(FUNCHECK(klass->findLargest)); CHECKL(FUNCHECK(klass->findInZones)); - CHECKL(FUNCHECK(klass->describe)); CHECKS(LandClass, klass); return TRUE; } @@ -543,8 +542,9 @@ static Res landNoFindInZones(Bool *foundReturn, Range rangeReturn, Range oldRang return ResUNIMPL; } -static Res LandAbsDescribe(Land land, mps_lib_FILE *stream, Count depth) +static Res LandAbsDescribe(Inst inst, mps_lib_FILE *stream, Count depth) { + Land land = CouldBeA(Land, inst); LandClass klass; Res res; @@ -553,7 +553,7 @@ static Res LandAbsDescribe(Land land, mps_lib_FILE *stream, Count depth) if (stream == NULL) return ResPARAM; - res = InstDescribe(CouldBeA(Inst, land), stream, depth); + res = NextMethod(Inst, Land, describe)(inst, stream, depth); if (res != ResOK) return res; @@ -575,6 +575,7 @@ DEFINE_CLASS(Inst, LandClass, klass) DEFINE_CLASS(Land, Land, klass) { INHERIT_CLASS(&klass->protocol, Land, Inst); + klass->protocol.describe = LandAbsDescribe; klass->protocol.finish = LandAbsFinish; klass->size = sizeof(LandStruct); klass->init = LandAbsInit; @@ -587,7 +588,6 @@ DEFINE_CLASS(Land, Land, klass) klass->findLast = landNoFind; klass->findLargest = landNoFind; klass->findInZones = landNoFindInZones; - klass->describe = LandAbsDescribe; klass->sig = LandClassSig; } diff --git a/mps/code/mpmst.h b/mps/code/mpmst.h index a271d7b010b..90f4d260a04 100644 --- a/mps/code/mpmst.h +++ b/mps/code/mpmst.h @@ -583,7 +583,6 @@ typedef struct LandClassStruct { LandFindMethod findLast; /* find last range of given size */ LandFindMethod findLargest; /* find largest range */ LandFindInZonesMethod findInZones; /* find first range of given size in zone set */ - LandDescribeMethod describe; /* describe the land */ Sig sig; /* .class.end-sig */ } LandClassStruct;