Beispiel #1
0
        public static UndefinedBehaviorAvoidanceConstraint operator+(UndefinedBehaviorAvoidanceConstraint c1, string c2)
        {
            var ret = new UndefinedBehaviorAvoidanceConstraint(c1);

            ret.Add(c2);
            return(ret);
        }
Beispiel #2
0
        public override ArmadaRValue GetRValue(IToken tok, ResolutionContext context)
        {
            var top = context.GetRValueTopStackFrame();
            var correct_frame_type = AH.MakeExprDotName(top, $"Armada_StackFrame_{methodName}?", new BoolType());
            var crashAvoidance     = new UndefinedBehaviorAvoidanceConstraint(correct_frame_type);

            var addr = AH.MakeExprDotName(top, $"{methodName}'AddrOf'{name}", new PointerType(ty));

            var h = context.GetRValueHeap();

            var valid = AH.GetInvocationOfValidPointer(h, addr, ty);

            if (valid == null)
            {
                context.Fail(tok, "Type {ty} is not supported on the heap, and thus not for addressable stack variables either");
                return(null);
            }
            crashAvoidance.Add(valid);

            var val = AH.GetInvocationOfDereferencePointer(h, addr, ty);

            if (val == null)
            {
                context.Fail(tok, "Type {ty} is not supported on the heap, and thus not for addressable stack variables either");
            }
            return(new ArmadaRValue(crashAvoidance, val));
        }
Beispiel #3
0
 public void Add(ArmadaRValue rvalue)
 {
     if (rvalue != null)
     {
         crashAvoidance.Add(rvalue.UndefinedBehaviorAvoidance);
         vals.Add(rvalue.Val);
     }
     else
     {
         vals.Add(null);
     }
 }
Beispiel #4
0
        public override ArmadaRValue GetRValue(IToken tok, ResolutionContext context)
        {
            var crashAvoidance = new UndefinedBehaviorAvoidanceConstraint();
            var addr           = $"({context.GetRValueTopStackFrame()}).{methodName}.AddrOf'{name}";
            var h = context.GetRValueHeap();

            var valid = AH.GetInvocationOfValidPointer(h, addr, ty);

            if (valid == null)
            {
                context.Fail(tok, $"Type {ty} is not supported on the heap, and thus not for addressable stack variables either");
                return(null);
            }
            crashAvoidance.Add(valid);

            var val = AH.GetInvocationOfDereferencePointer(h, addr, ty);

            if (val == null)
            {
                context.Fail(tok, $"Type {ty} is not supported on the heap, and thus not for addressable stack variables either");
            }
            return(new ArmadaRValue(crashAvoidance, val));
        }