Exemplo n.º 1
0
        public override ICompilationResult GetResult()
        {
            if (!(base.GetResult() is ExpressionCompilationResult resultWithGetter))
            {
                return(new ElementCompilationResult());
            }

            var reference = resultWithGetter.GetReference();

            if (reference == null)
            {
                return(new ElementCompilationResult());
            }
            var assignment  = new ReturnStatement(GetLocation(myArrowExpressionClause), reference);
            var instruction = new Instruction(assignment, MyParams.GetNewInstructionId());

            var instructionBlock = GetInstructionsConnectedSequentially(new List <IInstructionsContainer> {
                resultWithGetter, instruction
            });

            if (IsMethod)
            {
                MyParams.GetCurrentMethod().FillWithInstructions(instructionBlock);
                MyParams.FinishCurrentMethod();
                return(new ElementCompilationResult());
            }
            return(new ExpressionCompilationResult(instructionBlock, GetLocation(myArrowExpressionClause), reference: myReference));
        }
Exemplo n.º 2
0
        public override ICompilationResult GetResult()
        {
            var declaredElemMethod = myConstructorDeclaration.DeclaredElement;

            if (declaredElemMethod == null)
            {
                return(new ElementCompilationResult());
            }

            var instructionBlock = GetInstructionsConnectedSequentially(MyResults);

            var method = MyParams.GetCurrentMethod();

            method.FillWithInstructions(instructionBlock);
//      var baseMembers = MyParams.HierarchyMembers?.GetValuesSafe(declaredElemMethod);
//      if (baseMembers != null)
//      {
//        foreach (var baseMember in baseMembers)
//        {
//          var baseMethodId = CompilerUtils.GetMethodId(baseMember);
//          method.AddBase(baseMethodId);
//        }
//      }

            MyParams.FinishCurrentMethod();
            return(new ElementCompilationResult());
        }
        public override ICompilationResult GetResult()
        {
            var instructionBlock = GetInstructionsConnectedSequentially(MyResults);

            var method = MyParams.GetCurrentMethod();

            method.FillWithInstructions(instructionBlock);
            MyParams.FinishCurrentMethod();

            return(new ElementCompilationResult());
        }
Exemplo n.º 4
0
        public override ICompilationResult GetResult()
        {
            var declaredElemMethod = myAnonymousFunctionExpression.DeclaredElement;

            if (declaredElemMethod == null)
            {
                return(new ElementCompilationResult());
            }

            var results = MyChildToResult.Where(x => !(x.Key is ILambdaSignature)).Select(x => x.Value).ToList();

            var instructionBlock = GetInstructionsConnectedSequentially(results);

            var method = MyParams.GetCurrentMethod();

            method.FillWithInstructions(instructionBlock);
            MyParams.FinishCurrentMethod();
            return(new ExpressionCompilationResult(new InstructionBlock(), GetLocation(myAnonymousFunctionExpression), reference: myReference));
        }
Exemplo n.º 5
0
        public override ICompilationResult GetResult()
        {
            var method = MyParams.GetCurrentMethod();

            var declaredElemMethod = myMethodDeclaration.DeclaredElement;

            if (declaredElemMethod == null)
            {
                MyParams.FinishCurrentMethod();
                return(new ElementCompilationResult());
            }

            foreach (var attribute in myMethodDeclaration.AttributesEnumerable)
            {
                method.AddAttribute(attribute.Name.ShortName);
            }

            var instructionBlock = GetInstructionsConnectedSequentially(MyResults);

            if (CompilerUtils.NeedToSkipMethod(declaredElemMethod))
            {
                MyParams.FinishCurrentMethod();
                return(new ElementCompilationResult());
            }

            var baseMembers = MyParams.HierarchyMembers?.GetValuesSafe(declaredElemMethod);

            if (baseMembers != null)
            {
                foreach (var baseMember in baseMembers)
                {
                    var baseMethodId = CompilerUtils.GetMethodId(baseMember);
                    method.AddBase(baseMethodId);
                }
            }

            method.FillWithInstructions(instructionBlock);
            MyParams.FinishCurrentMethod();
            return(new MethodDeclarationCompilationResult(method));
        }