Ejemplo n.º 1
0
        private void CompileBranchWithStringCompare(TextWriter writer, string label, bool branchIfTrue)
        {
            if (LeftCompiler.IsLiteral && LeftCompiler.CanCompileBoolean && IsBooleanValue(LeftCompiler.Value))
            {
                CompileBranchForStringVariable(writer, RightCompiler, label, LeftCompiler.BooleanValue ^ (ParentExpression.Operator.Token == Token.NotEqualTo));
            }
            else if (RightCompiler.IsLiteral && RightCompiler.CanCompileBoolean && IsBooleanValue(RightCompiler.Value))
            {
                CompileBranchForStringVariable(writer, LeftCompiler, label, RightCompiler.BooleanValue ^ (ParentExpression.Operator.Token == Token.NotEqualTo));
            }
            else
            {
                using (var tempVariables = Context.UseTempVariables())
                {
                    string leftValue  = LeftCompiler.Compile(writer, tempVariables.CreateVariable(LeftCompiler.Type));
                    string rightValue = RightCompiler.Compile(writer, tempVariables.CreateVariable(RightCompiler.Type));

                    //IEV3Variable tempResultVariable = tempVariables.CreateVariable(EV3Type.String);
                    //writer.WriteLine($"    CALL EQ_STRING {leftValue} {rightValue} {tempResultVariable.Ev3Name}");
                    //writer.WriteLine($"    AND8888_32 {tempResultVariable.Ev3Name} -538976289 {tempResultVariable.Ev3Name}");
                    //writer.WriteLine($"    STRINGS COMPARE {tempResultVariable.Ev3Name} 'TRUE' {tempResultVariable.Ev3Name}");
                    //writer.WriteLine($"    JR_{GetOperationForJump(branchIfTrue)}8 {tempResultVariable.Ev3Name} 0 {label}");
                    IEV3Variable tempResultVariable = tempVariables.CreateVariable(EV3Type.Float);
                    writer.WriteLine($"    CALL EQ_STRING8 {leftValue} {rightValue} {tempResultVariable.Ev3Name}");
                    writer.WriteLine($"    JR_{GetOperationForJump(branchIfTrue)}8 {tempResultVariable.Ev3Name} 0 {label}");
                }
            }
        }
Ejemplo n.º 2
0
        private void CompileBranchWithNumericCompare(TextWriter writer, string label, bool branchIfTrue)
        {
            using (var tempVariables = Context.UseTempVariables())
            {
                string leftValue  = LeftCompiler.Compile(writer, tempVariables.CreateVariable(LeftCompiler.Type));
                string rightValue = RightCompiler.Compile(writer, tempVariables.CreateVariable(RightCompiler.Type));

                writer.WriteLine($"    JR_{GetOperationForJump(!branchIfTrue)}F {leftValue} {rightValue} {label}");
            }
        }