DKK007
PCGH-Community-Veteran(in)
Ich habe hier eine C# Klasse eines großen Integerdatentypes, die ich mit 2 Vergleichsfunktionen (MIN/MAX) erweitern soll.
Jedoch weiß ich nicht so wirklich, an welche Stelle mein Code soll.
UInt
UInt128
Es geht also darum, wohin die Implementierung für UInt128.Max hin muss.
Jedoch weiß ich nicht so wirklich, an welche Stelle mein Code soll.
UInt
Code:
[[COLOR=#00008b]Serializable]
[COLOR=#0000e0]public class [COLOR=#00008b]Min : [COLOR=#00008b]Binary<[COLOR=#00008b]ExpressionUInt, [COLOR=#00008b]ExpressionUInt> {
[COLOR=#0000e0]public [COLOR=#00008b]Min([COLOR=#00008b]ExpressionUInt a, [COLOR=#00008b]ExpressionUInt b) : [COLOR=#00008b]base(a, b) {
}
[COLOR=#0000e0]public override uint [COLOR=#008b8b]Value() {
[COLOR=#0000e0]return [COLOR=#00008b]Math.[COLOR=#008b8b]Min([COLOR=#800080]a.[COLOR=#008b8b]Value(), [COLOR=#800080]b.[COLOR=#008b8b]Value());
}
[COLOR=#0000e0]public override [COLOR=#00008b]ExpressionUInt [COLOR=#008b8b]Translate([COLOR=#00008b]TranslationContext ctx) {
[COLOR=#0000e0]return new [COLOR=#00008b]Min([COLOR=#800080]a.[COLOR=#008b8b]Translate(ctx), [COLOR=#800080]b.[COLOR=#008b8b]Translate(ctx));
}
[COLOR=#0000e0]public override void [COLOR=#008b8b]Compile([COLOR=#00008b]ExecutionContext exec, [COLOR=#0000e0]bool retval) {
[COLOR=#800080]a.[COLOR=#008b8b]Compile(exec, retval);
[COLOR=#800080]b.[COLOR=#008b8b]Compile(exec, retval);
[COLOR=#0000e0]if (retval) exec.[COLOR=#800080]codegen.[COLOR=#008b8b]Emit([COLOR=#00008b]OpCodes.[COLOR=#800080]Call,
[COLOR=#0000e0]typeof([COLOR=#00008b]System.[COLOR=#00008b]Math).[COLOR=#008b8b]GetMethod([COLOR=#a31515]"Min", [COLOR=#0000e0]new [COLOR=#00008b]Type[] { [COLOR=#0000e0]typeof([COLOR=#0000e0]uint), [COLOR=#0000e0]typeof([COLOR=#0000e0]uint) }));
}
}
UInt128
Code:
[[COLOR=#00008b]Serializable]
[COLOR=#0000e0]public class [COLOR=#00008b]Min : [COLOR=#00008b]Binary<[COLOR=#00008b]ExpressionU128, [COLOR=#00008b]ExpressionU128> {
[COLOR=#0000e0]public [COLOR=#00008b]Min([COLOR=#00008b]ExpressionU128 a, [COLOR=#00008b]ExpressionU128 b) : [COLOR=#00008b]base(a, b) {
}
[COLOR=#0000e0]public override [COLOR=#00008b]UInt128 [COLOR=#008b8b]Value() {
[COLOR=#007f00]// return UInt128.Min(a.Value(), b.Value());[COLOR=#0000e0]throw new [COLOR=#00008b]Exception();
}
[COLOR=#0000e0]public override [COLOR=#00008b]ExpressionU128 [COLOR=#008b8b]Translate([COLOR=#00008b]TranslationContext ctx) {
[COLOR=#0000e0]return new [COLOR=#00008b]Min([COLOR=#800080]a.[COLOR=#008b8b]Translate(ctx), [COLOR=#800080]b.[COLOR=#008b8b]Translate(ctx));
}
[COLOR=#0000e0]public override void [COLOR=#008b8b]Compile([COLOR=#00008b]ExecutionContext exec, [COLOR=#0000e0]bool retval) {
[COLOR=#007f00]// a.Compile(exec, retval);[COLOR=#007f00]// b.Compile(exec, retval);[COLOR=#007f00]// if (retval) exec.codegen.Emit(OpCodes.Call,[COLOR=#007f00]// typeof(UInt128).GetMethod("Min", new [] { typeof(UInt128), typeof(UInt128) }));}
}
Es geht also darum, wohin die Implementierung für UInt128.Max hin muss.