コード例 #1
0
        public static IYieldBreakStatement YieldBreak(this IBlockStatementParent blockParent)
        {
            var yieldResult = new YieldBreakStatement(blockParent);

            blockParent.Add(yieldResult);
            return(yieldResult);
        }
コード例 #2
0
        public static IUsingBlockStatement Using(this IBlockStatementParent parent, ILocalDeclarationsStatement resourceAcquisition)
        {
            var usingStatement = new UsingBlockStatement(parent, resourceAcquisition);

            parent.Add(usingStatement);
            return(usingStatement);
        }
コード例 #3
0
        public static IYieldReturnStatement YieldReturn(this IBlockStatementParent blockParent, IExpression returnValue)
        {
            var yieldResult = new YieldReturnStatement(blockParent, returnValue);

            blockParent.Add(yieldResult);
            return(yieldResult);
        }
コード例 #4
0
        public static IUsingExpressionBlockStatement Using(this IBlockStatementParent parent, IExpression resourceAcquisition)
        {
            var usingStatement = new UsingExpressionBlockStatement(parent, resourceAcquisition);

            parent.Add(usingStatement);
            return(usingStatement);
        }
コード例 #5
0
        public static ILockStatement Lock(this IBlockStatementParent parent, IExpression monitorLock)
        {
            var lockStatement = new LockStatement(parent, monitorLock);

            parent.Add(lockStatement);
            return(lockStatement);
        }
コード例 #6
0
        public static IThrowStatement Throw(this IBlockStatementParent parent, IExpression throwTarget)
        {
            var throwStatement = new ThrowStatement(parent, throwTarget);

            parent.Add(throwStatement);
            return(throwStatement);
        }
コード例 #7
0
        public static ITryStatement TryCatch(this IBlockStatementParent parent, TypedName exceptionType)
        {
            var result = new TryStatement(parent);

            result.Catch(exceptionType);
            parent.Add(result);
            return(result);
        }
コード例 #8
0
        public static ITryStatement TryCatch(this IBlockStatementParent parent)
        {
            var result = new TryStatement(parent);

            result.HasCatchAll = true;
            parent.Add(result);
            return(result);
        }
コード例 #9
0
        public static IUsingBlockStatement Using(this IBlockStatementParent parent, ILocalMember resourceAcquisition, params ILocalMember[] siblings)
        {
            var decl           = resourceAcquisition.GetDeclarationStatement(siblings);
            var usingStatement = new UsingBlockStatement(parent, decl);

            parent.Add(usingStatement);
            return(usingStatement);
        }
        /// <summary>
        /// Creates a new <see cref="EnumerateSetBreakableBlockStatement"/>
        /// with the <paramref name="parent"/> provided.
        /// </summary>
        /// <param name="parent">The <see cref="IBlockStatementParent"/>
        /// which contains the <see cref="IEnumerateSetBreakableBlockStatement"/>.
        /// </param>
        /// <param name="localName">The <see cref="String"/> value denoting
        /// the name of the local for the set enumeration block statement.</param>
        public EnumerateSetBreakableBlockStatement(IBlockStatementParent parent, string localName)
            : base(parent)
        {
            var local = this.Locals.Add(localName, null, LocalTypingKind.Implicit);

            local.AutoDeclare = false;
            this.Local        = local;
        }
        public EnumerateSetBreakableBlockStatement(IBlockStatementParent parent, TypedName localNameAndType)
            : base(parent)
        {
            var local = this.Locals.Add(localNameAndType);

            local.AutoDeclare = false;
            this.Local        = local;
        }
コード例 #12
0
        public static ITryStatement TryFinally(this IBlockStatementParent parent)
        {
            var result = new TryStatement(parent);

            result.HasFinally = true;
            parent.Add(result);
            return(result);
        }
コード例 #13
0
        public static IExplicitStringLiteralStatement Literal(this IBlockStatementParent block, string literal)
        {
            IExplicitStringLiteralStatement result = new ExplicitStringLiteralStatement(block)
            {
                Literal = literal
            };

            block.Add(result);
            return(result);
        }
コード例 #14
0
 public static Dictionary <SyntacticalDFAState, SyntacticalDFAStateJumpData> ObtainStateJumpDetails(
     IEnumerable <SyntacticalDFAState> statesNeedingLabels,
     IBlockStatementParent owner,
     string labelPattern,
     string statePattern,
     Func <SyntacticalDFAState, bool> isMultiOverride,
     IEnumerable <SyntacticalDFAState> singularStates,
     params object[]                          furtherReplacements)
 {
     return(ObtainStateJumpDetailsInternal(statesNeedingLabels, owner, labelPattern, statePattern, isMultiOverride, singularStates, furtherReplacements)
            .OrderBy(k => k.State.StateValue)
            .ToDictionary(k => k.State, v => v));
 }
コード例 #15
0
 private static IEnumerable <SyntacticalDFAStateJumpData> ObtainStateJumpDetailsInternal(
     IEnumerable <SyntacticalDFAState> statesNeedingLabels,
     IBlockStatementParent owner,
     string labelPattern,
     string statePattern,
     Func <SyntacticalDFAState, bool> isMultiOverride,
     IEnumerable <SyntacticalDFAState> singularStates,
     params object[]                          furtherReplacements)
 {
     if (singularStates != null && isMultiOverride != null)
     {
         foreach (var state in singularStates)
         {
             if (isMultiOverride(state))
             {
                 yield return new SyntacticalDFAStateJumpData()
                        {
                            State = state,
                            Label = new Lazy <ILabelStatement>(() =>
                                                               owner.DefineLabel(string.Format(string.Format(labelPattern, statePattern), ((object)state.StateValue).AsEnumerable().Concat(furtherReplacements).ToArray()))),
                            BlockContainer = new BlockStatementParentContainer(owner)
                        }
             }
         }
     }
     ;
     foreach (var state in statesNeedingLabels.OrderBy(k => k.StateValue))
     {
         yield return(new SyntacticalDFAStateJumpData()
         {
             State = state,
             Label = new Lazy <ILabelStatement>(() =>
                                                owner.DefineLabel(string.Format(string.Format(labelPattern, statePattern), ((object)state.StateValue).AsEnumerable().Concat(furtherReplacements).ToArray()))),
             BlockContainer = new BlockStatementParentContainer(owner)
         });
     }
 }
コード例 #16
0
        private void BuildCullAmbiguities(ParserCompiler compiler, ParserBuilder parserBuilder, IIntermediateCliManager identityManager)
        {
            bool lexicallyAmbiguousModel = compiler._GrammarSymbols.AmbiguousSymbols.Count() > 0;

            if (!lexicallyAmbiguousModel)
            {
                return;
            }
            var runningAmbiguities = this._cullAmbiguities.Locals.Add(
                new TypedName("runningAmbiguities", compiler.LexicalSymbolModel.ValidSymbols), new DefaultValueExpression(compiler.LexicalSymbolModel.ValidSymbols));
            var resultAmbiguities = this._cullAmbiguities.Locals.Add(
                new TypedName("resultAmbiguities", compiler.LexicalSymbolModel.ValidSymbols), new DefaultValueExpression(compiler.LexicalSymbolModel.ValidSymbols));
            var unambiguousSource = this._cullAmbiguities.Parameters["unambiguousSource"];

            this._cullAmbiguities.Comment("Remove the ambiguities that are currently present, a larger multiple-symbol ambiguity may trump what was there due to the follow-union.");
            this._cullAmbiguities.Assign((IMemberReferenceExpression)unambiguousSource.GetReference(), AssignmentOperation.BitwiseExclusiveOrAssign, unambiguousSource.GetReference().BitwiseAnd(_AllAmbiguitiesField.GetReference()));
            bool first = true;

            foreach (var ambiguity in compiler._GrammarSymbols.AmbiguousSymbols)
            {
                var ambiguityDetail          = compiler.AmbiguityDetail[ambiguity];
                IBlockStatementParent target = this._cullAmbiguities;
                if (first)
                {
                    first = false;
                }
                else
                {
                    target = target.If(runningAmbiguities.GetReference().BitwiseAnd(ambiguityDetail.AmbiguityKeyReference.GetReference()).InequalTo(ambiguityDetail.AmbiguityKeyReference.GetReference()));
                }
                var assignmentCheck = target.If(unambiguousSource.BitwiseAnd(ambiguityDetail.AmbiguityKeyReference).EqualTo(ambiguityDetail.AmbiguityKeyReference));
                assignmentCheck.Assign(runningAmbiguities.GetReference(), AssignmentOperation.BitwiseOrAssign, ambiguityDetail.AmbiguityKeyReference.GetReference());
                assignmentCheck.Assign(resultAmbiguities.GetReference(), AssignmentOperation.BitwiseOrAssign, ambiguityDetail.AmbiguityReference.GetReference());
            }
            _cullAmbiguities.Return(resultAmbiguities.GetReference());
        }
 public ConditionContinuationStatement(IBlockStatementParent parent)
     : base(parent)
 {
 }
