<commit_before>package Modules {
	import Components.Port;
	import Layouts.Nodes.WideNode;
	import Levels.Level;
	import Values.*;
	import Layouts.*;
	import Layouts.Nodes.StandardNode;
	import flash.geom.Point;
	/**
	 * ...
	 * @author Nicholas "PleasingFungus" Feinberg
	 */
	public class InstructionComparator extends Module {
		
		public var compareValue:OpcodeValue;
		protected var level:Level;
		public function InstructionComparator(X:int, Y:int, CompareValue:int = 0) {
			super(X, Y, "I-Comp", Module.CAT_LOGIC, 1, 1, 0);
			
			configuration = new OpConfiguration;
			if (U.state)
				configuration.setValue(CompareValue);

			setByConfig();
			delay = 1;
		}
		
		override public function getConfiguration():Configuration {
			if (!U.state)
				return configuration = new OpConfiguration;
			if (U.state.level != level) {
				configuration = new OpConfiguration;
				level = U.state.level;
			}
			return configuration;
		}
		
		override public function setByConfig():void {
			compareValue = (configuration as OpConfiguration).opValue;
		}
		
		override protected function generateLayout():ModuleLayout {
			var layout:ModuleLayout = new DefaultLayout(this, 1, 5);
			return layout;
		}
		
		override protected function generateInternalLayout():InternalLayout {
			var outport:PortLayout = layout.ports[1];
			return new InternalLayout([new StandardNode(this, new Point(outport.offset.x - layout.dim.x / 2 - 1 / 2, outport.offset.y),
														[layout.ports[0], layout.ports[1]], [],
														function getValue():Value { return drive(outputs[0]); }, "Opcodes match" ),
									   new WideNode(this, new Point(outport.offset.x - layout.dim.x / 2 - 1 / 2, outport.offset.y - 2),
														[], [],
														function getValue():Value { return compareValue; }, "Comparison opcode")]);
		}
		
		override public function renderDetails():String {
			return "I=" + "\n"+compareValue+"\n\n" + drive(null);
		}
		
		override public function getDescription():String {
			return "Outputs "+BooleanValue.TRUE+" if the input is "+(configuration as OpConfiguration).opValue+", else "+BooleanValue.FALSE+"."
		}
		
		
		override public function drive(port:Port):Value {
			var input:Value = inputs[0].getValue();
			if (input.unknown || input.unpowered)
				return input;
			return input.eq(compareValue) ? BooleanValue.TRUE : BooleanValue.FALSE;
		}
		
		override protected function getSaveValues():Array {
			var values:Array = super.getSaveValues();
			values.push(compareValue.toNumber());
			return values;
		}
		
	}

}<commit_msg>Temporarily turned of icomp in-place config<commit_after>package Modules {
	import Components.Port;
	import Layouts.Nodes.WideNode;
	import Levels.Level;
	import Values.*;
	import Layouts.*;
	import Layouts.Nodes.StandardNode;
	import flash.geom.Point;
	/**
	 * ...
	 * @author Nicholas "PleasingFungus" Feinberg
	 */
	public class InstructionComparator extends Module {
		
		public var compareValue:OpcodeValue;
		protected var level:Level;
		public function InstructionComparator(X:int, Y:int, CompareValue:int = 0) {
			super(X, Y, "I-Comp", Module.CAT_LOGIC, 1, 1, 0);
			
			configuration = new OpConfiguration;
			if (U.state)
				configuration.setValue(CompareValue);

			setByConfig();
			delay = 1;
			configurableInPlace = false; //TODO: FIXME
		}
		
		override public function getConfiguration():Configuration {
			if (!U.state)
				return configuration = new OpConfiguration;
			if (U.state.level != level) {
				configuration = new OpConfiguration;
				level = U.state.level;
			}
			return configuration;
		}
		
		override public function setByConfig():void {
			compareValue = (configuration as OpConfiguration).opValue;
		}
		
		override protected function generateLayout():ModuleLayout {
			var layout:ModuleLayout = new DefaultLayout(this, 1, 5);
			return layout;
		}
		
		override protected function generateInternalLayout():InternalLayout {
			var outport:PortLayout = layout.ports[1];
			return new InternalLayout([new StandardNode(this, new Point(outport.offset.x - layout.dim.x / 2 - 1 / 2, outport.offset.y),
														[layout.ports[0], layout.ports[1]], [],
														function getValue():Value { return drive(outputs[0]); }, "Opcodes match" ),
									   new WideNode(this, new Point(outport.offset.x - layout.dim.x / 2 - 1 / 2, outport.offset.y - 2),
														[], [],
														function getValue():Value { return compareValue; }, "Comparison opcode")]);
		}
		
		override public function renderDetails():String {
			return "I=" + "\n"+compareValue+"\n\n" + drive(null);
		}
		
		override public function getDescription():String {
			return "Outputs "+BooleanValue.TRUE+" if the input is "+(configuration as OpConfiguration).opValue+", else "+BooleanValue.FALSE+"."
		}
		
		
		override public function drive(port:Port):Value {
			var input:Value = inputs[0].getValue();
			if (input.unknown || input.unpowered)
				return input;
			return input.eq(compareValue) ? BooleanValue.TRUE : BooleanValue.FALSE;
		}
		
		override protected function getSaveValues():Array {
			var values:Array = super.getSaveValues();
			values.push(compareValue.toNumber());
			return values;
		}
		
	}

}
{'fraction_non_alphanumeric': 0.12403400309119011, 'fraction_numerical': 0.007341576506955177, 'mean_word_length': 3.5452151009657595, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5199781', 'n_tokens_mistral': 1871, 'n_tokens_neox': 1486, 'n_words': 379}