<commit_before>﻿// Copyright (c) <NAME>.  All Rights Reserved.  Licensed under the MIT License.  See License.txt in the project root for license information.

using Backend.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model.ThreeAddressCode.Instructions;
using Model.ThreeAddressCode.Values;
using Model;
using Backend.Model;

namespace Backend.Analyses
{
	public class LiveVariablesAnalysis :BackwardDataFlowAnalysis<ISet<IVariable>>
	{
		private DataFlowAnalysisResult<ISet<IVariable>>[] result;
		private ISet<IVariable>[] GEN;
		private ISet<IVariable>[] KILL;

		public LiveVariablesAnalysis(ControlFlowGraph cfg)
			: base(cfg)
		{
		}

		public override DataFlowAnalysisResult<ISet<IVariable>>[] Analyze()
		{
			
			this.ComputeGen();
			this.ComputeKill();

			var result = base.Analyze();

			this.result = result;
			this.GEN = null;
			this.KILL = null;

			return result;
		}

		protected override ISet<IVariable> InitialValue(CFGNode node)
		{
			return GEN[node.Id];
		}

		protected override bool Compare(ISet<IVariable> left, ISet<IVariable> right)
		{
			return left.Equals(right);
		}

		protected override ISet<IVariable> Join(ISet<IVariable> left, ISet<IVariable> right)
		{
			var result = new HashSet<IVariable>(left);
			result.UnionWith(right);
			return result;
		}

		protected override ISet<IVariable> Flow(CFGNode node, ISet<IVariable> input)
		{
			var output = new HashSet<IVariable>(input);<commit_msg>Fix equals in LiveVariable Analysis<commit_after>﻿// Copyright (c) <NAME>.  All Rights Reserved.  Licensed under the MIT License.  See License.txt in the project root for license information.

using Backend.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model.ThreeAddressCode.Instructions;
using Model.ThreeAddressCode.Values;
using Model;
using Backend.Model;

namespace Backend.Analyses
{
	public class LiveVariablesAnalysis :BackwardDataFlowAnalysis<ISet<IVariable>>
	{
		private DataFlowAnalysisResult<ISet<IVariable>>[] result;
		private ISet<IVariable>[] GEN;
		private ISet<IVariable>[] KILL;

		public LiveVariablesAnalysis(ControlFlowGraph cfg)
			: base(cfg)
		{
		}

		public override DataFlowAnalysisResult<ISet<IVariable>>[] Analyze()
		{
			
			this.ComputeGen();
			this.ComputeKill();

			var result = base.Analyze();

			this.result = result;
			this.GEN = null;
			this.KILL = null;

			return result;
		}

		protected override ISet<IVariable> InitialValue(CFGNode node)
		{
			return GEN[node.Id];
		}

		protected override bool Compare(ISet<IVariable> left, ISet<IVariable> right)
		{
			return left.SetEquals(right);
		}

		protected override ISet<IVariable> Join(ISet<IVariable> left, ISet<IVariable> right)
		{
			var result = new HashSet<IVariable>(left);
			result.UnionWith(right);
			return result;
		}

		protected override ISet<IVariable> Flow(CFGNode node, ISet<IVariable> input)
		{
			var output = new HashSet<IVariable>(input);
{'fraction_non_alphanumeric': 0.10529823392202599, 'fraction_numerical': 0.0, 'mean_word_length': 4.632270168855535, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1355820', 'n_tokens_mistral': 1083, 'n_tokens_neox': 932, 'n_words': 235}