コード例 #18
0
 /// <summary>
 /// Creates a new <see cref="TypedLocalMember"/>
 /// with the <paramref name="name"/>, <paramref name="parent"/> and <paramref name="localType"/>
 /// provided.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="parent"></param>
 /// <param name="localType"></param>
 public TypedLocalMember(string name, IBlockStatementParent parent, IType localType)
     : base(name, parent, LocalTypingKind.Explicit)
 {
     this.LocalType = localType;
 }
コード例 #19
0
 public static ILockStatement Lock(this IBlockStatementParent parent, ILocalMember localMember)
 {
     return(parent.Lock(localMember.GetReference()));
 }
コード例 #20
0
 public static IYieldReturnStatement YieldReturn(this IBlockStatementParent blockParent, IStructPropertyMember returnValue)
 {
     return(blockParent.YieldReturn((IExpression)returnValue.GetReference()));
 }
コード例 #21
0
 /// <summary>
 /// Creates a new <see cref="ConditionBlockStatement"/> with
 /// the <paramref name="parent"/> which contains it.
 /// </summary>
 /// <param name="parent">The <see cref="IBlockStatementParent"/> which
 /// contains the <see cref="ConditionBlockStatement"/>.</param>
 public ConditionBlockStatement(IBlockStatementParent parent)
     : base(parent)
 {
 }
コード例 #22
0
 public SwitchStatement(IBlockStatementParent parent)
 {
     this.Parent = parent;
 }
コード例 #23
0
 /// <summary>
 /// Creates a new <see cref="WhileStatement"/> with the <paramref name="parent"/> and
 /// <paramref name="condition"/> provided.
 /// </summary>
 /// <param name="parent">
 /// The <see cref="IBlockStatementParent"/> which contains the <see cref="WhileStatement"/>.
 /// </param>
 /// <param name="condition">
 /// The <see cref="IExpression"/> which must evaluate to true for the block of the
 /// <see cref="WhileStatement"/> to be evaluated.
 /// </param>
 public WhileStatement(IBlockStatementParent parent, IExpression condition)
     : base(parent)
 {
     this.Condition = condition;
 }
コード例 #24
0
 public BlockStatementScopeLabelDictionary(IBlockStatementParent initialPoint)
 {
     this.initialPoint = initialPoint;
 }
コード例 #25
0
 public IterationBlockBaseStatement(IBlockStatementParent parent, IExpression condition, IEnumerable <IStatementExpression> iterations)
     : base(parent)
 {
     this.Condition  = condition;
     this.Iterations = new MalleableStatementExpressionCollection(iterations);
 }
コード例 #26
0
 public static IYieldReturnStatement YieldReturn(this IBlockStatementParent blockParent, IParameterReferenceExpression returnValue)
 {
     return(blockParent.YieldReturn((IExpression)returnValue));
 }
コード例 #27
0
 public static IYieldReturnStatement YieldReturn(this IBlockStatementParent blockParent, INaryOperandExpression returnValue)
 {
     return(blockParent.YieldReturn((IExpression)returnValue));
 }
コード例 #28
0
 public static ILockStatement Lock(this IBlockStatementParent parent, IStructFieldMember fieldMember)
 {
     return(parent.Lock(fieldMember.GetReference()));
 }
コード例 #29
0
 public static IThrowStatement Throw(this IBlockStatementParent parent)
 {
     return(parent.Throw(null));
 }
コード例 #30
0
 public static IYieldReturnStatement YieldReturn(this IBlockStatementParent blockParent, ulong returnValue)
 {
     return(blockParent.YieldReturn((IExpression)returnValue.ToPrimitive()));
 }