Esempio n. 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);
                }
            }
        }
Esempio n. 2
0
File: Type.cs Progetto: 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);
 }
Esempio n. 3
0
 protected CodeObject(TypeEntity type)
 {
     this.type = type;
 }
Esempio n. 4
0
File: Type.cs Progetto: 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);
        }
Esempio n. 5
0
File: Type.cs Progetto: Djuffin/jcc
        public override bool Equals(object obj)
        {
            TypeEntity type = obj as TypeEntity;

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