Apply formatter, optional problems, save actions to machine project
[Mograsim.git] / net.mograsim.machine / src / net / mograsim / machine / mi / parameters / MnemonicFamily.java
index f4343bd..7ed69f9 100644 (file)
@@ -13,110 +13,110 @@ public class MnemonicFamily implements ParameterClassification
        private final String[] stringValues;
        private Map<String, Mnemonic> byText;
        private int vectorLength;
-       
+
        public MnemonicFamily(String... names)
        {
                this(false, (int) Math.round(Math.ceil(Math.log(names.length) / Math.log(2))), names);
        }
-       
+
        public MnemonicFamily(boolean reverse, String... names)
        {
                this(reverse, (int) Math.round(Math.ceil(Math.log(names.length) / Math.log(2))), names);
        }
-       
+
        public MnemonicFamily(int bits, String... names)
        {
                this(false, bits, names);
        }
-       
+
        public MnemonicFamily(boolean reverse, int bits, String... names)
        {
                this.values = new Mnemonic[names.length];
                this.stringValues = new String[names.length];
                BitVector[] values = new BitVector[names.length];
-               for(int i = 0; i < names.length; i++)
+               for (int i = 0; i < names.length; i++)
                {
                        values[i] = BitVector.from(i, bits);
                }
-               
+
                setup(names, values, reverse);
        }
-       
+
        public MnemonicFamily(String[] names, long[] values, int bits)
        {
                this(false, names, values, bits);
        }
-       
+
        public MnemonicFamily(boolean reverse, String[] names, long[] values, int bits)
        {
-               if(names.length != values.length)
+               if (names.length != values.length)
                        throw new IllegalArgumentException();
                this.values = new Mnemonic[values.length];
                this.stringValues = new String[values.length];
                BitVector[] vectors = new BitVector[values.length];
-               
-               for(int i = 0; i < vectors.length; i++)
+
+               for (int i = 0; i < vectors.length; i++)
                {
                        vectors[i] = BitVector.from(values[i], bits);
                }
-               
+
                setup(names, vectors, reverse);
        }
-       
+
        public MnemonicFamily(String[] names, BitVector[] values)
        {
                this(false, names, values);
        }
-       
+
        public MnemonicFamily(boolean reverse, String[] names, BitVector[] values)
        {
-               if(names.length != values.length)
+               if (names.length != values.length)
                        throw new IllegalArgumentException();
                this.values = new Mnemonic[values.length];
                this.stringValues = new String[values.length];
-               
+
                setup(names, values, reverse);
        }
-       
+
        public MnemonicFamily(MnemonicPair... values)
        {
                this(false, values);
        }
-       
+
        public MnemonicFamily(boolean reverse, MnemonicPair... values)
        {
                this.values = new Mnemonic[values.length];
                this.stringValues = new String[values.length];
-               
+
                setup(values);
        }
-       
+
        private void setup(String[] names, BitVector[] values, boolean reverse)
        {
                MnemonicPair[] mnemonics = new MnemonicPair[values.length];
-               for(int i = 0; i < values.length; i++)
+               for (int i = 0; i < values.length; i++)
                        mnemonics[i] = new MnemonicPair(names[i], reverse ? values[i].reverse() : values[i]);
                setup(mnemonics);
        }
-       
+
        private void setup(MnemonicPair[] values)
        {
-               for(int i = 0; i < values.length; i++)
+               for (int i = 0; i < values.length; i++)
                {
                        this.values[i] = createMnemonic(values[i], i);
                        this.stringValues[i] = values[i].name;
                }
-               if(values.length == 0)
+               if (values.length == 0)
                        vectorLength = 0;
                else
                {
                        vectorLength = values[0].value.length();
-                       for(int i = 1; i < values.length; i++)
-                               if(values[i].value.length() != vectorLength)
+                       for (int i = 1; i < values.length; i++)
+                               if (values[i].value.length() != vectorLength)
                                        throw new IllegalArgumentException("MnemonicFamily is not of uniform vector length!");
                }
                byText = Arrays.stream(this.values).collect(Collectors.toMap(m -> m.getText(), m -> m));
-               if(values.length != byText.keySet().size())
+               if (values.length != byText.keySet().size())
                        throw new IllegalArgumentException("MnemonicFamily contains multiple Mnemonics with the same name!");
        }
 
@@ -129,35 +129,35 @@ public class MnemonicFamily implements ParameterClassification
        {
                return values.clone();
        }
-       
+
        public Mnemonic get(int ordinal)
        {
                return values[ordinal];
        }
-       
+
        public Mnemonic get(String text)
        {
                return byText.get(text);
        }
-       
+
        public boolean contains(Mnemonic m)
        {
-               if(m != null)
+               if (m != null)
                        return m.owner == this;
                else
                        return false;
        }
-       
+
        public boolean contains(String value)
        {
                return byText.keySet().contains(value);
        }
-       
+
        public int size()
        {
                return values.length;
        }
-       
+
        public int getVectorLength()
        {
                return vectorLength;
@@ -185,7 +185,7 @@ public class MnemonicFamily implements ParameterClassification
        {
                return stringValues.clone();
        }
-       
+
        @Override
        public int hashCode()
        {
@@ -200,12 +200,12 @@ public class MnemonicFamily implements ParameterClassification
        {
                return this == obj;
        }
-       
+
        @Override
        public Mnemonic parse(String toParse)
        {
                Mnemonic parsed = get(toParse);
-               if(parsed == null)
+               if (parsed == null)
                        throw new UnknownMnemonicException(toParse);
                return parsed;
        }
@@ -214,7 +214,7 @@ public class MnemonicFamily implements ParameterClassification
        {
                public final String name;
                public final BitVector value;
-               
+
                public MnemonicPair(String name, BitVector value)
                {
                        this.name = name;