Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/scala/pipedsl/common/Errors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,9 @@ object Errors {
withPos(s"Not enough constraints provided to infer types. Found error at $e", e.pos)
)

case class ExtremelyCriticalExceptionFailure(msg :String, pos:Position) extends RuntimeException(
withPos(s"Extremely Critical Exception Failure at: $msg", pos)
)

case class IntWidthNotSpecified() extends RuntimeException
}
4 changes: 4 additions & 0 deletions src/main/scala/pipedsl/common/Syntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,10 @@ object Syntax {
case class EApp(func: Id, args: List[Expr]) extends Expr
case class ECall(mod: Id, method: Option[Id] = None, args: List[Expr]) extends Expr
case class EVar(id: Id) extends Expr
{
if(id.v == "input")
throw ExtremelyCriticalExceptionFailure("Do not under any circumstances even THINK about naming a variable input", id.pos)
}
case class ECast(ctyp: Type, exp: Expr) extends Expr
{
typ = Some(ctyp)
Expand Down
34 changes: 17 additions & 17 deletions src/test/tests/autocastTests/autocast-basic-pass.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def ass_cast_test() :int<32>
return c;
}

def tern_cast_test(input :bool) :int<32>
def tern_cast_test(inpt :bool) :int<32>
{
a = 10<10>;
b = 1<30>;
d = ((input) ? (a) : (b));
d = ((inpt) ? (a) : (b));
return d;
}

Expand Down Expand Up @@ -66,18 +66,18 @@ pipe output_cast()[] :int<32>



pipe recv_cast1(input :uint<32>)[rf :int<32>[32]<a,a>(Queue)]
pipe recv_cast1(inpt :uint<32>)[rf :int<32>[32]<a,a>(Queue)]
{
start(rf);
reserve(rf[input], W);
reserve(rf[inpt], W);
end(rf);
---
int<10> a = 4;
block(rf[input]);
rf[input] <- a;
block(rf[inpt]);
rf[inpt] <- a;
---
release(rf[input]);
call recv_cast1(input);
release(rf[inpt]);
call recv_cast1(inpt);
}

pipe recv_cast2()[]
Expand All @@ -87,26 +87,26 @@ pipe recv_cast2()[]
}


pipe test1(input: int<32>)[rf: int<32>[32]] {
a = input;
pipe test1(inpt: int<32>)[rf: int<32>[32]] {
a = inpt;
b = true;
c = b;
if (c) {
d = a + 5<32>;
}
call test1(input);
call test1(inpt);
}

pipe test2(input: int<32>)[rf: int<32>[32]] {
a = input;
pipe test2(inpt: int<32>)[rf: int<32>[32]] {
a = inpt;
b = true;
c = b;
if (c) {
d = a + 5<32>;
} else {
d = b;
}
call test2(input);
call test2(inpt);
}

pipe test3()[] {
Expand Down Expand Up @@ -157,16 +157,16 @@ pipe test5()[] {
}


pipe test6(input: int<32>)[rf: int<32>[32]] {
a = input;
pipe test6(inpt: int<32>)[rf: int<32>[32]] {
a = inpt;
b = true;
c = b;
if (c) {
d = a + 5<32>;
} else {
d = b;
}
call test6(input);
call test6(inpt);
}

pipe test7()[rf: uint<32>[32]<a,a>(Queue)] {
Expand Down
18 changes: 9 additions & 9 deletions src/test/tests/autocastTests/type-inference-basic-pass.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ def helper2(a:bool, b: bool): bool {
return c;
}

pipe test1(input: int<32>)[rf: int<32>[32]] {
a = input;
pipe test1(inpt: int<32>)[rf: int<32>[32]] {
a = inpt;
b = true;
c = b;
if (c) {
d = a + 5<32>;
}
call test1(input);
call test1(inpt);
}

pipe test2(input: int<32>)[rf: int<32>[32]] {
a = input;
pipe test2(inpt: int<32>)[rf: int<32>[32]] {
a = inpt;
b = true;
c = b;
if (c) {
d = a + 5<32>;
} else {
d = b;
}
call test2(input);
call test2(inpt);
}

pipe test3()[] {
Expand Down Expand Up @@ -83,16 +83,16 @@ pipe test5()[] {
}


pipe test6(input: int<32>)[rf: int<32>[32]] {
a = input;
pipe test6(inpt: int<32>)[rf: int<32>[32]] {
a = inpt;
b = true;
c = b;
if (c) {
d = a + 5<32>;
} else {
d = b;
}
call test6(input);
call test6(inpt);
}

pipe test7()[rf: uint<32>[32]<a,a>(Queue)] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ def helper2(a:bool, b: bool): bool {
return c;
}

pipe test1(input: int<32>)[rf: int<32>[32]] {
pipe test1(inpt: int<32>)[rf: int<32>[32]] {
a = 6 * 6<10>;
int<32> b = a;
int<32> c = a + b;
call test1(c);
}

pipe test2(input: int<32>)[rf: int<32>[32]<a,a>(Queue)] {
pipe test2(inpt: int<32>)[rf: int<32>[32]<a,a>(Queue)] {
a = 1;
start(rf);
reserve(rf[a]);
Expand All @@ -32,14 +32,14 @@ pipe test2(input: int<32>)[rf: int<32>[32]<a,a>(Queue)] {
call test2(b);
}

pipe test3(input: int<32>)[rf: int<32>[32]] {
pipe test3(inpt: int<32>)[rf: int<32>[32]] {
a = 1<32>;
int<32> b = a << 4;
c = a << 4;
call test3(c);
}

pipe test4(input: int<32>)[rf: int<32>[32]] {
pipe test4(inpt: int<32>)[rf: int<32>[32]] {
a = 15<32>;
int<32> b = cast(a{0:8}, int<32>);
call test4(a);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pipe test1(input: int<32>)[rf: int<32>[32]] {
a = input + 2<32>;
pipe test1(inpt: int<32>)[rf: int<32>[32]] {
a = inpt + 2<32>;
if (a) {

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

pipe test1(input: int<32>)[rf: int<32>[32]] {
a = input;
pipe test1(inpt: int<32>)[rf: int<32>[32]] {
a = inpt;
b = a || a;
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/tests/autocastTests/type-inference-fail-eqBinOp.pdl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pipe test1(input: int<32>)[rf: int<32>[32]] {
pipe test1(inpt: int<32>)[rf: int<32>[32]] {
a = true;
b = a == input;
b = a == inpt;
}

circuit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def func(a: bool, b: int<32>): bool {
return b;
}

pipe test1(input: int<32>)[rf: int<32>[32]] {
pipe test1(inpt: int<32>)[rf: int<32>[32]] {
a = true;
b = func(a, a);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/tests/autocastTests/type-inference-fail-funcApp.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ def func(a: bool, b: int<32>): bool {
return b;
}

pipe test1(input: int<32>)[rf: int<32>[32]] {
pipe test1(inpt: int<32>)[rf: int<32>[32]] {
a = true;
b = func(a, input) + 5<32>;
b = func(a, inpt) + 5<32>;
}

circuit {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pipe test1(input: int<32>)[rf: int<32>[32]] {
pipe test1(inpt: int<32>)[rf: int<32>[32]] {
a = true;
b = a + a;
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/tests/autocastTests/type-inference-fail-ternary.pdl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pipe test1(input: int<32>)[rf: int<32>[32]] {
pipe test1(inpt: int<32>)[rf: int<32>[32]] {
a = true;
b = input;
b = inpt;
c = (b) ? a : b;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pipe test3(input: uint<32>)[rf: int<32>[5]<c,s>] {
uint<5> rs1 = input{0:4};
uint<5> rs2 = input{5:9};
pipe test3(inpt: uint<32>)[rf: int<32>[5]<c,s>] {
uint<5> rs1 = inpt{0:4};
uint<5> rs2 = inpt{5:9};
start(rf);
acquire(rf[rs2], W);
end(rf);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pipe test3(input: uint<32>)[rf: int<32>[5]] {
uint<5> rs1 = input{0:4};
uint<5> rs2 = input{5:9};
pipe test3(inpt: uint<32>)[rf: int<32>[5]] {
uint<5> rs1 = inpt{0:4};
uint<5> rs2 = inpt{5:9};
start(rf);
acquire(rf[rs2], R);
end(rf);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pipe test3(input: uint<32>)[rf: int<32>[5]] {
uint<5> rs1 = input{0:4};
uint<5> rs2 = input{5:9};
pipe test3(inpt: uint<32>)[rf: int<32>[5]] {
uint<5> rs1 = inpt{0:4};
uint<5> rs2 = inpt{5:9};
start(rf);
acquire(rf[rs2], W);
end(rf);
Expand Down
6 changes: 3 additions & 3 deletions src/test/tests/typecheckTests/acquire-in-expr-fail.pdl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//Expected Fail
pipe test6(input: int<32>)[rf: int<32>[5]<c,s>] {
pipe test6(inpt: int<32>)[rf: int<32>[5]<c,s>] {
start(rf);
reserve(rf);
end(rf);
---
int<32> x = rf[u0<5>] + input;
int<32> x = rf[u0<5>] + inpt;
---
block(rf);
release(rf);
call test6(input);
call test6(inpt);
}

circuit {
Expand Down
6 changes: 3 additions & 3 deletions src/test/tests/typecheckTests/acquire-in-expr.pdl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//Expected Success
pipe test6(input: int<32>)[rf: int<32>[5]<c,s>(Queue)] {
pipe test6(inpt: int<32>)[rf: int<32>[5]<c,s>(Queue)] {
start(rf);
reserve(rf);
end(rf);
---
block(rf);
int<32> x = rf[u0<5>] + input;
int<32> x = rf[u0<5>] + inpt;
---
release(rf);
call test6(input);
call test6(inpt);
}

circuit {
Expand Down
14 changes: 7 additions & 7 deletions src/test/tests/typecheckTests/boolean-mishap.pdl
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
pipe mistake(input: int<32>)[rf: int<32>[5]<c, s>] {
bool a = input{0:0};
bool b = input{1:1};
pipe mistake(inpt: int<32>)[rf: int<32>[5]<c, s>] {
bool a = inpt{0:0};
bool b = inpt{1:1};
if(a && b)
{
call mistake(input);
call mistake(inpt);
}
---
if(a && !b)
{
call mistake(input);
call mistake(inpt);
}
---
if((!a) && b)
{
call mistake(input);
call mistake(inpt);
}
---
if(!(a && b))
{
call mistake(input);
call mistake(inpt);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/tests/typecheckTests/double-call-fail.pdl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//cannot call twice in same pipe
pipe call2(input: int<32>)[rf: int<32>[5]<c,s>] {
pipe call2(inpt: int<32>)[rf: int<32>[5]<c,s>] {
start(rf);
reserve(rf);
end(rf);
---
block(rf);
int<32> x = rf[0<5>] + input;
int<32> x = rf[0<5>] + inpt;
call call2(x);
---
int<32> y = rf[0<5>] + input;
int<32> y = rf[0<5>] + inpt;
call call2(y);
---
release(rf);
Expand Down
6 changes: 3 additions & 3 deletions src/test/tests/typecheckTests/double-call-guarded.pdl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pipe call_guard(input: int<32>)[rf: int<32>[5]<c, s>(Queue)] {
pipe call_guard(inpt: int<32>)[rf: int<32>[5]<c, s>(Queue)] {
start(rf);
reserve(rf);
end(rf);
---
block(rf);
int<32> x = rf[u0<5>] + input;
int<1> bit = input{0:0};
int<32> x = rf[u0<5>] + inpt;
int<1> bit = inpt{0:0};
if (bit == 1) {
call call_guard(x);
}
Expand Down
Loading