private void Update()
    {
        if (gameObject.activeInHierarchy)
        {
            rValueText.text = RValue.ToString();
            gValueText.text = GValue.ToString();
            bValueText.text = BValue.ToString();

            newColor = new Color32(System.Convert.ToByte(RValue), System.Convert.ToByte(GValue), System.Convert.ToByte(BValue), 255);

            colorPreview.color = newColor;
        }

        if (timer > 0)
        {
            timer -= Time.deltaTime;
        }
        else
        {
            if (mouseDownIncrease)
            {
                IncreaseColorValue((int)rGB);
            }
            if (mouseDownDecrease)
            {
                DecreaseColorValue((int)rGB);
            }
        }
    }
Beispiel #2
0
        public override void Execute(RValue[] realParams)
        {
            long address = this.Machine.Memory.Max;
            Variable vble = this.Machine.TDS.SolveToVariable( realParams[ 0 ] );
            var ptrVble = vble as PtrVariable;

            if ( ptrVble != null ) {
                address = ptrVble.IntValue.Value;
            }
            else
            if ( vble.Type == this.Machine.TypeSystem.GetIntType() ) {
                address = (long) vble.LiteralValue.Value;
            }
            else {
                throw new TypeMismatchException(
                    L18n.Get( L18n.Id.LblPointer ).ToLower()
                    + " (" + L18n.Get( L18n.Id.ErrNotAPointer )
                    + ": " + this.Id + ")"
                    );
            }

            this.Machine.TDS.DeleteBlk( address );

            Variable result = new TempVariable( Machine.TypeSystem.GetIntType() );
            result.LiteralValue = new IntLiteral( this.Machine, 0 );
            this.Machine.ExecutionStack.Push( result );
        }
Beispiel #3
0
        public override void Execute(RValue[] realParams)
        {
            var result = new TempVariable( this.Machine.TypeSystem.GetIntType() );
            result.LiteralValue = new IntLiteral( this.Machine, 0 );

            this.Machine.ExecutionStack.Push( result );
        }
Beispiel #4
0
        internal override ExpressionType EmitCs(EmitCodeContext codecontext)
        {
            // l = r

            VariableUse    lValueVariable = (VariableUse)LValue;
            ExpressionType lType          = codecontext.GetLocalVarType(Position, lValueVariable.VariableName);

            if (lType == null)
            {
                throw new GeneratorException(Position, lValueVariable.VariableName + " is not declared.");
            }

            if (lType.ListOf != null)
            {
                throw new GeneratorException(Position, "Unable to assign to a list.");
            }

            // TODO: lValue cannot be the method argument, unable to assign to the method argument, only adding to lists or modifying object properties.
            // arg1 = .. // error
            // arg1.prop1 = ... // ok
            // arg2[] = ... // ok

            codecontext.Write(lValueVariable.VariableName + " = ");

            ExpressionType rType = RValue.EmitCs(codecontext);

            if (!(lType.Equals(rType)))
            {
                throw new GeneratorException(Position, "Type mishmash.");
            }


            return(lType);
        }
Beispiel #5
0
 public static double?ToDoubleNullable(this RValue value)
 {
     if (value.Isnull)
     {
         return(null);
     }
     return(value.Val.Double_val);
 }
Beispiel #6
0
 public static short?ToShortNullable(this RValue value)
 {
     if (value.Isnull)
     {
         return(null);
     }
     return(value.Val.Smallint_val);
 }
Beispiel #7
0
 public static bool?ToBoolNullable(this RValue value)
 {
     if (value.Isnull)
     {
         return(null);
     }
     return(value.Val.Bool_val);
 }
Beispiel #8
0
 public static int?ToIntNullable(this RValue value)
 {
     if (value.Isnull)
     {
         return(null);
     }
     return(value.Val.Integer_val);
 }
Beispiel #9
0
        public static IEnumerable <long> ToLongEnumerator(this RValue value)
        {
            if (value.Isnull)
            {
                return(null);
            }

            return(value.Val.Array_val.Elements.Select(e => e.Bigint_val));
        }
Beispiel #10
0
        private RValue resolveMethodCall(RValue calledObj, string callName, IEnumerable <RValue> arguments = null)
        {
            if (arguments == null)
            {
                arguments = new RValue[0];
            }

            return(new MethodCallValue(calledObj, callName, arguments.ToArray(), CurrentContext));
        }
Beispiel #11
0
        public static IEnumerable <DateTime> ToDateTimeEnumerator(this RValue value)
        {
            if (value.Isnull)
            {
                return(null);
            }

            return(value.Val.Array_val.Elements.Select(e => e.Bigint_val.FromEpochMsToDate()));
        }
Beispiel #12
0
        public static IEnumerable <double> ToDoubleEnumerator(this RValue value)
        {
            if (value.Isnull)
            {
                return(null);
            }

            return(value.Val.Array_val.Elements.Select(e => e.Double_val));
        }
Beispiel #13
0
        public static IEnumerable <short> ToShortEnumerator(this RValue value)
        {
            if (value.Isnull)
            {
                return(null);
            }

            return(value.Val.Array_val.Elements.Select(e => e.Smallint_val));
        }
Beispiel #14
0
        public static IEnumerable <int> ToIntEnumerator(this RValue value)
        {
            if (value.Isnull)
            {
                return(null);
            }

            return(value.Val.Array_val.Elements.Select(e => e.Integer_val));
        }
Beispiel #15
0
        public static IEnumerable <bool> ToBoolEnumerator(this RValue value)
        {
            if (value.Isnull)
            {
                return(null);
            }

            return(value.Val.Array_val.Elements.Select(e => e.Bool_val));
        }
