Esempio n. 1
0
        //Build Single Memory Map using key and value types
        private void BuildSingleMapMemoryName(BoogieType keyTypes, BoogieType valueTypes)
        {
            BoogieMapType map = new BoogieMapType(keyTypes, valueTypes);

            map = new BoogieMapType(BoogieType.Ref, map);

            string name = Flags_HelperClass.generateMemoryMapName(keyTypes, valueTypes);

            context.getProgram.AddBoogieDeclaration(new BoogieGlobalVariable(new BoogieTypedIdent(name, map)));
        }
Esempio n. 2
0
        //ignored methods and translate flags not used, intended for implementation however timeconstraints prohibited this.
        //Parameter based constructor.
        public AST_Handler(HashSet <Tuple <string, string> > ignoreMethods, bool _genInlineAttrInBpl, Flags_HelperClass translateFlags = null)
        {
            //returns boogie program instance containing the building blocks for boogie statements.
            //Initially this property is populated with default Boogie Statements as per expectation of the Boogie veriifer.

            //The process handler then aids in conversion to boogie by providing Boogie alternatives to the soldiity constructs contained within each mapping.
            getProgram = new BoogieProgram();
            //generates the mappings for the AST_hander, used to filter the generic AST properties into categorizable subsections
            instantiateMappings();

            IgnoreMethods      = ignoreMethods;
            genInlineAttrInBpl = _genInlineAttrInBpl; // set by default to true;
            TranslateFlags     = translateFlags;      //Not used
        }
Esempio n. 3
0
        //returns a boogieAST reference, containing all captured elements of the sol file in question
        public BoogieAST Translate(AST solidityAST, HashSet <Tuple <string, string> > ignoredMethods, Flags_HelperClass _translatorFlags = null)
        {
            //ignored methods and translator flags need to be remove as not enough time to implement these.

            sourceUnits = solidityAST.GetSourceUnits();

            //create an empty AST_Handler Instance with no ignored method, generate InlineAttributes and no translator flags.
            AST_Handler context = new AST_Handler(ignoredMethods, true, _translatorFlags);

            context.IdToNodeMap     = solidityAST.GetIdToNodeMap();
            context.SourceDirectory = solidityAST.SourceDirectory;

            //assign class instance to temporary instance and use it throughout the rest of the
            //process to populate it.
            classTranslatorContext = context;

            //Execute Collection process from given sol contract.
            //Will enable boogie conversion to occur once specific states/functions/variables have been retrieved from the contract.
            executeSourceInfoCollector();
            executeContractCollection();

            executeInheritanceCollector();
            executeStateVariableCollector();
            executeMapArrayCollector();
            executeConstructorCollector();

            executeFunctionEventCollector();
            executeFunctionEventResolver();

            executeBoogieGenerator();
            executeDefinitionsCollector();

            executeProcessHandler();
            // generate harness for contract
            // non specifiable property, harness is always created and cannot be altered in this code
            OverSight_Harness_Generator harnessGenerator = new OverSight_Harness_Generator();

            harnessGenerator.setTranslatorContext(classTranslatorContext);
            harnessGenerator.createHarness();


            BoogieAST completeAST = new BoogieAST(classTranslatorContext.getProgram);

            Debug.Assert(completeAST != null);

            //returns the BoogieAST containing the root property, where the declarations of the contract are present.
            return(completeAST);
        }