Exemplo n.º 1
0
        public void LoopReversal( )
        {
            GFunction fib          = GetGFunction("fib.c");
            GFunction fib_loop_rev = GetGFunction("fib loop reversed.c");

            Assert.IsTrue(fib == fib_loop_rev);
        }
Exemplo n.º 2
0
        public void RedundantVar( )
        {
            GFunction fib = GetGFunction("fib.c");
            GFunction fib_redundant_var = GetGFunction("fib redundant var.c");

            Assert.IsTrue(fib == fib_redundant_var);
        }
Exemplo n.º 3
0
        public void Datatype( )
        {
            GFunction fib          = GetGFunction("fib.c");
            GFunction fib_datatype = GetGFunction("fib datatype.c");

            Assert.IsTrue(fib_datatype == fib);
        }
Exemplo n.º 4
0
        public void SingularDecl( )
        {
            GFunction fib = GetGFunction("fib.c");
            GFunction fib_singular_decl = GetGFunction("fib singular decl.c");

            Assert.IsTrue(fib == fib_singular_decl);
        }
Exemplo n.º 5
0
        public void RedundantExpressions( )
        {
            GFunction fib = GetGFunction("fib.c");
            GFunction fib_redundant_expr = GetGFunction("fib redundant expressions.c");

            Assert.IsTrue(fib == fib_redundant_expr);
        }
Exemplo n.º 6
0
        public void VarRenamed( )
        {
            GFunction fib            = GetGFunction("fib.c");
            GFunction fib_refactored = GetGFunction("fib var renamed.c");

            Assert.IsTrue(fib == fib_refactored);
        }
Exemplo n.º 7
0
        public void Macros( )
        {
            GFunction fib       = GetGFunction("fib.c");
            GFunction fib_macro = GetGFunction("fib macro.c");

            Assert.IsTrue(fib == fib_macro);
        }
Exemplo n.º 8
0
        public void ExactSame( )
        {
            GFunction fact     = GetGFunction("fib.c");
            GFunction fib_same = GetGFunction("fib same.c");

            Assert.IsTrue(fact == fib_same);
        }
Exemplo n.º 9
0
        public void ConditionReversed( )
        {
            GFunction max          = GetGFunction("max.c");
            GFunction max_cond_rev = GetGFunction("max condition rev.c");

            Assert.IsTrue(max == max_cond_rev);
        }
Exemplo n.º 10
0
        public void Refactored( )
        {
            GFunction fib            = GetGFunction("fib.c");
            GFunction fib_refactored = GetGFunction("fib refactored.c");

            Assert.IsTrue(fib == fib_refactored);
        }
Exemplo n.º 11
0
        // Constructor
        public FunctionBlock(GFunction function)
        {
            // Initialize Component
            InitializeComponent();

            // Initialize Hole List
            _HoleList = new List <BaseHole> {
                NextConnectHole
            };

            // Initialize Objects
            _GFunction   = function;
            _GObjectList = new List <GBase> {
                GScope
            };

            StackContentText.Text = function.FunctionName;

            // Initialize Events
            NextConnectHole.BlockAttached += RealNextConnectHole_BlockChanged;
            NextConnectHole.BlockDetached += RealNextConnectHole_BlockChanged;

            // Initialize Block
            InitializeBlock();
        }
Exemplo n.º 12
0
        public void CommentsAndIndentation( )
        {
            GFunction fib = GetGFunction("fib.c");
            GFunction fib_comments_indent = GetGFunction("fib comments and indentation.c");

            Assert.IsTrue(fib == fib_comments_indent);
        }
Exemplo n.º 13
0
        public static GFunction getGFunction(string fileName)
        {
            var optimizer = new Optimizer(fileName);
            var gimple    = optimizer.GIMPLE;

            GFunction gFunction = new GFunction(gimple);

            return(gFunction);
        }
Exemplo n.º 14
0
        public static GFunction GetGFunction(string fileName)
        {
            var optimizer = new Optimizer(fileName)
            {
                Rebuild = true
            };

            optimizer.Run( );
            var gimple = optimizer.GIMPLE;

            var gFunction = new GFunction(gimple, fileName);

            return(gFunction);
        }
Exemplo n.º 15
0
    internal GOpCall Merge(GOpCall gc)
    {
        /*
         * For the merge to be possible, calls to the same
         * Function should target the same GFunction.
         */
        foreach (var kvp in gc.cfm)
        {
            Function  f   = kvp.Key;
            GFunction gf2 = kvp.Value;
            GFunction gf1;
            if (!cfm.TryGetValue(f, out gf1))
            {
                continue;
            }
            if (gf1 != gf2)
            {
                return(null);
            }
        }

        /*
         * Compute the merged dispatcher.
         */
        Dispatcher d3 = Dispatcher.Merge(dispatcher, gc.dispatcher);

        if (d3 == null)
        {
            return(null);
        }

        /*
         * Merge the maps.
         */
        SortedDictionary <Function, GFunction> cfm3 =
            new SortedDictionary <Function, GFunction>();

        foreach (var kvp in cfm)
        {
            cfm3[kvp.Key] = kvp.Value;
        }
        foreach (var kvp in gc.cfm)
        {
            cfm3[kvp.Key] = kvp.Value;
        }

        return(new GOpCall(fname, d3, cfm3));
    }
Exemplo n.º 16
0
        private void materialRaisedButton3_Click(object sender, EventArgs e)
        {
            if (file_1 == null || file_2 == null)
            {
                MessageBox.Show("Please Upload File", "Error");
                return;
            }
            GFunction gFunc1 = getGFunction(file_1);
            GFunction gFunc2 = getGFunction(file_2);
            decimal   result = gFunc1.Compare(gFunc2);

            label1.Text = result.ToString();

            File.Delete(Path.Combine(project_dir, file_1));
            File.Delete(Path.Combine(project_dir, file_2));
        }
        public void GitHub_Issue_144_1()
        {
            // GetGFunction1 is defined outside the test function
            GFunction gFunc1 = GetGFunction1;

            Assert.True(gFunc1.Method.GetParameters()[0].HasDefaultValue);

            var flags         = BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance;
            var invokeMethod1 = (MethodInfo)gFunc1.GetType().FindMembers(MemberTypes.Method, flags, Type.FilterName, "Invoke")[0];

            Assert.True(invokeMethod1.GetParameters()[0].HasDefaultValue);

            var interpreter = new Interpreter();

            interpreter.SetFunction("GFunction", gFunc1);
            interpreter.SetVariable("arg", "arg");

            Assert.True((bool)interpreter.Eval("GFunction(arg)"));
            Assert.False((bool)interpreter.Eval("GFunction()"));
        }
Exemplo n.º 18
0
        // 함수 선언
        public FunctionBlock DefineFunction(string funcName)
        {
            var function = new GFunction(funcName);

            return(FunctionList[funcName] = new FunctionBlock(function));
        }
Exemplo n.º 19
0
 public void Append(GFunction func)
 {
     functionList.Add(func);
 }