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

Directly move functions instead of making methods #1261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ddobrev
Copy link
Contributor

@ddobrev ddobrev commented Nov 7, 2019

This keeps the original functions instead of ignoring them which helps when rearranging passes - in particular when the pass for symbols is involved.

{
if (!function.IsGenerated) continue;

foreach (var function in from function in context.Functions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overkill usage of query LINQ

@@ -443,7 +445,10 @@ public override bool VisitClassDecl(Class @class)
}

GenerateClassConstructors(@class);

foreach (var function in from function in @class.Functions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

function.Parameters[0].Name, function.Parameters[1].Name);
Type retType = function.OriginalReturnType.Type.Desugar();
bool regular = retType.IsPrimitiveType(PrimitiveType.Bool);
WriteLineIndent($@"return {(regular ? string.Empty : "global::System.Convert.ToInt32(")}{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use some refactoring, and comments

List<Method> methods = HandleMissingOperatorOverloadPair(
@class, @class.Operators, op1, op2);
foreach (Method @operator in methods)
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some space between statements in this method

This keeps the original functions instead of ignoring them which helps when rearranging passes - in particular when the pass for symbols is involved.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
@@ -443,7 +443,8 @@ public override bool VisitClassDecl(Class @class)
}

GenerateClassConstructors(@class);

foreach (Function function in @class.Functions.Where(f => f.IsGenerated))
GenerateFunction(function, @class.Name);
GenerateClassMethods(@class.Methods);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline here.


Write("{0} {1}::{2}(", function.ReturnType, classSig,
function.Name);
Write($@"{function.ReturnType} {QualifiedIdentifier(@namespace)}::{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous version was easier to read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants