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>
@ddobrev ddobrev force-pushed the directly-move-functions branch from e94ae29 to f6f52ac Compare November 7, 2019 21:32
@@ -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.

@ddobrev ddobrev force-pushed the master branch 2 times, most recently from c8e9f62 to be54a8b Compare December 18, 2019 22:22
@ddobrev ddobrev force-pushed the master branch 6 times, most recently from 1610aa5 to 64b1efd Compare April 15, 2020 22:32
@ddobrev ddobrev force-pushed the master branch 2 times, most recently from c930b78 to c38556a Compare January 2, 2021 20:41
Base automatically changed from master to main March 12, 2021 10:52
@ddobrev ddobrev force-pushed the main branch 7 times, most recently from 4c1e9b8 to 2fdd082 Compare August 30, 2021 11:25
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.

2 participants