private bool TryAdaptExpression(JassMapScriptAdapterContext context, IExpressionSyntax?expression, [NotNullWhen(true)] out IExpressionSyntax?adaptedExpression) { return(expression switch { JassFunctionReferenceExpressionSyntax functionReferenceExpression => TryAdaptFunctionReferenceExpression(context, functionReferenceExpression, out adaptedExpression), JassInvocationExpressionSyntax invocationExpression => TryAdaptInvocationExpression(context, invocationExpression, out adaptedExpression), JassArrayReferenceExpressionSyntax arrayReferenceExpression => TryAdaptArrayReferenceExpression(context, arrayReferenceExpression, out adaptedExpression), JassVariableReferenceExpressionSyntax variableReferenceExpression => TryAdaptVariableReferenceExpression(context, variableReferenceExpression, out adaptedExpression), JassParenthesizedExpressionSyntax parenthesizedExpression => TryAdaptParenthesizedExpression(context, parenthesizedExpression, out adaptedExpression), JassUnaryExpressionSyntax unaryExpression => TryAdaptUnaryExpression(context, unaryExpression, out adaptedExpression), JassBinaryExpressionSyntax binaryExpression => TryAdaptBinaryExpression(context, binaryExpression, out adaptedExpression), _ => TryAdaptDummy(context, expression, out adaptedExpression), });
public ExpressionSyntax Transpile(IExpressionSyntax expression) { return(expression switch { JassCharacterLiteralExpressionSyntax characterLiteralExpression => Transpile(characterLiteralExpression), JassFourCCLiteralExpressionSyntax fourCCLiteralExpression => Transpile(fourCCLiteralExpression), JassHexadecimalLiteralExpressionSyntax hexadecimalLiteralExpression => Transpile(hexadecimalLiteralExpression), JassRealLiteralExpressionSyntax realLiteralExpression => Transpile(realLiteralExpression), JassOctalLiteralExpressionSyntax octalLiteralExpression => Transpile(octalLiteralExpression), JassDecimalLiteralExpressionSyntax decimalLiteralExpression => Transpile(decimalLiteralExpression), JassBooleanLiteralExpressionSyntax booleanLiteralExpression => Transpile(booleanLiteralExpression), JassStringLiteralExpressionSyntax stringLiteralExpression => Transpile(stringLiteralExpression), JassNullLiteralExpressionSyntax nullLiteralExpression => Transpile(nullLiteralExpression), JassFunctionReferenceExpressionSyntax functionReferenceExpression => Transpile(functionReferenceExpression), JassInvocationExpressionSyntax invocationExpression => Transpile(invocationExpression), JassArrayReferenceExpressionSyntax arrayReferenceExpression => Transpile(arrayReferenceExpression), JassVariableReferenceExpressionSyntax variableReferenceExpression => Transpile(variableReferenceExpression), JassParenthesizedExpressionSyntax parenthesizedExpression => Transpile(parenthesizedExpression), JassUnaryExpressionSyntax unaryExpression => Transpile(unaryExpression), JassBinaryExpressionSyntax binaryExpression => Transpile(binaryExpression), });
public ExpressionSyntax Transpile(JassVariableReferenceExpressionSyntax variableReferenceExpression) { return(SyntaxFactory.IdentifierName(Transpile(variableReferenceExpression.IdentifierName))); }
private bool TryAdaptVariableReferenceExpression(JassMapScriptAdapterContext context, JassVariableReferenceExpressionSyntax variableReferenceExpression, [NotNullWhen(true)] out IExpressionSyntax?adaptedVariableReferenceExpression) { if (!context.KnownLocalVariables.ContainsKey(variableReferenceExpression.IdentifierName.Name) && !context.KnownGlobalVariables.ContainsKey(variableReferenceExpression.IdentifierName.Name)) { context.Diagnostics.Add($"Unknown variable '{variableReferenceExpression.IdentifierName}'."); } adaptedVariableReferenceExpression = null; return(false); }
public void Render(JassVariableReferenceExpressionSyntax variableReferenceExpressionSyntax) { Render(variableReferenceExpressionSyntax.IdentifierName); }
public LuaExpressionSyntax Transpile(JassVariableReferenceExpressionSyntax variableReferenceExpression, out JassTypeSyntax type) { type = GetVariableType(variableReferenceExpression.IdentifierName); return(Transpile(variableReferenceExpression.IdentifierName)); }