Пример #1
0
        /// <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;
        }
Пример #2
0
        /// <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;
        }
Пример #3
0
 /// <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)
 {
 }
Пример #4
0
 /// <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)
 {
 }
Пример #5
0
 public RefVariable(Id id, CSim.Core.Type t, Machine m)
     : base(id, t, m)
 {
     this.SetType( m.TypeSystem.GetRefType( t ) );
     this.pointedVble = null;
 }
Пример #6
0
 public RefVariable(Id id, CSim.Core.Type t, Machine m, int address)
     : this(id, t, m)
 {
     this.Address = address;
 }
Пример #7
0
 public Variable Add(Id id, CSim.Core.Type t)
 {
     return this.Add( new Variable( id, t, this.Machine, -1 ) );
 }
Пример #8
0
 public Variable Add(string id, CSim.Core.Type t)
 {
     return this.Add( new Id( id ), t );
 }
Пример #9
0
 public Variable AddVector(Id id, CSim.Core.Type t, long size)
 {
     return this.Add( new ArrayVariable( id, t, this.Machine, size ) );
 }
Пример #10
0
 /// <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)
 {
 }