Example #1
0
        protected override int GetPriority(CiExpr expr)
        {
            CiPropertyAccess pa = expr as CiPropertyAccess;

            if (pa != null)
            {
                if (pa.Property == CiLibrary.SByteProperty)
                {
                    return(GetPriority(pa.Obj));
                }
                if (pa.Property == CiLibrary.LowByteProperty)
                {
                    return(2);
                }
            }
            else if (expr is CiCoercion)
            {
                CiCoercion c = (CiCoercion)expr;
                if (c.ResultType == CiByteType.Value && c.Inner.Type == CiIntType.Value)
                {
                    return(2);
                }
                if (c.ResultType == CiIntType.Value && c.Inner.Type == CiByteType.Value)
                {
                    return(8);
                }
            }
            return(base.GetPriority(expr));
        }
Example #2
0
 protected override void Write(CiPropertyAccess expr)
 {
     if (expr.Property == CiLibrary.SByteProperty)
     {
         Write(expr.Obj);
     }
     else if (expr.Property == CiLibrary.LowByteProperty)
     {
         Write("(byte) ");
         WriteChild(expr, expr.Obj);
     }
     else if (expr.Property == CiLibrary.StringLengthProperty)
     {
         WriteChild(expr, expr.Obj);
         Write(".length()");
     }
     else
     {
         throw new ArgumentException(expr.Property.Name);
     }
 }
Example #3
0
 protected override void Write(CiPropertyAccess expr)
 {
     if (expr.Property == CiLibrary.SByteProperty)
     {
         Write('(');
         WriteChild(9, expr.Obj);
         Write(" ^ 128) - 128");
     }
     else if (expr.Property == CiLibrary.LowByteProperty)
     {
         WriteChild(expr, expr.Obj);
         Write(" & 0xff");
     }
     else if (expr.Property == CiLibrary.StringLengthProperty)
     {
         Write("length(");
         Write(expr.Obj);
         Write(')');
     }
     else
     {
         throw new ArgumentException(expr.Property.Name);
     }
 }
Example #4
0
File: GenJava.cs Project: epi/cito
 protected override void Write(CiPropertyAccess expr)
 {
     if (expr.Property == CiLibrary.SByteProperty)
     Write(expr.Obj);
     else if (expr.Property == CiLibrary.LowByteProperty) {
     Write("(byte) ");
     WriteChild(expr, expr.Obj);
     }
     else if (expr.Property == CiLibrary.StringLengthProperty) {
     WriteChild(expr, expr.Obj);
     Write(".length()");
     }
     else
     throw new ArgumentException(expr.Property.Name);
 }
Example #5
0
File: GenAs.cs Project: epi/cito
 protected override void Write(CiPropertyAccess expr)
 {
     if (expr.Property == CiLibrary.SByteProperty) {
     Write('(');
     WriteChild(CiPriority.Xor, expr.Obj);
     Write(" ^ 128) - 128");
     }
     else if (expr.Property == CiLibrary.LowByteProperty) {
     WriteChild(expr, expr.Obj);
     Write(" & 0xff");
     }
     else if (expr.Property == CiLibrary.StringLengthProperty) {
     WriteChild(expr, expr.Obj);
     Write(".length");
     }
     else
     throw new ArgumentException(expr.Property.Name);
 }
Example #6
0
 protected abstract void Write(CiPropertyAccess expr);
Example #7
0
 protected abstract void Write(CiPropertyAccess expr);
Example #8
0
File: GenC.cs Project: epi/cito
 protected override void Write(CiPropertyAccess expr)
 {
     if (expr.Property == CiLibrary.SByteProperty) {
     Write("(signed char) ");
     WriteChild(expr, expr.Obj);
     }
     else if (expr.Property == CiLibrary.LowByteProperty) {
     Write("(unsigned char) ");
     WriteChild(expr, expr.Obj);
     }
     else if (expr.Property == CiLibrary.StringLengthProperty) {
     Write("(int) strlen(");
     WriteChild(expr, expr.Obj);
     Write(')');
     }
     else
     throw new ArgumentException(expr.Property.Name);
 }