Ejemplo n.º 1
0
        private void ExportJumpBlock(JumpBlock jb, string functionReturnType)
        {
            switch (jb.JumpNode)
            {
            case ReturnStatementSyntax ret:
                ExportReturnStatement(ret, functionReturnType);
                break;

            case BreakStatementSyntax breakStmt:
                writer.WriteLine($"br ^{BlockId(jb.SuccessorBlock)} {GetLocation(breakStmt)} // break");
                break;

            case ContinueStatementSyntax continueStmt:
                writer.WriteLine($"br ^{BlockId(jb.SuccessorBlock)} {GetLocation(continueStmt)} // continue");
                break;

            case ThrowStatementSyntax throwStmt:
                // Should we transfer to a catch block if we are inside a try/catch?
                // See: https://github.com/SonarSource/SonarCBDE/issues/111
                writer.WriteLine($"cbde.throw %{OpId(throwStmt.Expression)} :  {MlirType(throwStmt.Expression)} {GetLocation(throwStmt)}");
                break;

            default:
                Debug.Assert(false, "Unknown kind of JumpBlock");
                break;
            }
        }
 private static bool IsJumpRemovable(JumpBlock jumpBlock, int yieldStatementCount)
 {
     return(!IsInsideSwitch(jumpBlock) &&
            !IsReturnWithExpression(jumpBlock) &&
            !IsThrow(jumpBlock) &&
            !IsOnlyYieldBreak(jumpBlock, yieldStatementCount) &&
            jumpBlock.SuccessorBlock == jumpBlock.WouldBeSuccessor);
 }
Ejemplo n.º 3
0
    private Vector3 startPos;                                      //座標ズレ対策のlocalTransform;

    // Start is called before the first frame update
    void Start()
    {
        camera = Camera.main;

        playerManager = playerManageObj.GetComponent <PlayerManager>();
        jumpBlock     = playerRotateAxis.GetComponent <JumpBlock>();
        hookShot      = attackSoumen.GetComponent <HookShot>();

        startPos = transform.localPosition;
    }
        private static bool IsReturnWithExpression(JumpBlock jumpBlock)
        {
            var returnStatement = jumpBlock.JumpNode as ReturnStatementSyntax;

            return(returnStatement != null && returnStatement.Expression != null);
        }
        private static bool IsThrow(JumpBlock jumpBlock)
        {
            var throwStatement = jumpBlock.JumpNode as ThrowStatementSyntax;

            return(throwStatement != null);
        }
        private static bool IsOnlyYieldBreak(JumpBlock jumpBlock, int yieldStatementCount)
        {
            var yieldStatement = jumpBlock.JumpNode as YieldStatementSyntax;

            return(yieldStatement != null && yieldStatementCount == 1);
        }
 private static bool IsInsideSwitch(JumpBlock jumpBlock)
 {
     // Not reporting inside switch, as the jumps might not be removable
     return(jumpBlock.JumpNode.AncestorsAndSelf().OfType <SwitchStatementSyntax>().Any());
 }
Ejemplo n.º 8
0
 private static bool IsReturnWithExpression(JumpBlock jumpBlock)
 {
     return(jumpBlock.JumpNode is ReturnStatementSyntax returnStatement && returnStatement.Expression != null);
 }
Ejemplo n.º 9
0
 private static bool IsThrow(JumpBlock jumpBlock)
 {
     return(jumpBlock.JumpNode is ThrowStatementSyntax);
 }
Ejemplo n.º 10
0
 private static bool IsOnlyYieldBreak(JumpBlock jumpBlock, int yieldStatementCount)
 {
     return(jumpBlock.JumpNode is YieldStatementSyntax yieldStatement &&
            yieldStatement.IsKind(SyntaxKind.YieldBreakStatement) &&
            yieldStatementCount == 1);
 }
Ejemplo n.º 11
0
 private static bool IsYieldReturn(JumpBlock jumpBlock)
 {
     // yield return cannot be redundant
     return(jumpBlock.JumpNode is YieldStatementSyntax yieldStatement &&
            yieldStatement.IsKind(SyntaxKind.YieldReturnStatement));
 }
