Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/16 using definition #21

Merged
merged 5 commits into from
Dec 24, 2017
Merged
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
31 changes: 31 additions & 0 deletions test/definition/using/binary_type_alias.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//

CASM init foo

using uint16_t = Binary'16

rule foo =
let x : uint16_t = 0b1010'1111'1111'1110 in
skip
31 changes: 31 additions & 0 deletions test/definition/using/boolean_type_alias.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//

CASM init foo

using MyType = Boolean

rule foo =
let x : MyType = true in
skip
37 changes: 37 additions & 0 deletions test/definition/using/enumeration_type_alias.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//

CASM init foo

enumeration Color = {
Red,
Green,
Blue
}

using MyType = Color

rule foo =
let x : MyType = ::Red in
skip
39 changes: 39 additions & 0 deletions test/definition/using/error/enumerator_alias.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//

// type check pass should say that the enumerator 'Color::Red' cannot be used
// as a type

CASM init foo

enumeration Color = {
Red,
Green,
Blue
}

using MyType = Color::Red //@ ERROR( 0100 )

rule foo =
skip
33 changes: 33 additions & 0 deletions test/definition/using/error/redefinition.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//

// symbol registration should say that symbol 'MyType' is already defined

CASM init foo

using MyType = Boolean //@ ERROR( 0502 )
using MyType = Integer //@ ERROR( 0502 )

rule foo =
skip
32 changes: 32 additions & 0 deletions test/definition/using/error/using_unknown_type.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//

// type check pass should say that the type 'UnknownType' is unknown

CASM init foo

using MyType = UnknownType //@ ERROR( 0100 )

rule foo =
skip
34 changes: 34 additions & 0 deletions test/definition/using/function_reference_type_alias.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//

CASM init foo

using MyFuncRef = FuncRef< Integer * Integer -> Integer >

derived d( a : Integer, b : Integer ) -> Integer =
a + b

rule foo =
let x : MyFuncRef = @d in
skip
33 changes: 33 additions & 0 deletions test/definition/using/type_alias_in_type_alias.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//

CASM init foo

using MyType1 = Boolean
using MyType2 = MyType1

function test : MyType1 -> MyType2

rule foo =
skip
44 changes: 44 additions & 0 deletions test/definition/using/use_type_alias_as_universe.casm
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// Copyright (c) 2014-2017 CASM Organization
// All rights reserved.
//
// Developed by: Philipp Paulweber
// Emmanuel Pescosta
// https://github.com/casm-lang/libcasm-tc
//
// This file is part of libcasm-tc.
//
// libcasm-tc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libcasm-tc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with libcasm-tc. If not, see <http://www.gnu.org/licenses/>.
//

CASM init foo

enumeration State = {
On,
Off
}

using MyState = State

function visitedStates : MyState -> Boolean

rule foo =
{|
forall s in MyState do
visitedStates( s ) := true

assert( visitedStates( ::On ) and visitedStates( ::Off ) )

program( self ) := undef
|}