コード例 #1
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);
        }
コード例 #2
0
 public ExpressionAddElement(ExprPosition position, VariableUse lvalue, Expression rvalue)
     : base(position)
 {
     this.lvalue = lvalue;
     this.rvalue = rvalue;
 }