Ejemplo n.º 12
0
 private static bool IsValidJumpInsideTryCatch(JumpBlock jumpBlock)
 {
     return(jumpBlock.WouldBeSuccessor is BranchBlock branchBlock &&
            branchBlock.BranchingNode is FinallyClauseSyntax &&
            branchBlock.AllSuccessorBlocks.Count > 1);
 }
Ejemplo n.º 13
0
    // Use this for initialization
    void Awake()
    {
        count = 0;

        if (gameObject.name == "Hero1") {
            characterID = 0;
            player = GetComponent<Player> ();
        }
        else if (gameObject.name == "Hero2"){
            characterID = 1;
            player = GetComponent<Player> ();
        }
        else if (GetComponent<MiniCopterBlock> ()) {
            characterID = 2;
            miniCopterBlock = GetComponent<MiniCopterBlock> ();
        }
        else if (gameObject.GetComponent<TankBlock> ()) {
            characterID = 3;
            tankBlock = GetComponent<TankBlock> ();
        }
        else if (GetComponent<JumpBlock> ()) {
            characterID = 4;
            jumpBlock = GetComponent<JumpBlock> ();
        }
        else if (GetComponent<TelekineticBlock> ()) {
            characterID = 5;
            telekineticBlock = GetComponent<TelekineticBlock> ();
        }
        else if (GetComponent<SuperTelekineticBlock> ()) {
            characterID = 6;
            superTelekineticBlock = GetComponent<SuperTelekineticBlock> ();
        }
        else if (GetComponent<DestructablePlatform>()){
            characterID = 7;
            destructablePlatform = GetComponent<DestructablePlatform>();
        }
        else if (GetComponent<TurretBlock>()){
            characterID = 8;
            turretBlock = GetComponent<TurretBlock> ();
        }
        else if (GetComponent<SuperTurretBlock>()){
            characterID = 9;
            superTurretBlock = GetComponent<SuperTurretBlock> ();
        }
        else if (GetComponent<PistonButton>()){
            characterID = 10;
            pistonButton = GetComponent<PistonButton> ();
        }
        else{
            characterID = 100;
        }
    }
Ejemplo n.º 14
0
    // Use this for initialization
    void Awake()
    {
        count = 0;

        if (gameObject.name == "Hero1")
        {
            characterID = 0;
            player      = GetComponent <Player> ();
        }
        else if (gameObject.name == "Hero2")
        {
            characterID = 1;
            player      = GetComponent <Player> ();
        }
        else if (GetComponent <MiniCopterBlock> ())
        {
            characterID     = 2;
            miniCopterBlock = GetComponent <MiniCopterBlock> ();
        }
        else if (gameObject.GetComponent <TankBlock> ())
        {
            characterID = 3;
            tankBlock   = GetComponent <TankBlock> ();
        }
        else if (GetComponent <JumpBlock> ())
        {
            characterID = 4;
            jumpBlock   = GetComponent <JumpBlock> ();
        }
        else if (GetComponent <TelekineticBlock> ())
        {
            characterID      = 5;
            telekineticBlock = GetComponent <TelekineticBlock> ();
        }
        else if (GetComponent <SuperTelekineticBlock> ())
        {
            characterID           = 6;
            superTelekineticBlock = GetComponent <SuperTelekineticBlock> ();
        }
        else if (GetComponent <DestructablePlatform>())
        {
            characterID          = 7;
            destructablePlatform = GetComponent <DestructablePlatform>();
        }
        else if (GetComponent <TurretBlock>())
        {
            characterID = 8;
            turretBlock = GetComponent <TurretBlock> ();
        }
        else if (GetComponent <SuperTurretBlock>())
        {
            characterID      = 9;
            superTurretBlock = GetComponent <SuperTurretBlock> ();
        }
        else if (GetComponent <PistonButton>())
        {
            characterID  = 10;
            pistonButton = GetComponent <PistonButton> ();
        }
        else
        {
            characterID = 100;
        }
    }
Ejemplo n.º 15
0
 private static bool IsThrow(JumpBlock jumpBlock)
 {
     return(jumpBlock.JumpNode.IsAnyKind(SyntaxKind.ThrowStatement, SyntaxKindEx.ThrowExpression));
 }