Пример #1
0
        public static BoogieFunction GenerateMultiDimZeroFunction(VariableDeclaration decl)
        {
            TypeName          curType    = decl.TypeName;
            List <BoogieType> boogieType = new List <BoogieType>();

            while (curType is Mapping || curType is ArrayTypeName)
            {
                if (curType is Mapping map)
                {
                    boogieType.Insert(0, TransUtils.GetBoogieTypeFromSolidityTypeName(map.KeyType));
                    curType = map.ValueType;
                }
                else if (curType is ArrayTypeName arr)
                {
                    boogieType.Insert(0, BoogieType.Int);
                    curType = arr.BaseType;
                }
            }

            BoogieType valType    = TransUtils.GetBoogieTypeFromSolidityTypeName(curType);
            BoogieExpr boogieInit = TransUtils.GetDefaultVal(valType);

            string     smtType = GetSmtType(valType);
            string     smtInit = boogieInit.ToString().Equals("null") ? "0" : boogieInit.ToString();
            BoogieType mapType = valType;
            string     fnName  = $"{valType.ToString()}Arr";

            foreach (BoogieType type in boogieType)
            {
                smtType = $"(Array {GetSmtType(type)} {smtType})";
                mapType = new BoogieMapType(type, mapType);
                smtInit = $"((as const {smtType}) {smtInit})";
                fnName  = $"{type.ToString()}{fnName}";
            }

            var outVar         = new BoogieFormalParam(new BoogieTypedIdent("ret", mapType));
            var smtDefinedAttr = new BoogieAttribute("smtdefined", $"\"{smtInit}\"");

            return(new BoogieFunction($"zero{fnName}", new List <BoogieVariable>(), new List <BoogieVariable>()
            {
                outVar
            }, new List <BoogieAttribute>()
            {
                smtDefinedAttr
            }));
        }
Пример #2
0
        public static BoogieFunction GenerateMultiDimZeroFunction(BoogieType keyType, BoogieType valType)
        {
            BoogieExpr boogieInit = TransUtils.GetDefaultVal(valType);
            string     smtType    = GetSmtType(valType);
            BoogieType mapType    = new BoogieMapType(keyType, valType);
            string     fnName     = $"zero{keyType.ToString()}{valType.ToString()}Arr";

            string smtInit = boogieInit.ToString().Equals("null") ? "0" : boogieInit.ToString();

            smtInit = $"((as const (Array {GetSmtType(keyType)} {smtType})) {smtInit})";

            var outVar         = new BoogieFormalParam(new BoogieTypedIdent("ret", mapType));
            var smtDefinedAttr = new BoogieAttribute("smtdefined", $"\"{smtInit}\"");

            return(new BoogieFunction(fnName, new List <BoogieVariable>(), new List <BoogieVariable>()
            {
                outVar
            }, new List <BoogieAttribute>()
            {
                smtDefinedAttr
            }));
        }
Пример #3
0
 public BoogieReturnExprCmd(BoogieExpr expr)
 {
     this.Expr = expr;
     throw new NotSupportedException("return " + expr.ToString());
 }
Пример #4
0
 public override string ToString()
 {
     return($"\naxiom({BExpr.ToString()});\n");
 }