Skip to content

Commit e11d020

Browse files
committed
do save supercalls for constructors
1 parent d45198b commit e11d020

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kscr-bytecode/Adapter/BytecodeAdapterV0_10.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ protected override void WriteMethod(Stream stream, StringCache strings, Method m
139139
Write(stream, strings, mtd.ReturnType.FullDetailedName);
140140
Write(stream, strings, mtd.SourceLocation);
141141
Write(stream, strings, mtd.Parameters.ToArray());
142+
if (mtd.Name == Method.ConstructorName)
143+
Write(stream, strings, mtd.SuperCalls.ToArray());
142144
Write(stream, strings, mtd.Body);
143145
}
144146

@@ -158,9 +160,14 @@ protected override Method ReadMethod(RuntimeBase vm, Stream stream, StringCache
158160
returnType = vm.FindType(ReadString(stream, strings));
159161
srcPos = Load<SourcefilePosition>(vm, strings, stream, pkg, cls);
160162
var parameters = ReadArray<MethodParameter>(vm, stream, strings, pkg, cls);
163+
StatementComponent[]? supers = name == Method.ConstructorName
164+
? ReadArray<StatementComponent>(vm, stream, strings, pkg, cls)
165+
: null;
161166
var body = Load<ExecutableCode>(vm, strings, stream, pkg, cls);
162167
var mtd = new Method(srcPos, cls!, name, returnType, mod) { Body = body };
163168
mtd.Parameters.AddRange(parameters);
169+
if (supers != null)
170+
mtd.SuperCalls.AddRange(supers);
164171
return mtd;
165172
}
166173

0 commit comments

Comments
 (0)