/// <summary> /// Coerce the specified vble to type t, by creating another vble. /// </summary> /// <param name="t">The type to coerce the value, as Type.</param> /// <param name="vble">A Variable which is to be coerced.</param> /// <returns>>A new variable with coerced type, or the same variable.</returns> public static Variable Coerce(CSim.Core.Type t, Variable vble) { Variable toret = vble; Id id = new Id( "a" ); id.SetIdWithoutChecks( "coerced_" + vble.Name.Name ); if ( t != vble.Type ) { toret = new Variable( id, t, vble.Machine ); toret.Address = vble.Address; } return toret; }
/// <summary> /// Initializes a new instance of the <see cref="CSim.Core.Function"/> class. /// Functions are defined by a return type, an indetifier, and a collection of /// formal parameters. /// </summary> /// <param name="id">The identifier of the function, as a string.</param> /// <param name="returnType">The return type, as a CSim.Core.Type.</param> /// <param name="formalParams">The formal parameters, as a vector.</param> protected Function(Machine m, string id, CSim.Core.Type returnType, Variable[] formalParams) { if ( id != null ) { id = id.Trim(); } if ( string.IsNullOrEmpty( id ) ) { throw new ArgumentException( "void id in fn." ); } if ( formalParams == null ) { formalParams = new Variable[]{}; } this.machine = m; this.formalParams = formalParams; this.id = id; this.returnType = returnType; }
/// <summary> /// Initializes a new instance of the <see cref="CSim.Core.Function"/> class. /// Functions are defined by a return type, an indetifier, and a collection of /// formal parameters. /// </summary> /// <param name="id">The identifier of the function, as a string.</param> /// <param name="returnType">The return type, as a CSim.Core.Type.</param> /// <param name="formalParams">The formal parameters, as a vector.</param> public EmbeddedFunction(Machine m, string id, CSim.Core.Type returnType, Variable[] formalParams) : base(m, id, returnType, formalParams) { }
/// <summary> /// Initializes a new instance of the <see cref="CSim.Core.EmbeddedFunction"/> class. /// Functions are defined by a return type, an indetifier, and a collection of /// formal parameters. Some functions don't accept any param. /// </summary> /// <param name="id">The identifier of the function, as a string.</param> /// <param name="returnType">The return type, as a CSim.Core.Type.</param> /// <param name="formalParams">The formal parameters, as a vector.</param> public EmbeddedFunction(Machine m, string id, CSim.Core.Type returnType) : base(m, id, returnType, null) { }
public RefVariable(Id id, CSim.Core.Type t, Machine m) : base(id, t, m) { this.SetType( m.TypeSystem.GetRefType( t ) ); this.pointedVble = null; }
public RefVariable(Id id, CSim.Core.Type t, Machine m, int address) : this(id, t, m) { this.Address = address; }
public Variable Add(Id id, CSim.Core.Type t) { return this.Add( new Variable( id, t, this.Machine, -1 ) ); }
public Variable Add(string id, CSim.Core.Type t) { return this.Add( new Id( id ), t ); }
public Variable AddVector(Id id, CSim.Core.Type t, long size) { return this.Add( new ArrayVariable( id, t, this.Machine, size ) ); }
/// <summary> /// Initializes a new instance of the <see cref="CSim.Core.Function"/> class. /// Functions are defined by a return type, an indetifier, and a collection of /// formal parameters. Some functions don't accept any param. /// </summary> /// <param name="id">The identifier of the function, as a string.</param> /// <param name="returnType">The return type, as a CSim.Core.Type.</param> protected Function(Machine m, string id, CSim.Core.Type returnType) : this(m, id, returnType, null) { }