예제 #1
0
파일: RppMatch.cs 프로젝트: dubik/csharprpp
        public override IRppNode Analyze(SymbolTable scope, Diagnostic diagnostic)
        {
            Value = (IRppExpr) Value.Analyze(scope, diagnostic);
            RppVar declIn = new RppVar(MutabilityFlag.MfVal, "<in>", Value.Type, Value);
            declIn.Analyze(scope, diagnostic);

            CaseClauses = NodeUtils.Analyze(scope, CaseClauses, diagnostic);

            Type = CheckCommonType(CaseClauses, Token).AsResolvable();
            RppVar declOut = new RppVar(MutabilityFlag.MfVar, "<out>", Type, new RppDefaultExpr(Type));

            RppId declInId = new RppId("<in>", declIn);
            declInId.Analyze(scope, diagnostic);
            RppId declOutId = new RppId("<out>", declOut);

            RppMatchingContext ctx = new RppMatchingContext();
            var ifC = Create(declInId, declOutId, CaseClauses, ctx);
            var expr = new RppBlockExpr(List<IRppNode>(declIn, ifC)) {Exitable = true};

            SymbolTable matchScope = new SymbolTable(scope);
            RppBlockExpr matchBlock = new RppBlockExpr(List<IRppNode>(declOut, expr, declOutId));
            return matchBlock.Analyze(matchScope, diagnostic);
        }
예제 #2
0
 public override void VisitExit(RppBlockExpr node)
 {
     if (node.Exitable)
     {
         _body.MarkLabel(_blockExprExitLabels.Pop());
     }
 }
예제 #3
0
 public override void VisitEnter(RppBlockExpr node)
 {
     Console.WriteLine("Block expr");
     if (node.Exitable)
     {
         Label exitLabel = _body.DefineLabel();
         _blockExprExitLabels.Push(exitLabel);
     }
 }
예제 #4
0
 public virtual void VisitExit(RppBlockExpr node)
 {
 }
예제 #5
0
 public virtual void VisitEnter(RppBlockExpr node)
 {
 }