[Tinyos-commits] CVS: tinyos-1.x/tos/lib/VM/languages/motlle/mate/runtime FNseq.nc, NONE, 1.1 FNtranscendentals.nc, NONE, 1.1 FNtranscendentalsM.nc, NONE, 1.1 FNreal.nc, 1.2, 1.3 FNrealM.nc, 1.2, 1.3 FNseqM.nc, 1.2, 1.3

David Gay idgay at users.sourceforge.net
Sun Oct 23 15:37:11 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/runtime
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6283

Modified Files:
	FNreal.nc FNrealM.nc FNseqM.nc 
Added Files:
	FNseq.nc FNtranscendentals.nc FNtranscendentalsM.nc 
Log Message:
transcendentals
FNseq configuration


--- NEW FILE: FNseq.nc ---
configuration FNseq {
  provides {
    //interface MateBytecode as Map;
    interface MateBytecode as ForEach;
    interface MateBytecode as Vector2List;
    interface MateBytecode as List2Vector;
    interface MateBytecode as String2List;
    interface MateBytecode as List2String;
    interface MateBytecode as Length;
    interface MotlleFrame as MapFrame;
  }
}
implementation {
  components FNseqM, MProxy;

  ForEach = FNseqM.ForEach;
  Vector2List = FNseqM.Vector2List;
  List2Vector = FNseqM.List2Vector;
  String2List = FNseqM.String2List;
  List2String = FNseqM.List2String;
  Length = FNseqM.Length;
  MapFrame = FNseqM.MapFrame;

  FNseqM.GC -> MProxy;
  FNseqM.S -> MProxy;
  FNseqM.T -> MProxy;
  FNseqM.E -> MProxy;
  FNseqM.V -> MProxy;
}

--- NEW FILE: FNtranscendentals.nc ---
configuration FNtranscendentals {
  provides {
    interface MateBytecode as Sqrt;
    interface MateBytecode as Sin;
    interface MateBytecode as Cos;
    interface MateBytecode as Tan;
    interface MateBytecode as Asin;
    interface MateBytecode as Acos;
    interface MateBytecode as Atan;
    interface MateBytecode as Exp;
    interface MateBytecode as Log;
    interface MateBytecode as Expt;
  }
}
implementation {
  components FNtranscendentalsM, MProxy;

  Sqrt = FNtranscendentalsM.Sqrt;
  Sin = FNtranscendentalsM.Sin;
  Cos = FNtranscendentalsM.Cos;
  Tan = FNtranscendentalsM.Tan;
  Asin = FNtranscendentalsM.Asin;
  Acos = FNtranscendentalsM.Acos;
  Atan = FNtranscendentalsM.Atan;
  Exp = FNtranscendentalsM.Exp;
  Log = FNtranscendentalsM.Log;
  Expt = FNtranscendentalsM.Expt;

  FNtranscendentalsM.S -> MProxy;
  FNtranscendentalsM.T -> MProxy;
  FNtranscendentalsM.E -> MProxy;
}

