public string InjectServiceIntoConstructor( CSharpParserWrapper constructorInjectorParser, string constructorClassName, string constructorClassNamespace, string serviceIdentifier, string serviceNamespace, string serviceInterfaceType, FieldDeclaration fieldDeclaration, FixedParameter constructorParameter, SimpleAssignment constructorAssignment, ConstructorDeclaration constructorDeclaration, string tabString = null) { var controllerInjectorTree = constructorInjectorParser.GetParseTree(); var serviceControllerInjector = _serviceConstructorInjectorFactory.Create( tokenStream: constructorInjectorParser.Tokens, constructorClassName: constructorClassName, constructorClassNamespace: constructorClassNamespace, serviceIdentifier: serviceIdentifier, serviceNamespace: serviceNamespace, serviceInterfaceType: serviceInterfaceType, fieldDeclaration: fieldDeclaration, constructorParameter: constructorParameter, constructorAssignment: constructorAssignment, constructorDeclaration: constructorDeclaration, tabString: tabString); serviceControllerInjector.Visit(controllerInjectorTree); return(serviceControllerInjector.IsModified ? serviceControllerInjector.Rewriter.GetText() : null); }
public ServiceConstructorInjector Create( BufferedTokenStream tokenStream, string constructorClassName, string constructorClassNamespace, string serviceIdentifier, string serviceNamespace, string serviceInterfaceType, FieldDeclaration fieldDeclaration, FixedParameter constructorParameter, SimpleAssignment constructorAssignment, ConstructorDeclaration constructorDeclaration, string tabString = null) { return(new ServiceConstructorInjector( _stringUtilService, _cSharpParserService, _cSharpCommonStgService, _logger, tokenStream, constructorClassName, constructorClassNamespace, serviceIdentifier, serviceNamespace, serviceInterfaceType, fieldDeclaration, constructorParameter, constructorAssignment, constructorDeclaration, tabString)); }
public string RenderSimpleAssignment(SimpleAssignment simpleAssignment = null) { var stringTemplate = _cSharpCommonGroupFile.GetInstanceOf(StgCSharpCommon.SimpleAssignmentStatement.Name); stringTemplate.Add( StgCSharpCommon.SimpleAssignmentStatement.Params.LeftHandSide, simpleAssignment.LeftHandSide); stringTemplate.Add( StgCSharpCommon.SimpleAssignmentStatement.Params.RightHandSide, simpleAssignment.RightHandSide); return(stringTemplate.Render()); }
private void varSimple_MouseLeftButtonDown(object sender, System.Windows.RoutedEventArgs e) { // TODO: Add event handler implementation here. sa = new SimpleAssignment(); sa.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; sa.VerticalAlignment = System.Windows.VerticalAlignment.Center; sa.Show(); sa.Closed += new EventHandler(rv_Closed); //menuVar.Hide(); menuVar.Visibility = System.Windows.Visibility.Collapsed; //menuVar.Visibility = System.Windows.Visibility.Collapsed; }
public ServiceConstructorInjector( IStringUtilService stringUtilService, ICSharpParserService cSharpParserService, ICSharpCommonStgService cSharpCommonStgService, ILogger logger, BufferedTokenStream tokenStream, string constructorClassName, string constructorClassNamespace, string serviceIdentifier, string serviceNamespace, string serviceInterfaceType, FieldDeclaration fieldDeclaration, FixedParameter constructorParameter, SimpleAssignment constructorAssignment, ConstructorDeclaration constructorDeclaration, string tabString = null) { _stringUtilService = stringUtilService; _cSharpParserService = cSharpParserService; _cSharpCommonStgService = cSharpCommonStgService; _logger = logger; Tokens = tokenStream; Rewriter = new TokenStreamRewriter(tokenStream); _constructorClassName = constructorClassName; _constructorClassNamespace = constructorClassNamespace; _serviceIdentifier = serviceIdentifier; _serviceNamespace = serviceNamespace; _serviceInterfaceType = serviceInterfaceType; _fieldDeclaration = fieldDeclaration; _constructorParameter = constructorParameter; _constructorAssignment = constructorAssignment; _constructorDeclaration = constructorDeclaration; _tabString = tabString; _currentNamespace = new Stack <string>(); IsModified = false; _isConstructorClassFound = false; _isRewritten = false; }
private void btnEditRule_Click(object sender, System.Windows.RoutedEventArgs e) { //SlideIn.Begin(); if (lbxRules.SelectedIndex > -1) { switch (((ListBoxItemSource)lbxRules.SelectedItem).RuleType) { case EwavRuleType.Recode: rv = new RecodedVariable(true, (ListBoxItemSource)lbxRules.SelectedItem); rv.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; rv.VerticalAlignment = System.Windows.VerticalAlignment.Center; //rv.SelectedItem = ; rv.Show(); rv.Closed += new EventHandler(rv_Closed); break; case EwavRuleType.Assign: ae = new AssignedExpression(true, (ListBoxItemSource)lbxRules.SelectedItem); ae.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; ae.VerticalAlignment = System.Windows.VerticalAlignment.Center; ae.Show(); ae.Closed += new EventHandler(rv_Closed); break; case EwavRuleType.Formatted: fv = new FormattedValue(true, (ListBoxItemSource)lbxRules.SelectedItem); fv.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; fv.VerticalAlignment = System.Windows.VerticalAlignment.Center; fv.Show(); fv.Closed += new EventHandler(rv_Closed); break; case EwavRuleType.Simple: sa = new SimpleAssignment(true, (ListBoxItemSource)lbxRules.SelectedItem); sa.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; sa.VerticalAlignment = System.Windows.VerticalAlignment.Center; sa.Show(); sa.Closed += new EventHandler(rv_Closed); break; case EwavRuleType.conditional: ConditionalAssign ca = new ConditionalAssign(true, (ListBoxItemSource)lbxRules.SelectedItem); ca.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; ca.VerticalAlignment = System.Windows.VerticalAlignment.Center; ca.Show(); ca.Closed += new EventHandler(rv_Closed); break; case EwavRuleType.GroupVariable: GroupVariable gv = new GroupVariable(true, (ListBoxItemSource)lbxRules.SelectedItem); gv.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; gv.VerticalAlignment = System.Windows.VerticalAlignment.Center; gv.Show(); gv.Closed += new EventHandler(rv_Closed); break; default: break; } //if (((ListBoxItemSource)lbxRules.SelectedItem).RuleType == EwavRuleType.Recode) //{ //} } }
public override object VisitClass_declaration([NotNull] CSharpParser.Class_declarationContext context) { _currentClass.Push(context.identifier().GetText()); var classBaseType = context?.class_base()?.class_type()?.GetText(); _isControllerClass.Push(classBaseType == "Controller"); _isClassModified.Push(false); VisitChildren(context); if (_isClassModified.Peek() && _isControllerClass.Peek()) { var currentClass = GetCurrentClass(); var serviceInterfaceName = GetServiceInterfaceName(); var controllerServiceIdentifier = "breadcrumbService"; var fieldDeclaration = new FieldDeclaration() { Modifiers = new List <string>() { Keywords.Private, Keywords.Readonly }, Type = serviceInterfaceName, VariableDeclarator = new VariableDeclarator() { Identifier = $"_{controllerServiceIdentifier}" } }; var constructorParameter = new FixedParameter() { Type = serviceInterfaceName, Identifier = controllerServiceIdentifier }; var constructorAssignment = new SimpleAssignment() { LeftHandSide = $"_{controllerServiceIdentifier}", RightHandSide = controllerServiceIdentifier }; var constructorDeclaration = new ConstructorDeclaration() { Modifiers = new List <string>() { Keywords.Public }, Identifier = currentClass, FormalParameterList = new FormalParameterList() { FixedParameters = new List <FixedParameter>() { constructorParameter } }, Body = new ConstructorBody() { Statements = new List <Statement>() { new Statement() { SimpleAssignment = constructorAssignment } } } }; var preclassWhitespace = Tokens.GetHiddenTokensToLeft(context.Start.TokenIndex, Lexer.Hidden); int classBodyTabLevels = 1 + ((preclassWhitespace?.Count ?? 0) > 0 ? _stringUtilService.CalculateTabLevels(preclassWhitespace[0]?.Text ?? string.Empty, _tabString) : 0); int ctorBodyTabLevels = classBodyTabLevels + 1; int?finalConstantOrField = null; int?finalField = null; int?finalProperty = null; CSharpParser.Constructor_declarationContext constructorContext = null; bool hasServiceField = false; bool hasCtorParam = false; bool hasCtorAssignment = false; var members = context?.class_body()?.class_member_declarations()?.class_member_declaration(); if (members != null) { foreach (var member in members) { if (member.constant_declaration() != null) { finalConstantOrField = member.constant_declaration().Stop.TokenIndex; } else if (member.field_declaration() != null) { var fieldDec = member.field_declaration(); finalField = fieldDec.Stop.TokenIndex; finalConstantOrField = fieldDec.Stop.TokenIndex; if (fieldDec.type_().GetText() == serviceInterfaceName) { foreach (var varDec in fieldDec.variable_declarators().variable_declarator()) { if (varDec.identifier().GetText() == $"_{controllerServiceIdentifier}") { hasServiceField = true; break; } } } } else if (member.property_declaration() != null) { finalProperty = member.property_declaration().Stop.TokenIndex; } else if (member.constructor_declaration() != null) { constructorContext ??= member.constructor_declaration(); } } } int fieldStopIndex = finalField ?? finalConstantOrField ?? context.class_body().OPEN_BRACE().Symbol.TokenIndex; int?constructorStopIndex = null; var fieldStringBuilder = new StringBuilder(); StringBuilder constructorStringBuilder = null; if (!hasServiceField) { fieldStringBuilder.Append(_cSharpParserService.GenerateFieldDeclaration( fieldDeclaration, classBodyTabLevels, _tabString)); } if (constructorContext is null) { constructorStopIndex = finalProperty ?? finalConstantOrField ?? fieldStopIndex; constructorStringBuilder = constructorStopIndex == fieldStopIndex ? fieldStringBuilder : new StringBuilder(); constructorStringBuilder.Append( _cSharpParserService.GenerateConstructorDeclaration( constructorDeclaration, classBodyTabLevels, _tabString)); } else { CSharpParser.Fixed_parameterContext finalFixedParam = null; var formalParamList = constructorContext?.constructor_declarator()?.formal_parameter_list(); if (formalParamList != null) { var fixedParams = formalParamList.fixed_parameters(); if (fixedParams != null) { foreach (var fixedParam in fixedParams.fixed_parameter()) { if (fixedParam.type_().GetText() == serviceInterfaceName && fixedParam.identifier().GetText() == controllerServiceIdentifier) { hasCtorParam = true; break; } } finalFixedParam = fixedParams.fixed_parameter().Last(); } } if (!hasCtorParam) { var ctorParam = _cSharpCommonStgService.RenderFixedParameter(constructorParameter); int fixedParamStopIndex = finalFixedParam?.Stop?.TokenIndex ?? constructorContext.constructor_declarator().OPEN_PARENS().Symbol.TokenIndex; var paramStringBuilder = new StringBuilder(); if (finalFixedParam != null) { var preFinalParamWhitespace = Tokens.GetHiddenTokensToLeft( finalFixedParam?.Start?.TokenIndex ?? -1, Lexer.Hidden); int finalParamtabs = (preFinalParamWhitespace?.Count ?? 0) > 0 ? _stringUtilService.CalculateTabLevels( preFinalParamWhitespace?[0]?.Text ?? string.Empty, _tabString) : 0; if (finalParamtabs > 0) { paramStringBuilder.Append(",\r\n"); paramStringBuilder.Append(_stringUtilService.TabString( ctorParam, finalParamtabs, _tabString)); if (formalParamList?.parameter_array() != null) { var preParamArrayWhitespaceArray = Tokens.GetHiddenTokensToLeft( formalParamList.parameter_array().Start.TokenIndex, Lexer.Hidden); string preParamArrayWhitespace = preParamArrayWhitespaceArray.Count > 0 ? preParamArrayWhitespaceArray[0].Text : string.Empty; if (!Regex.IsMatch(preParamArrayWhitespace, @"\r?\n")) { IsModified = true; Rewriter.InsertBefore( formalParamList.parameter_array().Start.TokenIndex, "\r\n" + _stringUtilService.TabString(string.Empty, finalParamtabs, _tabString)); } } } else { paramStringBuilder.Append(", "); paramStringBuilder.Append(ctorParam); } } else { paramStringBuilder.Append("\r\n"); paramStringBuilder.Append( _stringUtilService.TabString(ctorParam, ctorBodyTabLevels, _tabString)); if (formalParamList?.parameter_array() != null) { var preParamArrayWhitespaceArray = Tokens.GetHiddenTokensToLeft( formalParamList.parameter_array().Start.TokenIndex, Lexer.Hidden); string preParamArrayWhitespace = preParamArrayWhitespaceArray.Count > 0 ? preParamArrayWhitespaceArray[0].Text : string.Empty; if (!Regex.IsMatch(preParamArrayWhitespace, $"\r?\n")) { IsModified = true; Rewriter.InsertBefore( formalParamList.parameter_array().Start.TokenIndex, "\r\n" + _stringUtilService.TabString(string.Empty, ctorBodyTabLevels, _tabString)); } } } var paramString = paramStringBuilder.ToString(); if (paramString.Length > 0) { IsModified = true; Rewriter.InsertAfter(fixedParamStopIndex, paramString); } } string ctorAssignString = _cSharpCommonStgService.RenderSimpleAssignment(constructorAssignment); var constructorBody = constructorContext?.constructor_body(); if (constructorBody.SEMICOLON() != null) { IsModified = true; Rewriter.Replace(constructorBody.SEMICOLON().Symbol.TokenIndex, _stringUtilService.TabString( $@"\r\n{{\r\n{_tabString}{ctorAssignString}\r\n}}", classBodyTabLevels, _tabString)); } else { var block = constructorBody.block(); var statementList = block?.statement_list()?.GetText(); if (statementList != null) { var assignmentMatchString = $@"[\s;{{]_{controllerServiceIdentifier}\s*=\s*{controllerServiceIdentifier}\s*;"; hasCtorAssignment = Regex.Match(statementList, assignmentMatchString).Success; } if (!hasCtorAssignment) { int?finalAssignment = block.statement_list().statement().Last().Stop.TokenIndex; int assignmentStopIndex = finalAssignment ?? block.OPEN_BRACE().Symbol.TokenIndex; var assignmentStringBuilder = new StringBuilder(); assignmentStringBuilder.Append("\r\n"); assignmentStringBuilder.Append(_stringUtilService.TabString( ctorAssignString, ctorBodyTabLevels, _tabString)); var postAssignmentStopWhitespaceArray = Tokens.GetHiddenTokensToRight( assignmentStopIndex, Lexer.Hidden); string postAssignmentStopWhitespace = postAssignmentStopWhitespaceArray.Count > 0 ? postAssignmentStopWhitespaceArray[0].Text : string.Empty; if (!Regex.IsMatch(postAssignmentStopWhitespace, @"\r?\n")) { assignmentStringBuilder.Append("\r\n"); } var assignmentString = assignmentStringBuilder.ToString(); if (assignmentString.Length > 0) { IsModified = true; Rewriter.InsertAfter(assignmentStopIndex, assignmentString); } } } } var fieldString = fieldStringBuilder.ToString(); if (fieldString.Length > 0) { IsModified = true; Rewriter.InsertAfter(fieldStopIndex, fieldString); } if (constructorStringBuilder != null && constructorStopIndex != fieldStopIndex) { var constructorString = constructorStringBuilder.ToString(); if (constructorString.Length > 0) { IsModified = true; Rewriter.InsertAfter(Tokens.Get(constructorStopIndex ?? -1), constructorString); } } } _ = _isClassModified.Pop(); _ = _isControllerClass.Pop(); _ = _currentClass.Pop(); return(null); }
private static List <ExpressionBase> ConvertRoslynExpressionToWandaExpression( SimpleCompoundStatement wandaBlock, ExpressionSyntax expressionSyntax) { var result = new List <ExpressionBase>(); switch (expressionSyntax) { case AssignmentExpressionSyntax assignmentExpressionSyntax: { var left = assignmentExpressionSyntax.Left; var operatorToken = assignmentExpressionSyntax.OperatorToken; var right = assignmentExpressionSyntax.Right; var leftValue = wandaBlock.ResolveLValue(result, left, true); var rightValue = wandaBlock.ResolveValue(result, right, true); AssignmentBase assignment = null; switch (operatorToken.Kind()) { case SyntaxKind.EqualsToken: assignment = new SimpleAssignment(leftValue, rightValue); break; case SyntaxKind.SlashEqualsToken: assignment = new OperatorAssignment(leftValue, rightValue, BinaryDivideOperator.Instance); break; case SyntaxKind.PlusEqualsToken: assignment = new OperatorAssignment(leftValue, rightValue, BinaryAddOperator.Instance); break; case SyntaxKind.MinusEqualsToken: assignment = new OperatorAssignment(leftValue, rightValue, BinarySubtractOperator.Instance); break; case SyntaxKind.AsteriskEqualsToken: assignment = new OperatorAssignment(leftValue, rightValue, BinaryMultiplyOperator.Instance); break; case SyntaxKind.PercentEqualsToken: assignment = new OperatorAssignment(leftValue, rightValue, BinaryRemainderOperator.Instance); break; case SyntaxKind.AmpersandEqualsToken: assignment = new OperatorAssignment(leftValue, rightValue, BinaryBitAndOperator.Instance); break; case SyntaxKind.CaretEqualsToken: assignment = new OperatorAssignment(leftValue, rightValue, BinaryBitXorOperator.Instance); break; case SyntaxKind.BarEqualsToken: assignment = new OperatorAssignment(leftValue, rightValue, BinaryBitOrOperator.Instance); break; case SyntaxKind.LessThanLessThanEqualsToken: assignment = new OperatorAssignment(leftValue, rightValue, BinaryBitShiftLeftOperator.Instance); break; case SyntaxKind.GreaterThanGreaterThanEqualsToken: assignment = new OperatorAssignment(leftValue, rightValue, BinaryBitShiftRightOperator.Instance); break; case SyntaxKind.QuestionQuestionEqualsToken: break; default: throw new ArgumentOutOfRangeException(); } if (assignment != null) { result.Add(assignment); } else { Log.Debug("{Left} {Operator} {Right}", left, operatorToken.Text, right); } break; } case PrefixUnaryExpressionSyntax unaryExpressionSyntax: { var operand = unaryExpressionSyntax.Operand; var leftValue = wandaBlock.ResolveLValue(result, operand, true); AssignmentBase assignment = null; var operatorToken = unaryExpressionSyntax.OperatorToken; switch (operatorToken.Kind()) { case SyntaxKind.PlusToken: case SyntaxKind.MinusToken: case SyntaxKind.TildeToken: case SyntaxKind.ExclamationToken: break; case SyntaxKind.PlusPlusToken: assignment = new OperatorAssignment(leftValue, IntegerLiteral.One, BinaryAddOperator.Instance); break; case SyntaxKind.MinusMinusToken: assignment = new OperatorAssignment(leftValue, IntegerLiteral.One, BinarySubtractOperator.Instance); break; case SyntaxKind.AmpersandToken: case SyntaxKind.AsteriskToken: case SyntaxKind.CaretToken: break; default: throw new ArgumentOutOfRangeException(); } if (assignment != null) { result.Add(assignment); } else { Log.Debug("{Operator} {Right}", operatorToken.Text, unaryExpressionSyntax.Operand); } break; } case PostfixUnaryExpressionSyntax unaryExpressionSyntax: { var operand = unaryExpressionSyntax.Operand; var leftValue = wandaBlock.ResolveLValue(result, operand, true); AssignmentBase assignment = null; var operatorToken = unaryExpressionSyntax.OperatorToken; switch (operatorToken.Kind()) { case SyntaxKind.PlusPlusToken: assignment = new OperatorAssignment(leftValue, IntegerLiteral.One, BinaryAddOperator.Instance); break; case SyntaxKind.MinusMinusToken: assignment = new OperatorAssignment(leftValue, IntegerLiteral.One, BinarySubtractOperator.Instance); break; case SyntaxKind.ExclamationToken: break; default: throw new ArgumentOutOfRangeException(); } if (assignment != null) { // todo: that's not right. The value returned by expression is not as simple result.Add(assignment); } else { Log.Debug("{Left} {Operator}", unaryExpressionSyntax.Operand, operatorToken.Text); } break; } case InvocationExpressionSyntax invocationExpressionSyntax: { var what = invocationExpressionSyntax.Expression.ToString(); FunctionCallParameter Selector(ArgumentSyntax x) { var xRefKindKeyword = x.RefKindKeyword.Kind(); var(isRef, isOut) = ( xRefKindKeyword == SyntaxKind.RefKeyword, xRefKindKeyword == SyntaxKind.OutKeyword); return(new FunctionCallParameter { Value = wandaBlock.ResolveValue(result, x.Expression, true), Out = isOut, Ref = isRef }); } var with = invocationExpressionSyntax.ArgumentList.Arguments.Select(Selector); var functionCallOperator = new FunctionCallOperator { Name = what }; functionCallOperator.Arguments.AddRange(with); result.Add(functionCallOperator); break; } case IdentifierNameSyntax identifierNameSyntax: { result.Add(wandaBlock.ResolveVariableByName(identifierNameSyntax.Identifier.Text)); break; } case LiteralExpressionSyntax literalExpressionSyntax: { result.Add(ResolveLiteral(literalExpressionSyntax)); break; } case ElementAccessExpressionSyntax elementAccessExpressionSyntax: { result.Add( ResolveRoslynElementAccessExpressionToWandaOperator(elementAccessExpressionSyntax, result, wandaBlock)); break; } case BinaryExpressionSyntax binaryExpressionSyntax: { var operatorToken = binaryExpressionSyntax.OperatorToken; PureBase operatorBase = null; LogicBase logicBase = null; switch (operatorToken.Kind()) { case SyntaxKind.PlusToken: operatorBase = BinaryAddOperator.Instance; break; case SyntaxKind.MinusToken: operatorBase = BinarySubtractOperator.Instance; break; case SyntaxKind.AsteriskToken: operatorBase = BinaryMultiplyOperator.Instance; break; case SyntaxKind.SlashToken: operatorBase = BinaryDivideOperator.Instance; break; case SyntaxKind.PercentToken: operatorBase = BinaryRemainderOperator.Instance; break; case SyntaxKind.LessThanLessThanToken: operatorBase = BinaryBitShiftLeftOperator.Instance; break; case SyntaxKind.GreaterThanGreaterThanToken: operatorBase = BinaryBitShiftRightOperator.Instance; break; case SyntaxKind.BarBarToken: logicBase = OrLogic.Instance; break; case SyntaxKind.AmpersandAmpersandToken: logicBase = AndLogic.Instance; break; case SyntaxKind.BarToken: operatorBase = BinaryBitOrOperator.Instance; break; case SyntaxKind.AmpersandToken: operatorBase = BinaryBitAndOperator.Instance; break; case SyntaxKind.CaretToken: operatorBase = BinaryBitXorOperator.Instance; break; case SyntaxKind.EqualsEqualsToken: logicBase = EqualLogic.Instance; break; case SyntaxKind.ExclamationEqualsToken: logicBase = NotEqualLogic.Instance; break; case SyntaxKind.LessThanToken: logicBase = LessLogic.Instance; break; case SyntaxKind.LessThanEqualsToken: logicBase = LessOrEqualLogic.Instance; break; case SyntaxKind.GreaterThanToken: logicBase = GreaterLogic.Instance; break; case SyntaxKind.GreaterThanEqualsToken: logicBase = GreaterOrEqualLogic.Instance; break; case SyntaxKind.IsKeyword: case SyntaxKind.AsKeyword: case SyntaxKind.QuestionQuestionToken: break; default: throw new ArgumentOutOfRangeException(); } switch (operatorBase != null, logicBase != null) { case (true, false): { var left = wandaBlock.ResolveValue(result, binaryExpressionSyntax.Left, true); var right = wandaBlock.ResolveValue(result, binaryExpressionSyntax.Right, true); var dummy = new DummyVariable { TypeRef = ApproximateResultTypeOfBinaryOperator(left, right) }; wandaBlock.LocalVariables.Add(dummy); var assignment = new SimpleAssignment(dummy, left); result.Add(assignment); var operatorAssignment = new OperatorAssignment(dummy, right, operatorBase); result.Add(operatorAssignment); break; } case (false, true): { var left = wandaBlock.ResolveValue(result, binaryExpressionSyntax.Left, true); var right = wandaBlock.ResolveValue(result, binaryExpressionSyntax.Right, true); var operatorAssignment = new BinaryLogicExpression(logicBase, left, right); result.Add(operatorAssignment); break; } case (false, false): { Log.Debug("BINARY: {Left} {Operator} {Right} ({Kind})", binaryExpressionSyntax.Left, operatorToken.Text, binaryExpressionSyntax.Right, operatorToken.Kind()); break; } default: throw new ArgumentOutOfRangeException(); } break; }
/// <summary> /// IExpressionリスト取得 /// </summary> /// <param name="operation">IOperationインスタンス</param> /// <param name="container">イベントコンテナ</param> /// <returns>IExpressionリスト</returns> public static List <IExpression> GetExpressionList(IOperation operation, EventContainer container) { List <IExpression> result = new List <IExpression>(); AbstractOperation instance = null; switch (operation) { // 式系 case ISimpleAssignmentOperation param: instance = new SimpleAssignment(param, container); break; case IInvocationOperation param: instance = new Invocation(param, container); break; case IBinaryOperation param: instance = new Binary(param, container); break; case IIncrementOrDecrementOperation param: instance = new Increment(param, container); break; case ICompoundAssignmentOperation param: instance = new CompoundAssignment(param, container); break; case IConversionOperation param: result.AddRange(GetExpressionList(param.Operand, container)); break; // 参照系 case IInstanceReferenceOperation param: instance = new InstanceReference(param, container); break; case IFieldReferenceOperation param: instance = new FieldReference(param, container); break; case IPropertyReferenceOperation param: instance = new PropertyReference(param, container); break; case ILocalReferenceOperation param: instance = new LocalReference(param, container); break; case IParameterReferenceOperation param: instance = new ParameterReference(param, container); break; case IArrayElementReferenceOperation param: instance = new ArrayElementReference(param, container); break; case IArgumentOperation param: instance = new Argument(param, container); break; // 生成系 case IObjectCreationOperation param: instance = new ObjectCreation(param, container); break; case IArrayCreationOperation param: instance = new ArrayCreation(param, container); break; case IArrayInitializerOperation param: instance = new ArrayInitializer(param, container); break; case IVariableDeclaratorOperation param: instance = new VariableDeclarator(param, container); break; // 直値 case ILiteralOperation param: instance = new Literal(param, container); break; // Switch Case系 case IDefaultCaseClauseOperation param: instance = new DefalutCase(param, container); break; case IDeclarationPatternOperation param: instance = new DeclarationPattern(param, container); break; //If系 case IIsPatternOperation param: instance = new IsPattern(param, container); break; case IIsTypeOperation param: instance = new IsType(param, container); break; default: Console.Write($" [{operation.Kind} is none] "); break; } // リスト追加 if (instance != null) { result.AddRange(instance.Expressions); } return(result); }