Esempio n. 1
0
 public override int GetSize(CompilerContext c)
 {
     c.Report.Error(2070, "'void': illegal sizeof operand");
     return(0);
 }
Esempio n. 2
0
 bool HasRankGreaterThan(CBasicType otherBasicType, CompilerContext context)
 {
     return(false);
 }
Esempio n. 3
0
 public override int GetSize(CompilerContext c)
 {
     return(c.MachineInfo.PointerSize);
 }
Esempio n. 4
0
        /// <summary>
        /// Section 6.3.1.8 (page 53) of N1570
        /// </summary>
        /// <returns>
        /// The converted type.
        /// </returns>
        /// <param name='otherType'>
        /// The other type participating in the arithmetic.
        /// </param>
        /// <param name='context'>
        /// Context.
        /// </param>
        public CBasicType ArithmeticConvert(CType otherType, CompilerContext context)
        {
            var otherBasicType = otherType as CBasicType;

            if (otherBasicType == null)
            {
                context.Report.Error(19, "Cannot perform arithmetic with " + otherType);
                return(CBasicType.SignedInt);
            }
            if (Name == "double" || otherBasicType.Name == "double")
            {
                return(Double);
            }
            else if (Name == "single" || otherBasicType.Name == "single")
            {
                return(Float);
            }
            else
            {
                var p1    = IntegerPromote(context);
                var size1 = p1.GetSize(context);

                var p2    = otherBasicType.IntegerPromote(context);
                var size2 = p2.GetSize(context);

                if (p1.Signedness == p2.Signedness)
                {
                    return(size1 >= size2 ? p1 : p2);
                }
                else
                {
                    if (p1.Signedness == Signedness.Unsigned)
                    {
                        if (size1 > size2)                          //p1.HasRankGreaterThan (p2, context)) {
                        {
                            return(p1);
                        }
                        else
                        {
                            if (size2 > size1)
                            {
                                return(p2);
                            }
                            else
                            {
                                return(new CBasicType(p2.Name, Signedness.Unsigned, p2.Size));
                            }
                        }
                    }
                    else
                    {
                        if (size2 > size1)                          //p2.HasRankGreaterThan (p1, context)) {
                        {
                            return(p2);
                        }
                        else
                        {
                            if (size1 > size2)
                            {
                                return(p1);
                            }
                            else
                            {
                                return(new CBasicType(p1.Name, Signedness.Unsigned, p1.Size));
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
 public abstract int GetSize(CompilerContext c);
Esempio n. 6
0
 public Compiler(CompilerContext context)
 {
     this.context = context;
     tus          = new List <TranslationUnit> ();
 }
Esempio n. 7
0
 public FunctionContext(Executable exe, FunctionDeclaration fdecl, CompiledFunction fexe, CompilerContext context)
     : base(context.MachineInfo, context.Report, fdecl)
 {
     this.exe     = exe;
     this.fdecl   = fdecl;
     this.fexe    = fexe;
     this.context = context;
     blocks       = new List <Block> ();
     blockLocals  = new Dictionary <Block, BlockLocals> ();
     allLocals    = new List <VariableDeclaration> ();
 }
Esempio n. 8
0
 public ResolveContext(CompilerContext c)
 {
     Compiler = c;
 }