예제 #1
0
        BoundExpression BindInstanceOfEx(AST.InstanceOfEx x)
        {
            var result = new BoundInstanceOfEx(BindExpression(x.Expression, BoundAccess.Read));

            if (x.ClassNameRef is AST.DirectTypeRef)
            {
                result.IsTypeDirect = ((AST.DirectTypeRef)x.ClassNameRef).ClassName;
            }
            else
            {
                result.IsTypeIndirect = BindExpression(((AST.IndirectTypeRef)x.ClassNameRef).ClassNameVar, BoundAccess.Read);
            }

            //
            return(result);
        }
예제 #2
0
 public virtual void VisitInstanceOf(BoundInstanceOfEx x)
 {
     Accept(x.Operand);
     VisitTypeRef(x.AsType);
 }
 public virtual TResult VisitInstanceOf(BoundInstanceOfEx x) => DefaultVisitOperation(x);
예제 #4
0
 protected virtual void Visit(BoundInstanceOfEx x, ConditionBranch branch)
 {
     base.VisitInstanceOf(x);
 }
예제 #5
0
 public sealed override void VisitInstanceOf(BoundInstanceOfEx x) => Visit(x, ConditionBranch.Default);
예제 #6
0
 public virtual void VisitInstanceOf(BoundInstanceOfEx x)
 {
     Accept(x.Operand);
     VisitTypeRef(x.AsType);
 }
예제 #7
0
        protected override void Visit(BoundInstanceOfEx x, ConditionBranch branch)
        {
            Accept(x.Operand);
            VisitTypeRef(x.AsType);

            // TOOD: x.ConstantValue // in case we know and the operand is a local variable (we can ignore the expression and emit result immediatelly)

            if (branch == ConditionBranch.ToTrue && x.Operand is BoundVariableRef)
            {
                var vref = (BoundVariableRef)x.Operand;
                if (vref.Name.IsDirect)
                {
                    // if (Variable is T) => variable is T in True branch state
                    State.SetVar(vref.Name.NameValue.Value, TypeCtx.GetTypeMask(x.AsType.TypeRef, true));
                }
            }

            //
            x.TypeRefMask = TypeCtx.GetBooleanTypeMask();
        }