Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update system methods. #1155

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/Neo.Compiler.CSharp/MethodConvert/ConstructorConvert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ private void ProcessFields(SemanticModel model)
{
ProcessFieldInitializer(model, fields[i], () =>
{
AddInstruction(OpCode.LDARG0);
Push(i);
_instructionsBuilder.LdArg0();
_instructionsBuilder.Push(i);
}, () =>
{
AddInstruction(OpCode.SETITEM);
_instructionsBuilder.SetItem();
});
}
}
Expand Down Expand Up @@ -61,36 +61,35 @@ private void ProcessConstructorInitializer(SemanticModel model)

private void ProcessStaticFields(SemanticModel model)
{
foreach (INamedTypeSymbol @class in _context.StaticFieldSymbols.Select(p => p.ContainingType).Distinct<INamedTypeSymbol>(SymbolEqualityComparer.Default).ToArray())
foreach (INamedTypeSymbol @class in Context.StaticFieldSymbols.Select(p => p.ContainingType).Distinct<INamedTypeSymbol>(SymbolEqualityComparer.Default).ToArray())
{
foreach (IFieldSymbol field in @class.GetAllMembers().OfType<IFieldSymbol>())
{
if (field.IsConst || !field.IsStatic) continue;
ProcessFieldInitializer(model, field, null, () =>
{
byte index = _context.AddStaticField(field);
AccessSlot(OpCode.STSFLD, index);
byte index = Context.AddStaticField(field);
_instructionsBuilder.StSFld(index);
});
}
}
foreach (var (fieldIndex, type) in _context.VTables)
foreach (var (fieldIndex, type) in Context.VTables)
{
IMethodSymbol[] virtualMethods = type.GetAllMembers().OfType<IMethodSymbol>().Where(p => p.IsVirtualMethod()).ToArray();
for (int i = virtualMethods.Length - 1; i >= 0; i--)
{
IMethodSymbol method = virtualMethods[i];
if (method.IsAbstract)
{
Push((object?)null);
_instructionsBuilder.Push((object?)null);
}
else
{
InvokeMethod(model, method);
}
}
Push(virtualMethods.Length);
AddInstruction(OpCode.PACK);
AccessSlot(OpCode.STSFLD, fieldIndex);
_instructionsBuilder.Pack(virtualMethods.Length);
_instructionsBuilder.StSFld(fieldIndex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ internal partial class MethodConvert
/// <seealso href="https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/anonymous-types">Anonymous types</seealso>
private void ConvertAnonymousObjectCreationExpression(SemanticModel model, AnonymousObjectCreationExpressionSyntax expression)
{
AddInstruction(OpCode.NEWARRAY0);
_instructionsBuilder.NewArray0();
foreach (AnonymousObjectMemberDeclaratorSyntax initializer in expression.Initializers)
{
AddInstruction(OpCode.DUP);
_instructionsBuilder.Dup();
ConvertExpression(model, initializer.Expression);
AddInstruction(OpCode.APPEND);
_instructionsBuilder.Append();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ private void ConvertArrayCreationExpression(SemanticModel model, ArrayCreationEx
{
ConvertExpression(model, specifier.Sizes[0]);
if (type.ElementType.SpecialType == SpecialType.System_Byte)
AddInstruction(OpCode.NEWBUFFER);
_instructionsBuilder.NewBuffer();
else
AddInstruction(new Instruction { OpCode = OpCode.NEWARRAY_T, Operand = new[] { (byte)type.ElementType.GetStackItemType() } });
_instructionsBuilder.AddInstruction(new Instruction { OpCode = OpCode.NEWARRAY_T, Operand = new[] { (byte)type.ElementType.GetStackItemType() } });
}
else
{
Expand Down
Loading
Loading