Exemplo n.º 1
0
        public ExceptionHandlingManager()
        {
            ExceptionTable = new ExceptionRegistrationTable();

            int invalidIndex = ProtoCore.DSASM.Constants.kInvalidIndex;

            // System default exception registration
            SystemRegistration             = ExceptionTable.Register(invalidIndex, invalidIndex, invalidIndex);
            SystemRegistration.ParentIndex = ProtoCore.DSASM.Constants.kInvalidIndex;

            // Exception registration for the top most associative code block.
            //
            // Why we need to manually add this one even when code gen is compiling
            // the top-most language node the exception registration for that
            // language code block will be added?
            //
            // The reason is ParentIndex, which will be updated dynamcailly at
            // run-time, i.e., it should point to the index of exception registration
            // for the upper scope. Normally, we will set this value either at
            // OpCode.Bounce or at OpCode.CallR. But for the top-most language
            // block, it doesnt start from there, so here we manully set its
            // ParentIndex to the default system exception registration instance.
            //
            // If we can consolidate the updating code at OpCode.Bounce and at
            // OpCode.CallR, then it is not necessary to manually add this one.
            // (The reason that we have to do that is because we need the value
            // of pc in the upper scope, i.e., where does the execution jump to
            // other function call or language block; otherwise Execute() is a
            // ideal place to put that updating code). Should refactor this piece
            // of code for that case.  -- Yu Ke
            TopMostAssocBlockRegistration             = ExceptionTable.Register(0, invalidIndex, invalidIndex);
            TopMostAssocBlockRegistration.ParentIndex = SystemRegistration.RegistrationTableIndex;

            CurrentActiveRegistration = TopMostAssocBlockRegistration;

            IsStackUnwinding = false;
            TargetHandler    = null;
            Context          = null;

            Observers = new List <IFirstHandExceptionObserver>();
        }
Exemplo n.º 2
0
        public ExceptionHandlingManager()
        {
            ExceptionTable = new ExceptionRegistrationTable();

            int invalidIndex = ProtoCore.DSASM.Constants.kInvalidIndex;
            // System default exception registration
            SystemRegistration = ExceptionTable.Register(invalidIndex, invalidIndex, invalidIndex); 
            SystemRegistration.ParentIndex = ProtoCore.DSASM.Constants.kInvalidIndex;

            // Exception registration for the top most associative code block.
            //
            // Why we need to manually add this one even when code gen is compiling 
            // the top-most language node the exception registration for that 
            // language code block will be added?
            // 
            // The reason is ParentIndex, which will be updated dynamcailly at
            // run-time, i.e., it should point to the index of exception registration
            // for the upper scope. Normally, we will set this value either at
            // OpCode.Bounce or at OpCode.CallR. But for the top-most language
            // block, it doesnt start from there, so here we manully set its
            // ParentIndex to the default system exception registration instance.
            //
            // If we can consolidate the updating code at OpCode.Bounce and at
            // OpCode.CallR, then it is not necessary to manually add this one.
            // (The reason that we have to do that is because we need the value 
            // of pc in the upper scope, i.e., where does the execution jump to 
            // other function call or language block; otherwise Execute() is a 
            // ideal place to put that updating code). Should refactor this piece 
            // of code for that case.  -- Yu Ke
            TopMostAssocBlockRegistration = ExceptionTable.Register(0, invalidIndex, invalidIndex);
            TopMostAssocBlockRegistration.ParentIndex = SystemRegistration.RegistrationTableIndex;

            CurrentActiveRegistration = TopMostAssocBlockRegistration;

            IsStackUnwinding = false;
            TargetHandler = null;
            Context = null;

            Observers = new List<IFirstHandExceptionObserver>();
        }