示例#1
0
 public override Expression MoveRight(Expression child, bool jumpIn)
 {
     // Without this modification of caret's expression side it would be needed
     // to press the left arrow key twice to move right because the auxiliary is invisible.
     if (Caret.Instance.ExpressionSide == ExpressionSide.Left)
     {
         Caret.Instance.ExpressionSide = ExpressionSide.Right;
     }
     return(ParentExpression.MoveRight(this, false));
 }
        protected override EV3Type CalculateType()
        {
            string propertyName      = ParentExpression.FullName().ToUpper();
            EV3SubDefinitionBase sub = Context.FindMethod(propertyName);

            if (sub != null)
            {
                return(sub.ReturnType);
            }

            return(EV3Type.Unknown);
        }
示例#3
0
        public override string Compile(TextWriter writer, IEV3Variable variable)
        {
            EV3SubDefinitionBase sub = Context.FindMethod(Value);

            if (sub != null)
            {
                return(CompileMethodCall(writer, variable, sub));
            }

            AddError($"Unknown method call to {ParentExpression.FullName()}");
            return("");
        }
        protected override string CalculateValue()
        {
            string valueString = ParentExpression.ToString();

            if (ParentExpression.IsNumericLiteral())
            {
                return(SmallBasicExtensions.FormatFloat(valueString));
            }
            else
            {
                return(valueString.Replace('"', '\''));
            }
        }
        protected override EV3Type CalculateType()
        {
            if (Variable.Type != EV3Type.Unknown && !Variable.Type.IsArray())
            {
                AddError($"Cannot use index on non-array variable '{VariableName}'");
            }

            index = ParentExpression.Index();

            Variable.UpdateMaxIndex(index);

            return(Variable.Type.BaseType());
        }
        public override string Compile(TextWriter writer, IEV3Variable variable)
        {
            EV3SubDefinitionBase sub = Context.FindMethod(Value);

            if (sub != null)
            {
                using (var tempVariables = Context.UseTempVariables())
                {
                    if (variable.Type.IsArray() && !sub.ReturnType.IsArray())
                    {
                        variable = tempVariables.CreateVariable(variable.Type.BaseType());
                    }
                    return(sub.Compile(writer, Context, new string[0], variable.Ev3Name));
                }
            }
            else
            {
                AddError($"Unknown property {ParentExpression.FullName()}");
            }

            return(variable.Ev3Name);
        }
        protected override EV3Type CalculateType()
        {
            string valueString = ParentExpression.ToString();

            if (ParentExpression.IsNumericLiteral())
            {
                return(EV3Type.Float);
            }
            else
            {
                Match match = Regex.Match(valueString, @"^""(?:[\d]+=[^;]*;)*([\d]+)=[^;]*[;]*""$");
                if (match.Success)
                {
                    maxIndex = int.Parse(match.Groups[1].Value);
                    return(EV3Type.StringArray);
                }
                else
                {
                    return(EV3Type.String);
                }
            }
        }
示例#8
0
        private void ActParentColumn_Click(System.Object sender, System.EventArgs e)
        {
            // ----- Check for valid data.
            if (ParentName.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please provide a column name.");
                ParentName.Focus();
                return;
            }
            if (ParentExpression.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please provide an expression.");
                ParentExpression.Focus();
                return;
            }

            // ----- Add the new column.
            try
            {
                ExampleData.Tables["Parent"].Columns.Add(ParentName.Text.Trim(),
                                                         Type.GetType("System." + ParentDataType.SelectedItem.ToString()),
                                                         ParentExpression.Text.Trim());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not add the column: " + ex.Message);
                return;
            }

            // ----- Refresh the columns used for quick computing.
            RefreshComputeColumns();

            // ----- Reset for another column.
            ParentName.Clear();
            ParentDataType.SelectedIndex = 0;
            ParentExpression.Clear();
        }
 protected override string CalculateValue()
 {
     return(ParentExpression.FullName().ToUpper());
 }
 private void HandleParent(Stack <IContextExpression> stack, ParentExpression node)
 {
     stack.Push(node);
 }