예제 #1
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////// Right Hand Expressions Implementations /////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        #region Right Hand Expressions Implementations

        public override LLVMRegister VisitVariableAssignment([NotNull] ClepsParser.VariableAssignmentContext context)
        {
            string       variableName = context.variable().VariableName.Text;
            LLVMRegister ret          = VariableManager.GetVariable(variableName);

            return(ret);
        }
        public override object VisitVariableAssignment([NotNull] ClepsParser.VariableAssignmentContext context)
        {
            IValueRegister register = GetVariableRegister(context);

            if (register == null)
            {
                return(false);
            }

            IValue variableValue = CodeGenerator.GetRegisterValue(register);

            return(variableValue);
        }
        public override object VisitVariableAssignment([NotNull] ClepsParser.VariableAssignmentContext context)
        {
            IValueRegister register = GetVariableRegisterOrNullWithError(context);
            IValue         variableValue;

            if (register == null)
            {
                //Error occurred finding the register. Return some value to avoid stopping the compilation
                variableValue = CodeGenerator.CreateByte(0);
            }
            else
            {
                variableValue = CodeGenerator.GetRegisterValue(register);
            }

            return(variableValue);
        }
        private IValueRegister GetVariableRegisterOrNullWithError([NotNull] ClepsParser.VariableAssignmentContext context)
        {
            string         variableName    = Visit(context.variable()) as string;
            var            variableManager = VariableManagers.Last();
            IValueRegister register;

            if (!variableManager.IsVariableAvailable(variableName))
            {
                string errorMessage = String.Format("Variable {0} does not exist", variableName);
                Status.AddError(new CompilerError(FileName, context.Start.Line, context.Start.Column, errorMessage));
                register = null;
            }
            else
            {
                register = variableManager.GetVariableRegister(variableName);
            }

            return(register);
        }
예제 #5
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="ClepsParser.variableAssignment"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitVariableAssignment([NotNull] ClepsParser.VariableAssignmentContext context)
 {
 }
예제 #6
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="ClepsParser.variableAssignment"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitVariableAssignment([NotNull] ClepsParser.VariableAssignmentContext context)
 {
     return(VisitChildren(context));
 }