Create script ID helper function

This commit is contained in:
Yoshi Askharoun
2025-07-21 01:08:02 -05:00
parent 13d2fc640b
commit e79bb7d755
+14 -5
View File
@@ -150,6 +150,18 @@ namespace Microsoft.Iris.Markup
public override bool HasDefaultConstructor => true; public override bool HasDefaultConstructor => true;
public MarkupTypeSchema ResolveScriptId(uint scriptId, out uint offset) => ResolveScriptId(this, scriptId, out offset);
public static MarkupTypeSchema ResolveScriptId(MarkupTypeSchema type, uint scriptId, out uint offset)
{
uint num = scriptId >> c_TypeDepthShift;
while (num != type._typeDepth)
type = type._baseType;
offset = scriptId & c_ScriptOffsetMask;
return type;
}
public object Run( public object Run(
IMarkupTypeBase markupType, IMarkupTypeBase markupType,
uint scriptId, uint scriptId,
@@ -157,11 +169,8 @@ namespace Microsoft.Iris.Markup
ParameterContext parameterContext) ParameterContext parameterContext)
{ {
ErrorManager.EnterContext(markupType.TypeSchema.Owner.ErrorContextUri, ignoreErrors); ErrorManager.EnterContext(markupType.TypeSchema.Owner.ErrorContextUri, ignoreErrors);
MarkupTypeSchema markupTypeSchema = this; var markupTypeSchema = ResolveScriptId(scriptId, out var offset);
uint num = scriptId >> c_TypeDepthShift; object obj = markupTypeSchema.RunAtOffset(markupType, offset, parameterContext);
while ((int)num != (int)markupTypeSchema._typeDepth)
markupTypeSchema = markupTypeSchema._baseType;
object obj = markupTypeSchema.RunAtOffset(markupType, scriptId & c_ScriptOffsetMask, parameterContext);
ErrorManager.ExitContext(); ErrorManager.ExitContext();
return obj; return obj;
} }