Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        public override ArmadaRValue GetRValue(IToken tok, ResolutionContext context)
        {
            var s     = context.GetRValueState();
            var addrs = AH.MakeExprDotName(s, "addrs", "Armada_Addrs");
            var addr  = AH.MakeExprDotName(addrs, name, new PointerType(ty));

            var h = context.GetRValueHeap();

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

            if (valid == null)
            {
                context.Fail(tok, "Type {ty} is currently not supported in the heap");
                return(null);
            }
            var crashAvoidance = new UndefinedBehaviorAvoidanceConstraint(valid);

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

            if (val == null)
            {
                context.Fail(tok, "Type {ty} is currently not supported in the heap");
            }
            return(new ArmadaRValue(crashAvoidance, val));
        }
Exemplo n.º 3
0
        public override Expression UpdateTotalStateLocationDirectly(ResolutionContext context, IConstraintCollector constraintCollector,
                                                                    Expression val_new)
        {
            var s     = context.GetLValueState();
            var mem   = AH.MakeExprDotName(s, "mem", "Armada_SharedMemory");
            var h     = AH.MakeExprDotName(mem, "heap", "Armada_Heap");
            var valid = AH.GetInvocationOfValidPointer(h, address.Val, type);

            if (valid == null)
            {
                constraintCollector.Fail(tok, $"Type {type} is currently not supported in the heap");
            }
            else
            {
                constraintCollector.AddUndefinedBehaviorAvoidanceConstraint(valid);
            }

            var h_new = AH.GetInvocationOfUpdatePointer(h, address.Val, val_new);

            if (h_new == null)
            {
                constraintCollector.Fail(tok, $"Type {type} is currently not supported in the heap");
            }

            var mem_new = AH.MakeDatatypeUpdateExpr(mem, "heap", h_new);

            return(AH.MakeDatatypeUpdateExpr(s, "mem", mem_new));
        }
Exemplo n.º 4
0
        public override string UpdateTotalStateLocationDirectly(ResolutionContext context, IConstraintCollector constraintCollector,
                                                                string val_new)
        {
            var s     = context.GetLValueState();
            var h     = $"({s}).mem.heap";
            var valid = AH.GetInvocationOfValidPointer(h, address.Val, type);

            if (valid == null)
            {
                constraintCollector.Fail(tok, $"Type {type} is currently not supported in the heap");
            }
            else
            {
                constraintCollector.AddUndefinedBehaviorAvoidanceConstraint(valid);
            }

            var h_new = AH.GetInvocationOfUpdatePointer(h, address.Val, val_new, type);

            if (h_new == null)
            {
                constraintCollector.Fail(tok, $"Type {type} is currently not supported in the heap");
            }

            return($"{s}.(mem := {s}.mem.(heap := {h_new}))");
        }
Exemplo n.º 5
0
        public override ArmadaRValue GetRValue(IToken tok, ResolutionContext context)
        {
            var addr  = $"({context.GetRValueState()}).addrs.{name}";
            var h     = context.GetRValueHeap();
            var valid = AH.GetInvocationOfValidPointer(h, addr, ty);

            if (valid == null)
            {
                context.Fail(tok, $"Type {ty} is currently not supported in the heap");
                return(null);
            }
            var crashAvoidance = new UndefinedBehaviorAvoidanceConstraint(valid);

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

            if (val == null)
            {
                context.Fail(tok, $"Type {ty} is currently not supported in the heap");
            }
            return(new ArmadaRValue(crashAvoidance, val));
        }
Exemplo n.º 6
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));
        }