diff --git a/ravicomp/include/ravi_api.h b/ravicomp/include/ravi_api.h index f542c59..4c916e2 100644 --- a/ravicomp/include/ravi_api.h +++ b/ravicomp/include/ravi_api.h @@ -1,3 +1,25 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ #ifndef ravicomp_RAVIAPI_H #define ravicomp_RAVIAPI_H diff --git a/ravicomp/include/ravi_compiler.h b/ravicomp/include/ravi_compiler.h index 1485942..1cd31e4 100644 --- a/ravicomp/include/ravi_compiler.h +++ b/ravicomp/include/ravi_compiler.h @@ -1,10 +1,30 @@ +/****************************************************************************** + * Copyright (C) 2018-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ /* A compiler for Ravi and Lua 5.3. This is work in progress. Once ready it will be used to create a JIT compiler for Ravi. This header file defines the public api - -Copyright 2018-2020 Dibyendu Majumdar */ #ifndef ravicomp_COMPILER_H diff --git a/ravicomp/src/allocate.c b/ravicomp/src/allocate.c index c96b461..324ec1c 100644 --- a/ravicomp/src/allocate.c +++ b/ravicomp/src/allocate.c @@ -32,7 +32,7 @@ */ /* * This version is part of the Ravi Compiler project. - * Copyright (C) 2017-2020 Dibyendu Majumdar + * Copyright (C) 2017-2021 Dibyendu Majumdar */ #include diff --git a/ravicomp/src/allocate.h b/ravicomp/src/allocate.h index 3d9da88..c2e77f2 100644 --- a/ravicomp/src/allocate.h +++ b/ravicomp/src/allocate.h @@ -34,8 +34,10 @@ * small bits and pieces of it with no maintenance overhead. */ /* - * Portions Copyright (C) 2017-2020 Dibyendu Majumdar + * Portions Copyright (C) 2017-2021 Dibyendu Majumdar */ +#ifndef ravicomp_ALLOCATE_H +#define ravicomp_ALLOCATE_H #include #include @@ -127,4 +129,6 @@ extern size_t raviX_del_array_element(void *p, size_t element_size, size_t array } #endif +#endif + #endif \ No newline at end of file diff --git a/ravicomp/src/ast_printer.c b/ravicomp/src/ast_printer.c index 1b9c8e2..53d88c7 100644 --- a/ravicomp/src/ast_printer.c +++ b/ravicomp/src/ast_printer.c @@ -1,7 +1,25 @@ -/* -Copyright (C) 2018-2020 Dibyendu Majumdar -*/ - +/****************************************************************************** + * Copyright (C) 2018-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ #include const char *raviX_get_type_name(ravitype_t tt) diff --git a/ravicomp/src/ast_simplify.c b/ravicomp/src/ast_simplify.c index e3fe75d..5c40680 100644 --- a/ravicomp/src/ast_simplify.c +++ b/ravicomp/src/ast_simplify.c @@ -1,5 +1,27 @@ -/* Replace constant expressions with constants, and simply any other expressions if possible */ +/****************************************************************************** + * Copyright (C) 2018-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ /* Portions Copyright (C) 1994-2019 Lua.org, PUC-Rio.*/ +/* Replace constant expressions with constants, and simply any other expressions if possible */ #include diff --git a/ravicomp/src/ast_walker.c b/ravicomp/src/ast_walker.c index c143080..1fc1a86 100644 --- a/ravicomp/src/ast_walker.c +++ b/ravicomp/src/ast_walker.c @@ -1,3 +1,25 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ #include #include diff --git a/ravicomp/src/bitset.c b/ravicomp/src/bitset.c index 11c49a9..8d4196c 100644 --- a/ravicomp/src/bitset.c +++ b/ravicomp/src/bitset.c @@ -1,6 +1,29 @@ /* This file is a part of MIR project. Copyright (C) 2018-2020 Vladimir Makarov . */ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + /* * Adapted for Ravi Compiler project */ diff --git a/ravicomp/src/bitset.h b/ravicomp/src/bitset.h index 01ee10b..c8de8bd 100644 --- a/ravicomp/src/bitset.h +++ b/ravicomp/src/bitset.h @@ -1,6 +1,29 @@ /* This file is a part of MIR project. Copyright (C) 2018-2020 Vladimir Makarov . */ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + /* * Adapted for Ravi Compiler project */ diff --git a/ravicomp/src/cfg.c b/ravicomp/src/cfg.c index e06c13a..98e4833 100644 --- a/ravicomp/src/cfg.c +++ b/ravicomp/src/cfg.c @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + /* Build CFG */ diff --git a/ravicomp/src/cfg.h b/ravicomp/src/cfg.h index e93d478..3e47f21 100644 --- a/ravicomp/src/cfg.h +++ b/ravicomp/src/cfg.h @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #ifndef ravicomp_CFG_H #define ravicomp_CFG_H diff --git a/ravicomp/src/codegen.c b/ravicomp/src/codegen.c index 12d3c12..4acf87d 100644 --- a/ravicomp/src/codegen.c +++ b/ravicomp/src/codegen.c @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + /* * Convert the linear IR to C code that can be compiled and * executed by Ravi VM. diff --git a/ravicomp/src/codegen.h b/ravicomp/src/codegen.h index 7dc14e9..ceb9051 100644 --- a/ravicomp/src/codegen.h +++ b/ravicomp/src/codegen.h @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #ifndef ravicomp_CODEGEN_H #define ravicomp_CODEGEN_H diff --git a/ravicomp/src/common.h b/ravicomp/src/common.h index 48be199..68c4035 100644 --- a/ravicomp/src/common.h +++ b/ravicomp/src/common.h @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #ifndef ravicomp_COMMON_H #define ravicomp_COMMON_H diff --git a/ravicomp/src/dataflow_framework.c b/ravicomp/src/dataflow_framework.c index 8d5f229..3e1bdf4 100644 --- a/ravicomp/src/dataflow_framework.c +++ b/ravicomp/src/dataflow_framework.c @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + /** * A framework for performing data flow analysis. * The framework is based upon similar framework in MIR project (https://github.com/vnmakarov/mir) diff --git a/ravicomp/src/dataflow_framework.h b/ravicomp/src/dataflow_framework.h index 7e77ccf..81e7ef6 100644 --- a/ravicomp/src/dataflow_framework.h +++ b/ravicomp/src/dataflow_framework.h @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #ifndef ravicomp_DATAFLOW_FRAMEWORK_H #define ravicomp_DATAFLOW_FRAMEWORK_H diff --git a/ravicomp/src/df_liveness.c b/ravicomp/src/df_liveness.c index 687e04e..97c51fe 100644 --- a/ravicomp/src/df_liveness.c +++ b/ravicomp/src/df_liveness.c @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + /* * Calculate variable liveness * This will use the Dataflow Framework. diff --git a/ravicomp/src/dominator.c b/ravicomp/src/dominator.c index 7748dfd..83a8273 100644 --- a/ravicomp/src/dominator.c +++ b/ravicomp/src/dominator.c @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #include "dominator.h" #include "ravi_compiler.h" diff --git a/ravicomp/src/dominator.h b/ravicomp/src/dominator.h index 3d6b880..48dc3f8 100644 --- a/ravicomp/src/dominator.h +++ b/ravicomp/src/dominator.h @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #ifndef ravicomp_DOMINATOR_H #define ravicomp_DOMINATOR_H diff --git a/ravicomp/src/graph.c b/ravicomp/src/graph.c index dca5b93..6de7531 100644 --- a/ravicomp/src/graph.c +++ b/ravicomp/src/graph.c @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #include "graph.h" #include diff --git a/ravicomp/src/graph.h b/ravicomp/src/graph.h index 26ca9ae..6b6d2a2 100644 --- a/ravicomp/src/graph.h +++ b/ravicomp/src/graph.h @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #ifndef ravicomp_GRAPH_H #define ravicomp_GRAPH_H diff --git a/ravicomp/src/lexer.c b/ravicomp/src/lexer.c index 7d41f71..b0a7373 100644 --- a/ravicomp/src/lexer.c +++ b/ravicomp/src/lexer.c @@ -1,3 +1,25 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ /** * The lexer is basically a hacked version of Lua 5.3 lexer. * Copyright (C) 1994-2019 Lua.org, PUC-Rio. diff --git a/ravicomp/src/linearizer.c b/ravicomp/src/linearizer.c index 4b09ee1..45134df 100644 --- a/ravicomp/src/linearizer.c +++ b/ravicomp/src/linearizer.c @@ -1,6 +1,27 @@ -/* -Copyright (C) 2018-2020 Dibyendu Majumdar +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ +/* This file contains the Linearizer. The goal of the Linearizer is generate a linear intermediate representation (IR) from the AST suitable for further analysis. diff --git a/ravicomp/src/linearizer.h b/ravicomp/src/linearizer.h index ee357f6..ad8165e 100644 --- a/ravicomp/src/linearizer.h +++ b/ravicomp/src/linearizer.h @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #ifndef ravicomp_LINEARIZER_H #define ravicomp_LINEARIZER_H diff --git a/ravicomp/src/membuf.c b/ravicomp/src/membuf.c index b159ba7..01dfa2d 100644 --- a/ravicomp/src/membuf.c +++ b/ravicomp/src/membuf.c @@ -1,6 +1,25 @@ -/* -Copyright (C) 2018-2020 Dibyendu Majumdar -*/ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ #include "membuf.h" diff --git a/ravicomp/src/membuf.h b/ravicomp/src/membuf.h index d1abf8b..33332e7 100644 --- a/ravicomp/src/membuf.h +++ b/ravicomp/src/membuf.h @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #ifndef ravicomp_MEMBUF_H #define ravicomp_MEMBUF_H diff --git a/ravicomp/src/opt_unusedcode.c b/ravicomp/src/opt_unusedcode.c index 43f304a..c5d68f2 100644 --- a/ravicomp/src/opt_unusedcode.c +++ b/ravicomp/src/opt_unusedcode.c @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + /* A pass over linearized code to eliminate unused code. * Initially only tackle unreachable basic blocks */ diff --git a/ravicomp/src/optimizer.h b/ravicomp/src/optimizer.h index 7cf9314..2d4d8fc 100644 --- a/ravicomp/src/optimizer.h +++ b/ravicomp/src/optimizer.h @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #ifndef ravicomp_OPTIMIZER_H #define ravicomp_OPTIMIZER_H diff --git a/ravicomp/src/parser.c b/ravicomp/src/parser.c index 33a5c12..9bc7cfe 100644 --- a/ravicomp/src/parser.c +++ b/ravicomp/src/parser.c @@ -1,3 +1,27 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ +/* Portions Copyright (C) 1994-2019 Lua.org, PUC-Rio.*/ + /* A parser and syntax tree builder for Ravi. Note that the overall structure of the parser is loosely based on the Lua 5.3 parser. @@ -6,10 +30,7 @@ The parser retains the syntactic structure - including constant expressions and syntax nodes because these are useful for testing and understanding. A later pass simplifies the AST - see ast_simplify.c - -Copyright (C) 2018-2020 Dibyendu Majumdar */ -/* Portions Copyright (C) 1994-2019 Lua.org, PUC-Rio.*/ #include "fnv_hash.h" #include diff --git a/ravicomp/src/parser.h b/ravicomp/src/parser.h index e5e6b97..29196b7 100644 --- a/ravicomp/src/parser.h +++ b/ravicomp/src/parser.h @@ -1,5 +1,29 @@ -#ifndef ravicomp_IMPLEMENTATION_H -#define ravicomp_IMPLEMENTATION_H +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ +/* Portions Copyright (C) 1994-2019 Lua.org, PUC-Rio.*/ + +#ifndef ravicomp_PARSER_H +#define ravicomp_PARSER_H /* * Internal header file for the implementation. diff --git a/ravicomp/src/ptrlist.c b/ravicomp/src/ptrlist.c index 32862ab..1f1c57f 100644 --- a/ravicomp/src/ptrlist.c +++ b/ravicomp/src/ptrlist.c @@ -7,7 +7,7 @@ */ /* * This version is part of the dmr_c project. - * Copyright (C) 2017 Dibyendu Majumdar + * Copyright (C) 2017-2021 Dibyendu Majumdar */ #define PARANOIA 1 diff --git a/ravicomp/src/ptrlist.h b/ravicomp/src/ptrlist.h index 242d7b4..f48f0e2 100644 --- a/ravicomp/src/ptrlist.h +++ b/ravicomp/src/ptrlist.h @@ -1,15 +1,15 @@ -#ifndef ravicomp_PTRLIST_H -#define ravicomp_PTRLIST_H - /* -* Generic pointer list manipulation code. -* -* (C) Copyright Linus Torvalds 2003-2005 -*/ + * Generic pointer list manipulation code. + * + * (C) Copyright Linus Torvalds 2003-2005 + */ /* -* This version is part of the dmr_c project. -* Copyright (C) 2017 Dibyendu Majumdar -*/ + * This version is part of the dmr_c project. + * Copyright (C) 2017-2021 Dibyendu Majumdar + */ + +#ifndef ravicomp_PTRLIST_H +#define ravicomp_PTRLIST_H #include @@ -20,25 +20,24 @@ extern "C" { #endif - /* -* The ptrlist data structure is copied from the Linux Sparse project. -* It is essentially a dynamic array of pointers but the array is split up -* into nodes that are linked together. Each node contains a small number of array entries. -* -* The ptr list data structure is like a train - with cars linked to each other. -* Just as in a train each car has many seats, so in ptr list each "node" has -* several entries. Unlike a train however, the ptr list is arranged as a ring, -* i.e. the the front and back nodes are linked to each other. Hence there is no -* such thing as a 'head' of the list - i.e. any node can be the head! -* -* The disadvantage of the ptrlist structure compared to a dynamic array is -* that it consumes more memory to maintain the linked list data structure. -* -* The main advantage is that it is well suited to fixed sized memory -* allocators as there is no resizing of memory already allocated, which happens -* with dynamic arrays. The ptrlist is made up of fixed size nodes. -*/ + * The ptrlist data structure is copied from the Linux Sparse project. + * It is essentially a dynamic array of pointers but the array is split up + * into nodes that are linked together. Each node contains a small number of array entries. + * + * The ptr list data structure is like a train - with cars linked to each other. + * Just as in a train each car has many seats, so in ptr list each "node" has + * several entries. Unlike a train however, the ptr list is arranged as a ring, + * i.e. the the front and back nodes are linked to each other. Hence there is no + * such thing as a 'head' of the list - i.e. any node can be the head! + * + * The disadvantage of the ptrlist structure compared to a dynamic array is + * that it consumes more memory to maintain the linked list data structure. + * + * The main advantage is that it is well suited to fixed sized memory + * allocators as there is no resizing of memory already allocated, which happens + * with dynamic arrays. The ptrlist is made up of fixed size nodes. + */ /* number of array entries per node */ #ifndef LIST_NODE_NR @@ -46,14 +45,14 @@ extern "C" { #endif /* structure of a node */ -#define DECLARE_PTR_LIST(listname, type) \ - typedef struct listname { \ - int nr_ : 8; \ - int rm_ : 8; \ - struct listname *prev_; \ - struct listname *next_; \ - Allocator *allocator_; \ - type *list_[LIST_NODE_NR]; \ +#define DECLARE_PTR_LIST(listname, type) \ + typedef struct listname { \ + int nr_ : 8; \ + int rm_ : 8; \ + struct listname *prev_; \ + struct listname *next_; \ + Allocator *allocator_; \ + type *list_[LIST_NODE_NR]; \ } listname /* Each node in the list */ @@ -77,13 +76,11 @@ extern void raviX_ptrlist_split_node(struct ptr_list *head); extern void raviX_ptrlist_pack(struct ptr_list **self); extern void raviX_ptrlist_remove_all(struct ptr_list **self); extern int raviX_ptrlist_remove(struct ptr_list **self, void *entry, int count); -extern int raviX_ptrlist_replace(struct ptr_list **self, void *old_ptr, void *new_ptr, - int count); +extern int raviX_ptrlist_replace(struct ptr_list **self, void *old_ptr, void *new_ptr, int count); extern void *raviX_ptrlist_undo_last(struct ptr_list **self); extern void *raviX_ptrlist_delete_last(struct ptr_list **self); extern void raviX_ptrlist_concat(struct ptr_list *a, struct ptr_list **self); -extern void raviX_ptrlist_sort(struct ptr_list **self, void *, - int (*cmp)(void *, const void *, const void *)); +extern void raviX_ptrlist_sort(struct ptr_list **self, void *, int (*cmp)(void *, const void *, const void *)); /* iterator functions */ extern PtrListIterator raviX_ptrlist_forward_iterator(struct ptr_list *self); @@ -96,54 +93,50 @@ extern void raviX_ptrlist_iter_remove(PtrListIterator *self); extern void raviX_ptrlist_iter_set(PtrListIterator *self, void *ptr); extern void raviX_ptrlist_iter_mark_deleted(PtrListIterator *self); -static inline void **raviX_ptrlist_iter_this_address(PtrListIterator *self) { - return &self->__list->list_[self->__nr]; -} +static inline void **raviX_ptrlist_iter_this_address(PtrListIterator *self) { return &self->__list->list_[self->__nr]; } #define ptr_list_empty(x) ((x) == NULL) -#define PTR_ENTRY_NOTAG(h,i) ((h)->list_[i]) -#define PTR_ENTRY(h,i) (void *)(PTR_ENTRY_NOTAG(h,i)) - -#define FOR_EACH_PTR(list, var) \ - { PtrListIterator var##iter__ = raviX_ptrlist_forward_iterator((struct ptr_list *)list); \ - for (var = raviX_ptrlist_iter_next(&var##iter__); var != NULL; var = raviX_ptrlist_iter_next(&var##iter__)) +#define PTR_ENTRY_NOTAG(h, i) ((h)->list_[i]) +#define PTR_ENTRY(h, i) (void *)(PTR_ENTRY_NOTAG(h, i)) + +#define FOR_EACH_PTR(list, var) \ + { \ + PtrListIterator var##iter__ = raviX_ptrlist_forward_iterator((struct ptr_list *)list); \ + for (var = raviX_ptrlist_iter_next(&var##iter__); var != NULL; \ + var = raviX_ptrlist_iter_next(&var##iter__)) #define END_FOR_EACH_PTR(var) } -#define FOR_EACH_PTR_REVERSE(list, var) \ - { PtrListIterator var##iter__ = raviX_ptrlist_reverse_iterator((struct ptr_list *)list); \ - for (var = raviX_ptrlist_iter_prev(&var##iter__); var != NULL; var = raviX_ptrlist_iter_prev(&var##iter__)) +#define FOR_EACH_PTR_REVERSE(list, var) \ + { \ + PtrListIterator var##iter__ = raviX_ptrlist_reverse_iterator((struct ptr_list *)list); \ + for (var = raviX_ptrlist_iter_prev(&var##iter__); var != NULL; \ + var = raviX_ptrlist_iter_prev(&var##iter__)) #define END_FOR_EACH_PTR_REVERSE(var) } -#define RECURSE_PTR_REVERSE(list, var) \ - { PtrListIterator var##iter__ = list##iter__; \ - for (var = raviX_ptrlist_iter_prev(&var##iter__); var != NULL; var = raviX_ptrlist_iter_prev(&var##iter__)) +#define RECURSE_PTR_REVERSE(list, var) \ + { \ + PtrListIterator var##iter__ = list##iter__; \ + for (var = raviX_ptrlist_iter_prev(&var##iter__); var != NULL; \ + var = raviX_ptrlist_iter_prev(&var##iter__)) -#define PREPARE_PTR_LIST(list, var) \ - PtrListIterator var##iter__ = raviX_ptrlist_forward_iterator((struct ptr_list *)list); \ +#define PREPARE_PTR_LIST(list, var) \ + PtrListIterator var##iter__ = raviX_ptrlist_forward_iterator((struct ptr_list *)list); \ var = raviX_ptrlist_iter_next(&var##iter__) -#define NEXT_PTR_LIST(var) \ - var = raviX_ptrlist_iter_next(&var##iter__) -#define FINISH_PTR_LIST(var) - -#define THIS_ADDRESS(type, var) \ - (type *)raviX_ptrlist_iter_this_address(&var##iter__) +#define NEXT_PTR_LIST(var) var = raviX_ptrlist_iter_next(&var##iter__) +#define FINISH_PTR_LIST(var) -#define DELETE_CURRENT_PTR(var) \ - raviX_ptrlist_iter_remove(&var##iter__) +#define THIS_ADDRESS(type, var) (type *)raviX_ptrlist_iter_this_address(&var##iter__) -#define REPLACE_CURRENT_PTR(type, var, replacement) \ - raviX_ptrlist_iter_set(&var##iter__, replacement) +#define DELETE_CURRENT_PTR(var) raviX_ptrlist_iter_remove(&var##iter__) -#define INSERT_CURRENT(newval, var) \ - raviX_ptrlist_iter_insert(&var##iter__, newval) +#define REPLACE_CURRENT_PTR(type, var, replacement) raviX_ptrlist_iter_set(&var##iter__, replacement) -#define MARK_CURRENT_DELETED(PTR_TYPE, var) \ - raviX_ptrlist_iter_mark_deleted(&var##iter__) +#define INSERT_CURRENT(newval, var) raviX_ptrlist_iter_insert(&var##iter__, newval) +#define MARK_CURRENT_DELETED(PTR_TYPE, var) raviX_ptrlist_iter_mark_deleted(&var##iter__) #ifdef __cplusplus } #endif - #endif diff --git a/ravicomp/src/ravi_binding.c b/ravicomp/src/ravi_binding.c index 4e3752d..f5d6bd2 100644 --- a/ravicomp/src/ravi_binding.c +++ b/ravicomp/src/ravi_binding.c @@ -1,3 +1,26 @@ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + /* This will contain Lua bindings */ #include "ravi_api.h" diff --git a/ravicomp/src/typechecker.c b/ravicomp/src/typechecker.c index d926695..1875e9d 100644 --- a/ravicomp/src/typechecker.c +++ b/ravicomp/src/typechecker.c @@ -1,6 +1,26 @@ -/* -Copyright (C) 2018-2020 Dibyendu Majumdar -*/ +/****************************************************************************** + * Copyright (C) 2020-2021 Dibyendu Majumdar + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ******************************************************************************/ + #include /* @@ -17,7 +37,6 @@ d) Any unassigned local vars that have type info must be set to valid initial va None of these operations are explicit in the AST. */ - static bool is_type_same(const VariableType *a, const VariableType *b) { // String comparion of type_name relies upon strings being interned @@ -98,8 +117,7 @@ static void typecheck_unary_operator(CompilerState *container, AstNode *function } /* Type checker - WIP */ -static void typecheck_binary_operator(CompilerState *container, AstNode *function, - AstNode *node) +static void typecheck_binary_operator(CompilerState *container, AstNode *function, AstNode *node) { BinaryOperatorType op = node->binary_expr.binary_op; AstNode *e1 = node->binary_expr.expr_left; @@ -260,8 +278,7 @@ static void typecheck_var_assignment(CompilerState *container, VariableType *var } } -static void typecheck_local_statement(CompilerState *container, AstNode *function, - AstNode *node) +static void typecheck_local_statement(CompilerState *container, AstNode *function, AstNode *node) { // The local vars should already be annotated // We need to typecheck the expressions to the right of = @@ -317,15 +334,13 @@ static void typecheck_expr_statement(CompilerState *container, AstNode *function } } -static void typecheck_for_in_statment(CompilerState *container, AstNode *function, - AstNode *node) +static void typecheck_for_in_statment(CompilerState *container, AstNode *function, AstNode *node) { typecheck_ast_list(container, function, node->for_stmt.expr_list); typecheck_ast_list(container, function, node->for_stmt.for_statement_list); } -static void typecheck_for_num_statment(CompilerState *container, AstNode *function, - AstNode *node) +static void typecheck_for_num_statment(CompilerState *container, AstNode *function, AstNode *node) { typecheck_ast_list(container, function, node->for_stmt.expr_list); AstNode *expr; @@ -381,8 +396,7 @@ static void typecheck_if_statement(CompilerState *container, AstNode *function, } } -static void typecheck_while_or_repeat_statement(CompilerState *container, AstNode *function, - AstNode *node) +static void typecheck_while_or_repeat_statement(CompilerState *container, AstNode *function, AstNode *node) { typecheck_ast_node(container, function, node->while_or_repeat_stmt.condition); if (node->while_or_repeat_stmt.loop_statement_list) { @@ -459,8 +473,7 @@ static void typecheck_ast_node(CompilerState *container, AstNode *function, AstN /* symbol type should have been set when symbol was created */ if (node->symbol_expr.var->symbol_type != SYM_LABEL) { copy_type(&node->symbol_expr.type, &node->symbol_expr.var->variable.value_type); - } - else { + } else { // TODO can this happen? node->symbol_expr.type.type_code = RAVI_TANY; } @@ -491,7 +504,8 @@ static void typecheck_ast_node(CompilerState *container, AstNode *function, AstN typecheck_ast_node(container, function, node->table_elem_assign_expr.key_expr); } typecheck_ast_node(container, function, node->table_elem_assign_expr.value_expr); - copy_type(&node->table_elem_assign_expr.type, &node->table_elem_assign_expr.value_expr->common_expr.type); + copy_type(&node->table_elem_assign_expr.type, + &node->table_elem_assign_expr.value_expr->common_expr.type); break; } case EXPR_TABLE_LITERAL: {