/// <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); } } }
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); }
protected CodeObject(TypeEntity type) { this.type = type; }
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); }
public override bool Equals(object obj) { TypeEntity type = obj as TypeEntity; return(Equals(type)); }
protected ILCodeObject(TypeEntity type, ILCodeGenerator generator) : base(type) { this.generator = generator; }