-
Notifications
You must be signed in to change notification settings - Fork 742
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
File content is loaded into special variables #6275
File content is loaded into special variables #6275
Conversation
semanticModel.TypeManager.GetMatchedFunctionOverload(syntax) is { VariableGenerator: { } } functionOverload) | ||
{ | ||
var variable = functionOverload.VariableGenerator(syntax, symbol, semanticModel.GetTypeInfo(syntax)); | ||
variables.Add(syntax, new InternalVariableSymbol($"$fxv#{variables.Count}", variable)); |
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.
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.
Fx - function, v - variable
…unctions-optimisation-5412
df964bf
to
2a531ca
Compare
@@ -315,5 +314,6 @@ private ImmutableArray<ResourceMetadata> GetAllResourceMetadata() | |||
public FileSymbol Root => this.Binder.FileSymbol; | |||
|
|||
public ResourceScope TargetScope => this.Binder.TargetScope; | |||
|
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.
[nit]: Extra newline.
|
||
namespace Bicep.Core.Semantics | ||
{ | ||
public class FunctionVariable |
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.
Mind moving this to Bicep.Core.Emit as well? Otherwise it looks good to me.
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.
|
||
if (variableAccessSyntax is ExplicitVariableAccessSyntax) |
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.
/// <summary> | ||
/// Represents an explicit reference to a variable | ||
/// </summary> | ||
public class ExplicitVariableAccessSyntax: VariableAccessSyntax |
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.
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.
Contributing a Pull Request
If you haven't already, read the full contribution guide. The guide may have changed since the last time you read it, so please double-check. Once you are done and ready to submit your PR, run through the relevant checklist below.
Contributing a feature
File loading functions are now loading files into special variables starting with
$
sign to avoid being overlapped by users. Then, in place where function is actually called, only variable access is emitted.This will help to avoid duplicating file content when load functions are used in variables that need to be inlined.
If the loadTextContent or loadFileAsBase64 is used directly in a variable declaration (
var file = loadTextContent('file.txt')
) then no special symbol is emitted.Fixes #5412