Skip to content

Commit

Permalink
Some update
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrawehr committed Apr 12, 2024
1 parent 729e432 commit ce861b7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
7 changes: 7 additions & 0 deletions tools/ArduinoCsCompiler/ClassMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public ClassMember(FieldInfo field, VariableKind variableType, int token, int si
Field = field;
StaticFieldSize = staticFieldSize;
Name = $"Field: {field.MemberInfoSignature()}";
FieldName = field.Name;
}

public ClassMember(MethodBase method, VariableKind variableType, int token, List<int> baseTokens)
Expand All @@ -37,6 +38,7 @@ public ClassMember(MethodBase method, VariableKind variableType, int token, List
SizeOfField = 0;
Method = method;
Name = $"Method: {method.MethodSignature()}";
FieldName = "(not a field)";
}

public string Name
Expand All @@ -54,6 +56,11 @@ public FieldInfo? Field
get;
}

public string FieldName
{
get;
}

/// <summary>
/// This value is non-zero for static fields. The length is the size of the root field required, so it is
/// the type length for value types but 4 (sizeof(void*)) for reference types.
Expand Down
2 changes: 1 addition & 1 deletion tools/ArduinoCsCompiler/IlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void Write(string sourceFile, string outFile)
UseSdkStyleProjectFormat = false,
};

using TextWriter tw = new StreamWriter("output.cs");
using TextWriter tw = new StreamWriter("C:\\projects\\iot4\\tools\\ArduinoCsCompiler\\samples\\BlinkingLedNano\\generated.cs");
SyntaxTree tree = new SyntaxTree();
var node = new NamespaceDeclaration("Decompiled");
tree.AddChild(node, SyntaxTree.MemberRole);
Expand Down
21 changes: 12 additions & 9 deletions tools/ArduinoCsCompiler/NanoGenerator/FieldWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -47,7 +50,7 @@ public bool HasAttribute(KnownAttribute attribute)
return _memberField.Field.GetValue(null); // Expect a constant here
}

public string Name => _memberField.Name;
public string Name => _memberField.FieldName;
public bool IsReadOnly => _memberField.Field.IsInitOnly;
public bool ReturnTypeIsRefReadOnly { get; }
public bool IsVolatile { get; }
Expand All @@ -67,9 +70,9 @@ public IType Type

public IEnumerable<IMember> ExplicitlyImplementedInterfaceMembers { get; }
public bool IsExplicitInterfaceImplementation { get; }
public bool IsVirtual { get; }
public bool IsOverride { get; }
public bool IsOverridable { get; }
public bool IsVirtual => false;
public bool IsOverride => false;
public bool IsOverridable => false;
public TypeParameterSubstitution Substitution { get; }

public IMember Specialize(TypeParameterSubstitution substitution)
Expand All @@ -88,10 +91,10 @@ public bool Equals(IMember? obj, TypeVisitor typeNormalization)
IType? IEntity.DeclaringType => Type;

public IModule? ParentModule { get; }
public Accessibility Accessibility { get; }
public bool IsStatic { get; }
public bool IsAbstract { get; }
public bool IsSealed { get; }
public Accessibility Accessibility => Accessibility.Public;
public bool IsStatic => _memberField.Field.IsStatic;
public bool IsAbstract => false;
public bool IsSealed => false;
public string ReflectionName { get; }
public string Namespace { get; }
public ICompilation Compilation { get; }
Expand Down

0 comments on commit ce861b7

Please sign in to comment.