示例#1
0
        /// <summary>
        /// Generates the IL code for declaration construction
        /// </summary>
        /// <param name="This">The declaration node.</param>
        void IStatementVisitor.Visit(Declare This)
        {
            TypeEntity type  = new TypeEntity(This.Type);
            int        index = 0;

            foreach (Variable var in This)
            {
                ILLocal    local = new ILLocal(type, var.Name, generator);
                Expression init  = This.GetInitExpression(index++);
                if (init != null)
                {
                    try
                    {
                        local.GenerateStore(generator.ExprEvaluator.Create(init));
                    }
                    catch (AnalizeException e)
                    {
                        throw new AnalizeException(e.Message, This);
                    }
                    IL.Emit(OpCodes.Pop);
                }
            }
        }
示例#2
0
文件: Type.cs 项目: Djuffin/jcc
 public static Type Translate(TypeEntity inType)
 {
     if (inType == TypeEntity.Int)
     {
         return(typeof(int));
     }
     if (inType == TypeEntity.Double)
     {
         return(typeof(double));
     }
     if (inType == TypeEntity.String)
     {
         return(typeof(string));
     }
     if (inType == TypeEntity.Void)
     {
         return(typeof(void));
     }
     if (inType == TypeEntity.Object)
     {
         return(typeof(object));
     }
     return(null);
 }
示例#3
0
文件: CodeObject.cs 项目: Djuffin/jcc
 protected CodeObject(TypeEntity type)
 {
     this.type = type;
 }
示例#4
0
文件: Type.cs 项目: Djuffin/jcc
        public static void GenerateExplicitCast(ILGenerator il, TypeEntity SourceType, TypeEntity DestType)
        {
            if (SourceType == DestType)
            {
                return;
            }

            if (!TypeEntity.CanCastTo(SourceType, DestType))
            {
                throw new AnalizeException(string.Format("Can't cast \"{0}\" to \"{1}\"", SourceType.Name, DestType.Name));
            }

            GenCast(il, SourceType, DestType);
        }
示例#5
0
文件: Type.cs 项目: Djuffin/jcc
        public override bool Equals(object obj)
        {
            TypeEntity type = obj as TypeEntity;

            return(Equals(type));
        }
示例#6
0
 protected ILCodeObject(TypeEntity type, ILCodeGenerator generator)
     : base(type)
 {
     this.generator = generator;
 }