-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
161 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef __BOOL_TEST_H__ | ||
#define __BOOL_TEST_H__ | ||
|
||
#include <stdbool.h> | ||
|
||
typedef struct { | ||
bool a:1; | ||
bool b; | ||
} bool_test_args; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include "BoolTest.h" | ||
|
||
interface BoolTest { | ||
command bool unary(const bool a); | ||
event void unaryDone(bool result, bool arg); | ||
command void binary(const bool_test_args args); | ||
event void binaryDone(bool result, bool_test_args args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "BoolTest.h" | ||
|
||
generic module BoolTestM(bool val) { | ||
provides interface BoolTest; | ||
} implementation { | ||
command bool BoolTest.unary(const bool a) { | ||
const bool result = val ? a : !a; | ||
signal BoolTest.unaryDone(result, a); | ||
return result; | ||
} | ||
|
||
command void BoolTest.binary(const bool_test_args args) { | ||
const bool result = val ? args.a | args.b | ||
: args.a ^ args.b; | ||
signal BoolTest.binaryDone(result, args); | ||
} | ||
|
||
default event void BoolTest.unaryDone(bool result, bool arg) { | ||
} | ||
|
||
default event void BoolTest.binaryDone(bool result, bool_test_args args) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#include <stdio.h> | ||
|
||
#include "BoolTest.h" | ||
|
||
module TestP { | ||
uses interface BoolTest as Test1; | ||
uses interface BoolTest as Test2; | ||
} implementation { | ||
event void Test1.unaryDone(bool result, bool arg) { | ||
printf("Test1.unary(%d) -> %d\n", arg, result); | ||
} | ||
|
||
event void Test1.binaryDone(bool result, bool_test_args args) { | ||
printf("Test1.binary(%d, %d) -> %d\n", args.a, args.b, result); | ||
} | ||
|
||
event void Test2.unaryDone(bool result, bool arg) { | ||
printf("Test2.unary(%d) -> %d\n", arg, result); | ||
} | ||
|
||
event void Test2.binaryDone(bool result, bool_test_args args) { | ||
printf("Test2.binary(%d, %d) -> %d\n", args.a, args.b, result); | ||
} | ||
|
||
int main() @C() @spontaneous() { | ||
bool_test_args args; | ||
bool r1, r2; | ||
|
||
r1 = call Test1.unary(false); | ||
r2 = call Test1.unary(true); | ||
if (r1 == r2) | ||
printf("Test1.unary operation fails\n"); | ||
args.a = args.b = false; | ||
call Test1.binary(args); | ||
args.b = true; | ||
call Test1.binary(args); | ||
args.a = true; args.b = false; | ||
call Test1.binary(args); | ||
args.a = args.b = true; | ||
call Test1.binary(args); | ||
|
||
r1 = call Test2.unary(false); | ||
r2 = call Test2.unary(true); | ||
if (r1 == r2) | ||
printf("Test2.unary operation fails\n"); | ||
args.a = args.b = false; | ||
call Test2.binary(args); | ||
args.b = true; | ||
call Test2.binary(args); | ||
args.a = true; args.b = false; | ||
call Test2.binary(args); | ||
args.a = args.b = true; | ||
call Test2.binary(args); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "BoolTest.h" | ||
|
||
configuration test { | ||
} implementation { | ||
components TestP; | ||
components new BoolTestM(1 == 1 && 0 < 1) as Test1; | ||
components new BoolTestM(0 == 1 || 0 > 1) as Test2; | ||
|
||
TestP.Test1 -> Test1; | ||
TestP.Test2 -> Test2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
keep= | ||
if [ -z "$NESC1" ]; then | ||
NESC1=../../../src/nesc1 | ||
keep=1 | ||
fi | ||
cd $1 | ||
cfile=/tmp/c99c11.$$.c | ||
exe=/tmp/c99c11.out.$$ | ||
$NESC1 -fnesc-separator=__ test.nc -o $cfile && \ | ||
gcc -Wall -g -o $exe $cfile && \ | ||
$exe | ||
ok=$? | ||
if [ -z "$keep" ]; then | ||
rm -f $cfile $exe | ||
else | ||
echo C file is $cfile, executable is $exe | ||
fi | ||
exit $ok |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Test1.unary(0) -> 0 | ||
Test1.unary(1) -> 1 | ||
Test1.binary(0, 0) -> 0 | ||
Test1.binary(0, 1) -> 1 | ||
Test1.binary(1, 0) -> 1 | ||
Test1.binary(1, 1) -> 1 | ||
Test2.unary(0) -> 1 | ||
Test2.unary(1) -> 0 | ||
Test2.binary(0, 0) -> 0 | ||
Test2.binary(0, 1) -> 1 | ||
Test2.binary(1, 0) -> 1 | ||
Test2.binary(1, 1) -> 0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ enum rid | |
RID_LONG, | ||
RID_SIGNED, | ||
RID_COMPLEX, | ||
RID_BOOL, | ||
RID_LASTTYPE, | ||
|
||
RID_INLINE = RID_LASTTYPE, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters