예제 #1
0
파일: Opcode.cs 프로젝트: Baltasarq/CSim
        /// <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
파일: Function.cs 프로젝트: Baltasarq/CSim
        /// <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
파일: Function.cs 프로젝트: Baltasarq/CSim
 /// <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)
 {
 }