Exemple #1
0
        public TilePartComponent(TilePart tilePart, TileComponent tileComponent)
        {
            TilePart = tilePart;

            TileComponent = tileComponent;

            COC = tilePart.Header.COC[TileComponent.Component.ComponentIndex];
            QCC = tilePart.Header.QCC[TileComponent.Component.ComponentIndex];

            var nResolutions = COC.SP_NumberOfDecompositionLevels + 1;

            ResolutionLevels = new ResolutionLevel[nResolutions];

            for (var iResolution = 0; iResolution < nResolutions; iResolution++)
            {
                ResolutionLevels[iResolution] = new ResolutionLevel(this, iResolution);
            }

            if (COC.SP_WaveletTransformUsed == WaveletTransform.Reversible_5_3)
            {
                ArithmeticType = ArithmeticType.Int32;
            }
            else if (COC.SP_WaveletTransformUsed == WaveletTransform.Irreversible_9_7)
            {
                ArithmeticType = ArithmeticType.Double;
            }
            else
            {
                throw NotSupported(COC.SP_WaveletTransformUsed);
            }
        }
Exemple #2
0
            public ArithmeticNode(string val)
            {
                val = val.Trim();
                bool foundMatchingOp = false;

                foreach (ArithmeticOp op in AllOps)
                {
                    if (op.op == val)
                    {
                        this.arithemeticType = ArithmeticType.Operator;
                        this.ops.Add(op);
                        this.op         = val;
                        foundMatchingOp = true;
                        //Debug.Log("found dat match " + op.op);
                        // allow multiple matches (such as the unary and binary minus sign)
                    }
                }
                if (val == "(")
                {
                    this.arithemeticType = ArithmeticType.Paren;
                    this.paren           = new ArithmeticParen(true);
                    foundMatchingOp      = true;
                }
                else if (val == ")")
                {
                    this.arithemeticType = ArithmeticType.Paren;
                    this.paren           = new ArithmeticParen(false);
                    foundMatchingOp      = true;
                }
                if (!foundMatchingOp)
                {
                    arithemeticType = ArithmeticType.State;
                    variable        = new ArithmeticVarible(val.ToLower());
                }
            }
        /// <summary>
        /// Generate arithmetic operation.
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <param name="compareType"></param>
        /// <returns></returns>
        public static string GenerateArithmetiCode(string left, string right, ArithmeticType arithmeticType = ArithmeticType.Add)
        {
            if (left == null && right == null)
            {
                return(null);
            }
            switch (arithmeticType)
            {
            case ArithmeticType.Add:
                return(left + " + " + right);

            case ArithmeticType.Divide:
                return(left + " / " + right);

            case ArithmeticType.Modulo:
                return(left + " % " + right);

            case ArithmeticType.Multiply:
                return(left + " * " + right);

            case ArithmeticType.Subtract:
                return(left + " - " + right);
            }
            throw new System.InvalidCastException();
        }
		public decimal GetValue(byte[] rawValue, ArithmeticType arithmeticType, int scalePowerIndex)
		{
			bool wasNegative;
			var absoluteRawValue = ConvertToPositiveIfNeeded(rawValue, out wasNegative);

			var result = 0.0m;
			for (var byteIndex = 0; byteIndex < rawValue.Length; byteIndex++)
			{
				var @byte = absoluteRawValue[byteIndex];
				var lastByte = byteIndex == rawValue.Length - 1;

				var lastBitIndex = lastByte ? 6 : 7;
				for (var bitIndex = 0; bitIndex <= lastBitIndex; bitIndex++)
				{
					var bit = @byte & 0x01;
					if (bit == 1)
					{
						var powerIndex = GetPowerIndex(byteIndex, bitIndex, arithmeticType, rawValue.Length);
						var scaledPowerIndex = powerIndex - scalePowerIndex;
						var digitValue = GetPower(scaledPowerIndex);

						result += digitValue;
					}
					@byte = (byte)(@byte >> 1);
				}
			}

			if (wasNegative)
			{
				result *= -1;
			}

			return result;
		}
