Exemple #1
0
        private void FinishClassParent()
        {
            var classParent = this.classParent;

            classParent.AccessLevel = AccessLevelModifiers.Public;
            classParent.SummaryText = string.Format(@"Returns/sets the @s:{0}; which contains the current @s:{1};.", this.resultInterface.Name, this.resultClass.Name);
            classParent.RemarksText = @"May be null if there was no ancestor in the context stack at the time of parse.";
            var parentNullCheck    = classParent.GetMethod.If(classParentField.EqualTo(IntermediateGateway.NullValue));
            var parentContextLocal =
                parentNullCheck.Locals.Add(
                    new TypedName(
                        "parentContext",
                        this.compiler.RuleSymbolBuilder.ILanguageRuleSymbol),
                    this.compiler.RuleSymbolBuilder.GetFirstViableParentContext
                    .GetReference()
                    .Invoke(
                        this.compiler.RuleSymbolBuilder.Parent.GetReference(
                            this.ContextImpl.GetReference())));

            parentContextLocal.AutoDeclare = false;
            parentNullCheck.DefineLocal(parentContextLocal);
            IConditionBlockStatement parentContextNullCheck = null;

            //if (this.compiler.Source.GetRules().Any(k=>k.IsRuleCollapsePoint))
            //    parentContextNullCheck = parentNullCheck.If(parentContextLocal.InequalTo(IntermediateGateway.NullValue).LogicalAnd(parentContextLocal.InequalTo(this.classContextField.GetReference().RightComment("If we started parsing at a collapse point..."))));
            //else
            parentContextNullCheck = parentNullCheck.If(parentContextLocal.InequalTo(IntermediateGateway.NullValue));
            parentContextNullCheck
            .Assign(this.classParentField.GetReference(), this.compiler.RuleSymbolBuilder.CreateRuleImpl.GetReference(parentContextLocal.GetReference()).Invoke());
            classParent.GetMethod.Return(this.classParentField.GetReference());
        }
 public override bool Visit(IConditionBlockStatement statement, IStatement context)
 {
     _stack.Push(statement);
     try
     {
         return(base.Visit(statement, context));
     }
     finally
     {
         _stack.Pop();
     }
 }
