Пример #1
0
        public Real()
            : base("Real", new Address("", "$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, AddressType.TypeSpace), "System.Double")
        {
            Function addition = new Function("Addition", "+", FunctionType.InfixExpression | FunctionType.Callable, this.Address, Address);

            addition.SingleRepetitiveParameterized = true;
            addition.ExecuteFunction += addition_ExecuteFunction;
            AddFunction(addition);

            Function subtraction = new Function("Subtraction", "-", FunctionType.InfixExpression, this.Address, Address, Address);

            subtraction.ExecuteFunction += subtraction_ExecuteFunction;
            AddFunction(subtraction);

            Function multiplication = new Function("Multiplication", "*", FunctionType.InfixExpression | FunctionType.Callable, this.Address, Address);

            multiplication.SingleRepetitiveParameterized = true;
            multiplication.ExecuteFunction += multiplication_ExecuteFunction;
            AddFunction(multiplication);

            Function division = new Function("Division", "/", FunctionType.InfixExpression, this.Address, Address, Address);

            division.ExecuteFunction += division_ExecuteFunction;
            AddFunction(division);

            string   castFromIntegerName = "$SYSTEM$_Runtime.CastTo_" + Address.FullPath.Replace("/", "_");
            Address  integerTypeAddress  = new Address("$SYSTEM$_Runtime.TypeSpace@" + typeof(TypeEngine).Name, "Integer", AddressType.TypeSpace);
            Function castIntegerToReal   = new Function("Cast from Integer to Real", castFromIntegerName, FunctionType.Callable, integerTypeAddress, "/Integer");

            castIntegerToReal.ExecuteFunction += castFromInteger_ExecuteFunction;
            Type integerType = TypeEngine.GetType(integerTypeAddress);

            integerType.AddFunction(castIntegerToReal);

            Function toString = new Function("ToString", "toString", FunctionType.PostfixExpression, this.Address, Address);

            toString.ExecuteFunction += ToString_ExecuteFunction;
            AddFunction(toString);
            Function fromString = new Function("FromString", "fromString", FunctionType.PostfixExpression, this.Address, "/String");

            fromString.ExecuteFunction += FromString_ExecuteFunction;
            AddFunction(fromString);
        }