Exemple #5
0
        public Question(int a, int b, ArithmeticType type)
        {
            _type = type; _a = a; _b = b;
            switch (type)
            {
            case ArithmeticType.Add:
                Answer = _a + _b;
                break;

            case ArithmeticType.Subtract:
                Answer = _a - _b;
                break;

            case ArithmeticType.Multiply:
                Answer = _a * _b;
                break;

            case ArithmeticType.Divide:
                Answer = _a / _b;
                break;

            default:
                break;
            }
        }
		public DataPropertiesModel(
			int numberOfArguments, int numberOfFunctions,
			DataType argumentsType, DataType functionsType, ArithmeticType arithmeticType,
			int[] argumentScales, int[] functionScales)
		{
			NumberOfArguments = numberOfArguments;
			NumberOfFunctions = numberOfFunctions;
			ArgumentsType = argumentsType;
			FunctionsType = functionsType;
			ArithmeticType = arithmeticType;

			if (argumentScales != null)
			{
				if (argumentScales.Length != numberOfArguments)
				{
					throw new ArgumentException(Resources.ArgumentScalesCountMismatch);
				}

				this.argumentScales = new int[argumentScales.Length];
				argumentScales.CopyTo(this.argumentScales, 0);
				argumentScalesInitialized = true;
			}

			if (functionScales != null)
			{
				if (functionScales.Length != numberOfFunctions)
				{
					throw new ArgumentException(Resources.FunctionScalesCountMismatch);
				}

				this.functionScales = new int[functionScales.Length];
				functionScales.CopyTo(this.functionScales, 0);
				functionScalesInitialized = true;
			}
		}
Exemple #7
0
 public BinaryArithmeticCheatOperator(CheatOperator left, CheatOperator right, ArithmeticType ArithmeticType,
                                      ProcessManager processManager)
     : base(left.ValueType, processManager)
 {
     Left  = left;
     Right = right;
     this.ArithmeticType = ArithmeticType;
     CheatOperatorType   = CheatOperatorType.ARITHMETIC_TYPE;
 }