Exemple #3
0
        private void BuildExpect()
        {
            this.ExpectImpl = this._parserClass.Methods.Add(
                new TypedName("Expect", RuntimeCoreType.VoidType, this._identityManager),
                new TypedNameSeries(
                    new TypedName("lookAheadDepth", RuntimeCoreType.Int32, this._identityManager),
                    new TypedName("erroneousContext", this.compiler.RuleSymbolBuilder.ILanguageRuleSymbol),
                    new TypedName("fromError", RuntimeCoreType.Boolean, this._identityManager)));
            var lookAheadDepth   = this.ExpectImpl.Parameters["lookAheadDepth"];
            var erroneousContext = this.ExpectImpl.Parameters["erroneousContext"];
            var fromError        = this.ExpectImpl.Parameters["fromError"];

            var tokenIndex = this.ExpectImpl.Locals.Add(new TypedName("tokenIndex", RuntimeCoreType.Int32, this._identityManager), this.SymbolStreamBuilder.GetTokenIndexImpl.GetReference(this._SymbolStreamImpl.GetReference()).Invoke(lookAheadDepth.GetReference()));
            var position   = this.ExpectImpl.Locals.Add(new TypedName("position", RuntimeCoreType.Int32, this._identityManager));
            var tiCheck    = this.ExpectImpl.If(tokenIndex.LessThan(this.Compiler.GenericSymbolStreamBuilder.CountImpl.GetReference(this.TokenStreamImpl.GetReference())));

            tiCheck.CreateNext(this.Compiler.GenericSymbolStreamBuilder.CountImpl.GetReference(this.TokenStreamImpl.GetReference()).EqualTo(IntermediateGateway.NumberZero));
            tiCheck.Assign(position, this.compiler.TokenSymbolBuilder.StartPosition.GetReference(this.compiler.GenericSymbolStreamBuilder.IndexerImpl.GetReference(this.TokenStreamImpl.GetReference(), tokenIndex.GetReference())));
            tiCheck.Next.Assign(position, IntermediateGateway.NumberZero);
            IConditionBlockStatement tiCheckNext = (IConditionBlockStatement)tiCheck.Next;

            tiCheckNext.CreateNext();
            tiCheckNext.Next.Assign(position, this.compiler.TokenSymbolBuilder.StartPosition.GetReference(this.compiler.GenericSymbolStreamBuilder.IndexerImpl.GetReference(this.TokenStreamImpl.GetReference(), this.Compiler.GenericSymbolStreamBuilder.CountImpl.GetReference(this.TokenStreamImpl.GetReference()).Subtract(1))));
            var errorContext = this.ExpectImpl.Locals.Add(new TypedName("errorContext", this.compiler.ErrorContextBuilder.LanguageErrorContext), this.compiler.ErrorContextBuilder.LanguageErrorContext.GetNewExpression(this.compiler.ErrorContextBuilder.CauseExpected.GetReference(), this.StateImpl.GetReference(), this.Compiler.ExtensionsBuilder.GetValidSyntaxMethodImpl.GetReference().Invoke(), position.GetReference()));

            errorContext.AutoDeclare = false;
            this.ExpectImpl.DefineLocal(errorContext);
            var listTypeGeneric  = typeof(List <int>).GetTypeReference <IClassType>(this._identityManager);
            var errorIndicesList = this.ExpectImpl.Locals.Add(listTypeGeneric.WithName("errorIndices"), listTypeGeneric.GetNewExpression());

            errorIndicesList.AutoDeclare = false;
            this.ExpectImpl.DefineLocal(errorIndicesList);
            this.ExpectImpl.Call(errorIndicesList.GetReference().GetMethod("Add").Invoke(this.Compiler.ErrorContextBuilder.IndexImpl.GetReference(errorContext.GetReference()).Assign(this._ErrorContextImpl.GetReference().GetProperty("Count"))));
            this.ExpectImpl.Call(this._ErrorContextImpl.GetReference().GetMethod("Add").Invoke(errorContext.GetReference()));
            this.ExpectImpl.Call(this.Compiler.RuleSymbolBuilder.DelineateCaptureImpl.GetReference(erroneousContext.GetReference()).Invoke(ParserCompiler.ErrorCaptureName.ToPrimitive(), errorIndicesList.GetReference()));
            this.Compiler.RuleSymbolBuilder.DelineateCapture.GetReference(erroneousContext.GetReference()).Invoke(ParserCompiler.ErrorCaptureName.ToPrimitive(), errorIndicesList.GetReference());
            this.ExpectImpl.AccessLevel = AccessLevelModifiers.Public;
        }
Exemple #4
0
 public abstract IStatement Transform(IConditionBlockStatement statement);
Exemple #5
0
 void IStatementVisitor.Visit(IConditionBlockStatement statement)
 {
     this.Translate(statement);
 }
Exemple #6
0
 TransformationImpact IStatementVisitor <TransformationImpact> .Visit(IConditionBlockStatement statement)
 {
     return(CalculateRefactorImpact(statement));
 }
Exemple #7
0
 public TestLinkerResult Visit(IConditionBlockStatement statement, ICompilationContext context)
 {
     throw new NotImplementedException();
 }
Exemple #8
0
 public abstract TransformationImpact CalculateRefactorImpact(IConditionBlockStatement statement);
Exemple #9
0
 public bool Visit(IConditionBlockStatement statement, TContext context)
 {
     return(IsBrokeFull(statement, context) && (statement.HasNext && statement.Next.Accept(this, context)));
 }
Exemple #10
0
 public abstract void Translate(IConditionBlockStatement statement);
Exemple #11
0
 public TransformationKind Visit(IConditionBlockStatement statement, ITransformationContext context)
 {
     throw new NotImplementedException();
 }