--- NEW FILE: FNtranscendentalsM.nc ---
module FNtranscendentalsM {
  provides {
    interface MateBytecode as Sqrt;
    interface MateBytecode as Sin;
    interface MateBytecode as Cos;
    interface MateBytecode as Tan;
    interface MateBytecode as Asin;
    interface MateBytecode as Acos;
    interface MateBytecode as Atan;
    interface MateBytecode as Exp;
    interface MateBytecode as Log;
    interface MateBytecode as Expt;
  }
  uses {
    interface MotlleStack as S;
    interface MotlleTypes as T;
    interface MateError as E;
  }
}
implementation {
#define TRANS(name, op) \
  { \
    mvalue x = call S.pop(context, 1); \
    if (call T.numberp(x)) \
      {
	vreal r = op(call T.number(x)); \
	call S.qpush(context, call T.make_real(r)); \
      } \
    else \
      call E.error(context, MOTLLE_ERROR_BAD_TYPE); \
    return SUCCESS; \
  }
 \
  command uint8_t name.byteLength() { \
    return 1; \
  }

  //FN sqrt: r1 -> r2. Return sqrt(r1)
  command result_t Sqrt.execute(uint8_t instr, MateContext *context) 
    TRANS(Sqrt, sqrt)

  //FN sin: r1 -> r2. Return sin(r1)
  command result_t Sin.execute(uint8_t instr, MateContext *context) 
    TRANS(Sin, sin)

  //FN cos: r1 -> r2. Return cos(r1)
  command result_t Cos.execute(uint8_t instr, MateContext *context) 
    TRANS(Cos, cos)

  //FN tan: r1 -> r2. Return tan(r1)
  command result_t Tan.execute(uint8_t instr, MateContext *context) 
    TRANS(Tan, tan)

  //FN asin: r1 -> r2. Return asin(r1)
  command result_t Asin.execute(uint8_t instr, MateContext *context) 
    TRANS(Asin, asin)

  //FN acos: r1 -> r2. Return acos(r1)
  command result_t Acos.execute(uint8_t instr, MateContext *context) 
    TRANS(Acos, acos)

  //FN exp: r1 -> r2. Return exp(r1)
  command result_t Exp.execute(uint8_t instr, MateContext *context) 
    TRANS(Exp, exp)

  //FN log: r1 -> r2. Return log(r1)
  command result_t Log.execute(uint8_t instr, MateContext *context) 
    TRANS(Log, log)


  //FN expt: r1 r2 -> r3. r3 = r1 raised to the r2'th power
  command result_t Expt.execute(uint8_t instr, MateContext *context) {
    mvalue y = call S.pop(context, 1);
    mvalue x = call S.pop(context, 1);

    if (call T.numberp(x) && call T.numberp(y))
      {
	vreal r = pow(call T.number(x), call T.number(y));
	call S.qpush(context, call T.make_real(r));
      }
    else
      call E.error(context, MOTLLE_ERROR_BAD_TYPE);
    return SUCCESS;
  }

  command uint8_t Expt.byteLength() {
    return 1;
  }

  //FN atan: r1 ... -> r3. r3 = atan(r1) or r3 = atan(r2/r1)
  command result_t Atan.execute(uint8_t nargs, MateContext *context) {
    vreal result = 0;

    if (nargs == 1)
      {
	mvalue x = call S.pop(context, 1);

	if (call T.numberp(x))
	  result = atan(call V.number(x));
	else
	  call E.error(context, MOTLLE_ERROR_BAD_TYPE);
      }
    else if (nargs == 2)
      {
	mvalue x = call S.pop(context, 1);
	mvalue y = call S.pop(context, 1);

	if (call T.numberp(x) && call T.numberp(y))
	  result = atan2(call V.number(y), call V.number(x));
	else
	  call E.error(context, MOTLLE_ERROR_BAD_TYPE);
      }
    else
      call E.error(context, MOTLLE_ERROR_WRONG_PARAMETERS);

    call S.qpush(context, call T.make_real(r));

    return SUCCESS;
  }

  command uint8_t Atan.byteLength() {
    return 1;
  }
}

Index: FNreal.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/runtime/FNreal.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FNreal.nc	30 Nov 2004 18:52:43 -0000	1.2
--- FNreal.nc	23 Oct 2005 22:37:09 -0000	1.3
***************
*** 1,4 ****
--- 1,5 ----
  configuration FNreal {
    provides {
+     interface MateBytecode as RealP;
      interface MateBytecode as NumberP;
      interface MateBytecode as FloatP;
***************
*** 11,14 ****
--- 12,16 ----
    components FNrealM, MProxy;
  
+   RealP = FNrealM.RealP;
    NumberP = FNrealM.NumberP;
    FloatP = FNrealM.FloatP;

Index: FNrealM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/runtime/FNrealM.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FNrealM.nc	30 Nov 2004 18:52:43 -0000	1.2
--- FNrealM.nc	23 Oct 2005 22:37:09 -0000	1.3
***************
*** 3,6 ****
--- 3,7 ----
      interface MateBytecode as FloatP;
      interface MateBytecode as NumberP;
+     interface MateBytecode as RealP;
      interface MateBytecode as Floor;
      interface MateBytecode as Ceiling;
***************
*** 22,25 ****
--- 23,28 ----
  	call S.qpush(context, call T.make_int(ix));
        }
+     else if (call T.intp(x))
+       call S.qpush(context, x);
      else
        call E.error(context, MOTLLE_ERROR_BAD_TYPE);
***************
*** 39,42 ****
--- 42,47 ----
  	call S.qpush(context, call T.make_int(ix));
        }
+     else if (call T.intp(x))
+       call S.qpush(context, x);
      else
        call E.error(context, MOTLLE_ERROR_BAD_TYPE);
***************
*** 56,59 ****
--- 61,66 ----
  	call S.qpush(context, call T.make_int(ix));
        }
+     else if (call T.intp(x))
+       call S.qpush(context, x);
      else
        call E.error(context, MOTLLE_ERROR_BAD_TYPE);
***************
*** 76,79 ****
--- 83,95 ----
    }
  
+   //FN real?: x -> b. TRUE if x is a number
+   command result_t RealP.execute(uint8_t instr, MateContext* context) {
+     return call NumberP.execute(instr, context);
+   }
+ 
+   command uint8_t RealP.byteLength() {
+     return 1;
+   }
+ 
    //FN float?: x -> b. TRUE if x is a float
    command result_t FloatP.execute(uint8_t instr, MateContext* context) {

Index: FNseqM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/mate/runtime/FNseqM.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** FNseqM.nc	23 Oct 2005 22:11:05 -0000	1.2
--- FNseqM.nc	23 Oct 2005 22:37:09 -0000	1.3
***************
*** 15,18 ****
--- 15,19 ----
      interface MotlleTypes as T;
      interface MateError as E;
+     interface MotlleValues as V;
    }
  }



More information about the Tinyos-commits mailing list