Exemple #8
0
 public static InverseDCLevelShifter Create(ArithmeticType arithmeticType)
 {
     return(arithmeticType switch
     {
         ArithmeticType.Int32 => new InverseInt32DCLevelShifter(),
         ArithmeticType.Single => new InverseSingleDCLevelShifter(),
         ArithmeticType.Double => new InverseDoubleDCLevelShifter(),
         _ => throw NotSupported(arithmeticType)
     });
		public CoreDataPropertiesDto(
			int numberOfArguments, int numberOfFunctions,
			DataType argumentsType, DataType functionsType, ArithmeticType arithmeticType)
		{
			NumberOfArguments = numberOfArguments;
			NumberOfFunctions = numberOfFunctions;
			ArgumentsType = argumentsType;
			FunctionsType = functionsType;
			ArithmeticType = arithmeticType;
		}
Exemple #10
0
 public ArithmeticNode(ArithmeticNode opHolder, ArithmeticOp unaryOp, ArithmeticNode applyTo)
 {
     this.op = unaryOp.op;
     this.ops.Add(unaryOp);
     this.children.Add(applyTo);
     applyTo.parent       = this;
     applyTo.merged       = true;
     opHolder.parent      = this;
     opHolder.merged      = true;
     this.arithemeticType = ArithmeticType.MergedUnaryOperator;
 }
Exemple #11
0
 public ArithmeticNode(ArithmeticNode opHolder, ArithmeticOp binaryOp, ArithmeticNode applyToA, ArithmeticNode applyToB)
 {
     this.op = binaryOp.op;
     this.ops.Add(binaryOp);
     this.children.Add(applyToA);
     applyToA.parent = this;
     applyToA.merged = true;
     applyToB.parent = this;
     applyToB.merged = true;
     opHolder.parent = this;
     opHolder.merged = true;
     this.children.Add(applyToB);
     this.arithemeticType = ArithmeticType.MergedBinaryOperator;
 }
		public FullDataPropertiesDto(
			int numberOfArguments, int numberOfFunctions,
			DataType argumentsType, DataType functionsType, ArithmeticType arithmeticType,
			int[] argumentScales, int[] functionScales)
		{
			NumberOfArguments = numberOfArguments;
			NumberOfFunctions = numberOfFunctions;
			ArgumentsType = argumentsType;
			FunctionsType = functionsType;
			ArithmeticType = arithmeticType;

			ArgumentScales = new int[argumentScales.Length];
			argumentScales.CopyTo(ArgumentScales, 0);
			FunctionScales = new int[functionScales.Length];
			functionScales.CopyTo(FunctionScales, 0);
		}
Exemple #13
0
        public override bool Parse(string[] cheat_elements, ref int start_idx, bool simple_format)
        {
            if (Left.Parse(cheat_elements, ref start_idx, simple_format))
            {
                return(false);
            }

            switch (cheat_elements[start_idx])
            {
            case "+":
                ArithmeticType = ArithmeticType.ADD_TYPE;
                break;

            case "-":
                ArithmeticType = ArithmeticType.SUB_TYPE;
                break;

            case "*":
                ArithmeticType = ArithmeticType.MUL_TYPE;
                break;

            case "/":
                ArithmeticType = ArithmeticType.DIV_TYPE;
                break;

            default:
                throw new Exception("ArithmeticType parse!!!");
            }
            ++start_idx;

            if (Right.Parse(cheat_elements, ref start_idx, simple_format))
            {
                return(false);
            }

            return(true);
        }
Exemple #14
0
        public void GenerateQuestions(ArithmeticType t)
        {
            switch (t)
            {
            case ArithmeticType.Add:
                GenerateAdditionQuestions();
                break;

            case ArithmeticType.Subtract:
                GenerateSubtractionQuestions();
                break;

            case ArithmeticType.Multiply:
                GenerateMultiplicationQuestions();
                break;

            case ArithmeticType.Divide:
                GenerateDivisionQuestions();
                break;

            default:
                break;
            }
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="byteIndex"></param>
		/// <param name="bitIndex">index of bit in byte. Starts from the right</param>
		/// <param name="arithmeticType"></param>
		/// <param name="bytesCount"></param>
		/// <returns></returns>
		public int GetPowerIndex(int byteIndex, int bitIndex, ArithmeticType arithmeticType, int bytesCount = -1)
		{
			int index;
			switch (arithmeticType)
			{
				case ArithmeticType.Integer:
					index = bitIndex + 8 * byteIndex;
					return index;
				case ArithmeticType.Fractional:
					if (bytesCount == -1)
					{
						throw new ArgumentException(InternalResources.BytesCountNotSpecified);
					}
					index = bitIndex - 7 - 8*(bytesCount - 1 - byteIndex);
					return index;
				default:
					throw new ArgumentException(string.Format(InternalResources.ArithmeticTypeUnknownMember, arithmeticType));
			}
		}
 /// <summary>
 /// Generate arithmetic operation.
 /// </summary>
 /// <param name="left"></param>
 /// <param name="right"></param>
 /// <param name="arithmeticType"></param>
 /// <returns></returns>
 public static string Arithmetic(this string left, string right, ArithmeticType arithmeticType)
 {
     return(CodeGenerator.GenerateArithmetiCode(left, right, arithmeticType));
 }
 private ItemSelector.CustomItem GetItem(Type type, Type param1, Type param2, Type returnType, MemberData data, ArithmeticType operatorType)
 {
     return(new ItemSelector.CustomItem(string.Format(operatorType.ToString() + " ({0}, {1})", param1.PrettyName(), param2.PrettyName()), () => {
         NodeEditorUtility.AddNewNode(graph.editorData, null, null, mousePositionOnCanvas, (MultiArithmeticNode n) => {
             if (param1.IsCastableTo(type))
             {
                 n.targets[0] = data;
                 n.targets[1] = new MemberData(ReflectionUtils.CreateInstance(param2));
             }
             else
             {
                 n.targets[0] = new MemberData(ReflectionUtils.CreateInstance(param1));
                 n.targets[1] = data;
             }
             n.operatorType = operatorType;
             graph.Refresh();
         });
     }, "Operator")
     {
         icon = uNodeEditorUtility.GetTypeIcon(returnType)
     });
 }
Exemple #18
0
 private static ItemSelector.CustomItem GetCustomItem(MultiArithmeticNode source, Type param1, Type param2, Type declaredType, Type returnType, ArithmeticType operatorType)
 {
     return(new ItemSelector.CustomItem(string.Format(operatorType.ToString() + " ({0}, {1})", param1.PrettyName(), param2.PrettyName()), () => {
         uNodeEditorUtility.RegisterUndo(source);
         source.operatorType = operatorType;
         while (source.targets.Count > 2)
         {
             source.targets.RemoveAt(source.targets.Count - 1);
         }
         source.targets[0].CopyFrom(new MemberData(ReflectionUtils.CreateInstance(param1)));
         source.targets[1].CopyFrom(new MemberData(ReflectionUtils.CreateInstance(param2)));
         uNodeGUIUtility.GUIChanged(source);
     }, declaredType.PrettyName() + " : Operator")
     {
         icon = uNodeEditorUtility.GetTypeIcon(returnType)
     });
 }
Exemple #19
0
 public ArithmeticNode(ArithmeticNode parent)
 {
     this.parent          = parent;
     this.arithemeticType = ArithmeticType.Scope;
 }
Exemple #20
0
 public static InverseMultipleComponentTransformer Create(WaveletTransform waveletTransformUsed, ArithmeticType arithmeticType)
 {
     if (waveletTransformUsed == WaveletTransform.Reversible_5_3)
     {
         return(arithmeticType switch
         {
             ArithmeticType.Int32 => new ReversibleInverseMultipleComponentTransformer(),
             _ => throw NotSupported(arithmeticType)
         });