Repository navigation
[WIP] Support ListLiteralExpression '[]' in PowerShell #5761
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
Changes from all commits
9b8b5c7
3469218
c327e51
b58f1b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,8 +175,15 @@ public interface ICustomAstVisitor2 : ICustomAstVisitor | |
| object VisitDynamicKeywordStatement(DynamicKeywordStatementAst dynamicKeywordAst); | ||
| } | ||
|
|
||
| /// <summary/> | ||
| public interface ICustomAstVisitor3 : ICustomAstVisitor2 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think numbered interfaces made sense when the release cycle spanned years, but I'm worried we'll end up with
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One (maybe not awesome) idea is to avoid the problem for this feature is to add a The downside to this approach is that some analysis tools that aren't aware of list literals will analyze the ast as an array, e.g. they may incorrectly give warnings about performance.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about reusing the
I would like to see more discussion on this before updating the code. |
||
| { | ||
| /// <summary/> | ||
| object VisitListLiteral(ListLiteralAst listLiteralAst); | ||
| } | ||
|
|
||
| #if DEBUG | ||
| class CheckAllParentsSet : AstVisitor2 | ||
| class CheckAllParentsSet : AstVisitor3 | ||
| { | ||
| internal CheckAllParentsSet(Ast root) | ||
| { | ||
|
|
@@ -239,6 +246,7 @@ internal AstVisitAction CheckParent(Ast ast) | |
| public override AstVisitAction VisitInvokeMemberExpression(InvokeMemberExpressionAst ast) { return CheckParent(ast); } | ||
| public override AstVisitAction VisitArrayExpression(ArrayExpressionAst ast) { return CheckParent(ast); } | ||
| public override AstVisitAction VisitArrayLiteral(ArrayLiteralAst ast) { return CheckParent(ast); } | ||
| public override AstVisitAction VisitListLiteral(ListLiteralAst ast) { return CheckParent(ast); } | ||
| public override AstVisitAction VisitHashtable(HashtableAst ast) { return CheckParent(ast); } | ||
| public override AstVisitAction VisitScriptBlockExpression(ScriptBlockExpressionAst ast) { return CheckParent(ast); } | ||
| public override AstVisitAction VisitParenExpression(ParenExpressionAst ast) { return CheckParent(ast); } | ||
|
|
@@ -258,7 +266,7 @@ internal AstVisitAction CheckParent(Ast ast) | |
| /// <summary> | ||
| /// Check if <see cref="TypeConstraintAst"/> contains <see cref="TypeBuilder "/> type | ||
| /// </summary> | ||
| class CheckTypeBuilder : AstVisitor2 | ||
| class CheckTypeBuilder : AstVisitor3 | ||
| { | ||
| public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast) | ||
| { | ||
|
|
@@ -275,7 +283,7 @@ public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast) | |
| /// <summary> | ||
| /// Searches an AST, using the evaluation function provided by either of the constructors | ||
| /// </summary> | ||
| internal class AstSearcher : AstVisitor2 | ||
| internal class AstSearcher : AstVisitor3 | ||
| { | ||
| #region External interface | ||
|
|
||
|
|
@@ -408,6 +416,7 @@ protected AstVisitAction CheckScriptBlock(Ast ast) | |
| public override AstVisitAction VisitInvokeMemberExpression(InvokeMemberExpressionAst ast) { return Check(ast); } | ||
| public override AstVisitAction VisitArrayExpression(ArrayExpressionAst ast) { return Check(ast); } | ||
| public override AstVisitAction VisitArrayLiteral(ArrayLiteralAst ast) { return Check(ast); } | ||
| public override AstVisitAction VisitListLiteral(ListLiteralAst ast) { return Check(ast); } | ||
| public override AstVisitAction VisitHashtable(HashtableAst ast) { return Check(ast); } | ||
| public override AstVisitAction VisitScriptBlockExpression(ScriptBlockExpressionAst ast) { return CheckScriptBlock(ast); } | ||
| public override AstVisitAction VisitParenExpression(ParenExpressionAst ast) { return Check(ast); } | ||
|
|
@@ -559,4 +568,13 @@ public abstract class DefaultCustomAstVisitor2 : DefaultCustomAstVisitor, ICusto | |
| /// <summary/> | ||
| public virtual object VisitFunctionMember(FunctionMemberAst functionMemberAst) { return null; } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Default implementation of <see cref="ICustomAstVisitor3"/> interface | ||
| /// </summary> | ||
| public abstract class DefaultCustomAstVisitor3 : DefaultCustomAstVisitor2, ICustomAstVisitor3 | ||
| { | ||
| /// <summary/> | ||
| public virtual object VisitListLiteral(ListLiteralAst listExpressionAst) { return null; } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should add this to the interpreter - this way it stays as close as possible to original and/or the one used for
dynamicwhen now JIT is available.It is possible to add new instructions without touching the interpreter it that's how you want to do it - see
PowerShellLoopExpressionfor an example.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
NewListInitInstructionis a minor optimization which can be removed.But I need to implement
LightCompiler.CompileListInitExpressionbecause it's currently not implemented. Are you suggesting to not useListInitExpressionin our compiler generated code?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the method is now implemented: http://source.dot.net/#System.Linq.Expressions/System/Linq/Expressions/Interpreter/LightCompiler.cs,a988c37e1da7a799
I wonder if there is a supported way of invoking the interpreter now? We'd have to make sure they have any of our fixes first, but it'd be nice to not ship two copies of basically the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I can use their implementation then.