public static IEnumerable <SyntaxNode> BuildReturn(this RoslynEcsTranslator translator,
                                                    ReturnNodeModel returnModel, IPortModel portModel)
 {
     if (translator.context is CoroutineContext coroutineContext)
     {
         if (returnModel.ParentStackModel.OwningFunctionModel is CoroutineStackModel)
         {
             yield return(ReturnStatement(LiteralExpression(SyntaxKind.TrueLiteralExpression)));
         }
         else
         {
             coroutineContext.SkipStateBuilding = true;
             yield return(ReturnStatement(LiteralExpression(SyntaxKind.FalseLiteralExpression)));
         }
     }
     else
     {
         if (returnModel.InputPort == null)
         {
             yield return(ReturnStatement());
         }
         else
         {
             yield return(ReturnStatement(
                              translator.BuildPort(returnModel.InputPort).FirstOrDefault() as ExpressionSyntax));
         }
     }
 }
Esempio n. 2
0
        public IEnumerator MovingAStackMovesStackedNodeConnectedFloatingNode([Values] TestingMode mode)
        {
            var                     stackModel0   = GraphModel.CreateStack(string.Empty, new Vector2(-100, -100));
            ReturnNodeModel         ret           = stackModel0.CreateStackedNode <ReturnNodeModel>("return");
            BinaryOperatorNodeModel operatorModel = GraphModel.CreateBinaryOperatorNode(BinaryOperatorKind.Add, new Vector2(-100, -100));
            IConstantNodeModel      intModel      = GraphModel.CreateConstantNode("int", typeof(int).GenerateTypeHandle(GraphModel.Stencil), new Vector2(-150, -100));

            GraphModel.CreateEdge(ret.InputPort, operatorModel.OutputPort);
            GraphModel.CreateEdge(operatorModel.InputPortA, intModel.OutputPort);

            yield return(TestMove(mode,
                                  mouseDelta: new Vector2(20, 10),
                                  movedNodes: new INodeModel[] { stackModel0 },
                                  expectedMovedDependencies: new INodeModel[] { operatorModel, intModel }
                                  ));
        }
 public static IEnumerable <SyntaxNode> BuildReturn(this RoslynTranslator translator, ReturnNodeModel returnModel, IPortModel portModel)
 {
     if (returnModel.InputPort == null)
     {
         yield return(SyntaxFactory.ReturnStatement());
     }
     else
     {
         yield return(SyntaxFactory.ReturnStatement(
                          translator.BuildPort(returnModel.InputPort).FirstOrDefault() as ExpressionSyntax));
     }
 }
        public static IEnumerable <SyntaxNode> BuildReturn(this RoslynEcsTranslator translator, ReturnNodeModel returnModel, IPortModel portModel)
        {
            // TODO Implement Return statement in coroutine
            if (translator.context is CoroutineContext)
            {
                translator.AddError(returnModel, "Return node isn't allowed in Coroutine (e.g. Wait) execution stack for now. This feature is coming in a further release");
                yield break;
            }

            if (returnModel.InputPort == null)
            {
                yield return(ReturnStatement());
            }
            else
            {
                yield return(ReturnStatement(
                                 translator.BuildPort(returnModel.InputPort).FirstOrDefault() as ExpressionSyntax));
            }
        }
 public static IEnumerable <SyntaxNode> BuildReturn(this RoslynTranslator translator, ReturnNodeModel returnModel, IPortModel portModel)
 {
     if (returnModel.ParentStackModel.OwningFunctionModel.ReturnType == typeof(void).GenerateTypeHandle(translator.Stencil))
     {
         yield return(SyntaxFactory.ReturnStatement());
     }
     else
     {
         yield return(SyntaxFactory.ReturnStatement(
                          translator.BuildPort(returnModel.InputPort).FirstOrDefault() as ExpressionSyntax));
     }
 }