Beispiel #16
0
        public static long?ToLongNullable(this RValue value)
        {
            if (value.Isnull)
            {
                return(null);
            }

            return(value.Val.Bigint_val);
        }
Beispiel #17
0
        public static IEnumerable <string> ToStringEnumerator(this RValue value)
        {
            if (value.Isnull)
            {
                return(null);
            }

            return(value.Val.Array_val.Elements.Select(e => e.String_val));
        }
Beispiel #18
0
        public override void Execute(RValue[] realParams)
        {
            var result = new TempVariable( this.Machine.TypeSystem.GetIntType() );
            result.LiteralValue = new IntLiteral(
                this.Machine,
                Convert.ToInt64( Math.Ceiling( DateTime.Now.TimeOfDay.TotalSeconds ) ) );

            this.Machine.ExecutionStack.Push( result );
        }
Beispiel #19
0
        public static string ToStringNullable(this RValue value)
        {
            if (value.Isnull)
            {
                return(null);
            }

            return(value.Val.String_val);
        }
Beispiel #20
0
        public static DateTime?ToDateTimeNullable(this RValue value)
        {
            if (value.Isnull)
            {
                return(null);
            }

            return(value.Val.Bigint_val.FromEpochMsToDate());
        }
Beispiel #21
0
        public static object ToObjectValue(this RValue value)
        {
            if (value.Isnull)
            {
                return(null);
            }

            if (value.Val.__isset.array_val)
            {
                return(value.Val.Array_val);
            }
            else if (value.Val.__isset.bigint_val)
            {
                return(value.Val.Bigint_val);
            }
            else if (value.Val.__isset.binary_val)
            {
                return(value.Val.Binary_val);
            }
            else if (value.Val.__isset.bool_val)
            {
                return(value.Val.Bool_val);
            }
            else if (value.Val.__isset.double_val)
            {
                return(value.Val.Double_val);
            }
            else if (value.Val.__isset.integer_val)
            {
                return(value.Val.Integer_val);
            }
            else if (value.Val.__isset.msfromepoch_val)
            {
                return(value.Val.Msfromepoch_val);
            }
            else if (value.Val.__isset.smallint_val)
            {
                return(value.Val.Smallint_val);
            }
            else if (value.Val.__isset.string_val)
            {
                return(value.Val.String_val);
            }
            else if (value.Val.__isset.tinyint_val)
            {
                return(value.Val.Tinyint_val);
            }
            // should not occur
            else
            {
                return(null);
            }
        }
Beispiel #22
0
        private RValue resolveMethodCall(RValue calledObj, Node callNode)
        {
            //TODO create signature based support for lambdaBlocks
            var callName = GetTerminalText(callNode, "callName", "identifier");

            switch (callName)
            {
            case "each":
                var lambdaBlockNode = GetDescendant(callNode, "lambdaBlock");

                var enumeratedItemType = calledObj.ReturnType().GetGenericArguments()[0];
                var lambdaBlock        = resolveLambdaBlock(lambdaBlockNode, enumeratedItemType);
                return(new ForeachValue(calledObj, lambdaBlock, CurrentContext));

            default:
                var args = getArguments(callNode);
                return(resolveMethodCall(calledObj, callName, args));
            }
        }
Beispiel #23
0
 private void RegisterDialog_Shown(object sender, EventArgs e)
 {
     RValue.Focus();
 }
Beispiel #24
0
 public void WriteToBytes(Span <byte> out64)
 {
     PubKey.WriteToSpan(out64);
     RValue.WriteToSpan(out64.Slice(32));
 }
Beispiel #25
0
 public static DateTime ToDateTime(this RValue value)
 {
     return(value.Val.Bigint_val.FromEpochMsToDate());
 }
Beispiel #26
0
 public static double ToDouble(this RValue value)
 {
     return(value.Val.Double_val);
 }
Beispiel #27
0
 public static short ToShort(this RValue value)
 {
     return(value.Val.Smallint_val);
 }
Beispiel #28
0
 public static int ToInt(this RValue value)
 {
     return(value.Val.Integer_val);
 }
Beispiel #29
0
 public static bool ToBool(this RValue value)
 {
     return(value.Val.Bool_val);
 }
Beispiel #30
0
 private RValue resolveCondition(RValue conditionValue)
 {
     return(new ConditionValue(conditionValue, CurrentContext));
 }
        public override string ToString()
        {
            string op = "";

            switch (Operation)
            {
            case Opcode.EQ: op = "==";   break;

            case Opcode.LT: op = "<";    break;

            case Opcode.LE: op = "<=";   break;

            case Opcode.ADD: op = "+";   break;

            case Opcode.SUB: op = "-";   break;

            case Opcode.MUL: op = "*";   break;

            case Opcode.DIV: op = "/";   break;

            case Opcode.AND: op = "and"; break;

            case Opcode.OR: op = "or";   break;

            case Opcode.POW: op = "^";   break;
            }
            string assignVal = mAssignmentLvalue != null ? mAssignmentLvalue + " = " : "";
            string retVal    = String.Format("{0}{1} {2} {3}", assignVal, LValue.ToString().Trim(), op, RValue.ToString().Trim());

            if (mAssignmentLvalue != null)
            {
                retVal += "\n";
            }
            if (assignVal == "" && LocalName != null)
            {
                return(LocalName);
            }
            return(retVal);
        }
Beispiel #32
0
 public static string ToStringValue(this RValue value)
 {
     return(value.Val.String_val);
 }
Beispiel #33
0
 public static long ToLong(this RValue value)
 {
     return(value.Val.Bigint_val);
 }