Code Monkey home page Code Monkey logo

vut-ifj's People

Contributors

jkalend avatar otysuvenyr avatar xstrei06 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

vut-ifj's Issues

static analysis

<?php
declare(strict_types=1);
$i = 0;
while($i < 3) {
  if ($i > 0) {
    write($z);
  } else {}
  $z = "Hello, world";
  $i = $i + 1;
}

this code doesn't as expected as of now due to the $z variable

empty function arguments not causing error

<?php declare(strict_types=1);
$a = "a";
$b = 49;
ord(,,,,, $a,, );
chr(,,,,, $b);
write(,,,,"Hello World",,);
strlen(,,,,, "Hello World",,);

According to PHP, this should cause an error, but it does not.

Space is being ignored

<?php
declare(strict_types=1);
$a = "hello ";
$b = "world";
$c = $a . $b;

output of this should be: hello world
instead it is: helloworld

Readi Readf Reads can return null

read functions can return null on bad input, as of now they are considered as return certain types only, not counting null

possible solutions:

  • change type to VOID for all read functions

Freeing of memory

As of now there are many pointers that are just handed over and freeing those is a little complicated
putting IDs in one array and so on would make this process much easier

codegen builtins

  • reads
  • readi
  • readf
  • strlen
  • substring
  • ord
  • chr
  • floatval
  • intval
  • strval
  • write

Failing test due to undefined variable

<?php
declare(strict_types=1);
$x;

as of now, this is being done only by codegen, but here it passes with no issue at all.
we need to implement checking variables and functions at the end of the parser.

add type checking of function parameters

<?php
declare(strict_types=1);
$a = 49;
$b = 48.0;
function func(int $a, int $b) : string
{
    return chr($a) . chr($b);
}

$c = func($a, $b);
write($c);

this should cause an error but as of now it does not

function and variable identifiers

<?php
declare(strict_types=1);
$a = 2;
function a (int $a) : ?int {
    if ($a > 2) {
        $a = $a + 2;
    } else {
        $a = $a - 2;
    }
    return $a;
}

$a = a($a);
?>

can a function and a variable within the same scope share the same identifier?

Recursive calls unsupported

<?php
declare(strict_types=1);
function f(int $x) : int {
    if($x === 0) {
        return 0;
    } else {
        $inp = $x - 1;
        $res = g($inp);
        return $res + $x;
    }
}
function g(int $x) : int {
    $res = f($x);
    return $res + 1;
}
$res = g(10);
write($res, "\n");

for these examples and variables in while loop we will need some sort of speculative execution.

What is meant by that is:

  • all variable and function IDs will be stored in an array
  • after the entire loop or function is checked, then the IDs will be checked one by one if they are or aren't defined
  • for functions more global approach will be need and their IDs will be checked only after reaching "main"

checking for undefined variables in parser

tests like this:

<?php
declare(strict_types=1);
write($x);

require checking for the definition of a variable in parser, which is currently not being properly done

for each htab we need to check whether their type is D_NONE or not and in case it is, immediately exit with code 5

also for purposes of memory freeing we can't lose the local htabs, which can, unfortunately, happen as of now.

=== in expression

<?php
declare(strict_types=1);
$i = 0;
while($i === 3) {
  if ($i > 0) {
    write($i);
  } else {}
  $z = "Hello, world";
  $i = $i + 1;
}

precedential does not accept ===

Invalid return code

<?php
declare(strict_types=1);
return 0;

should return 0, instead it causes parser to exit with error code 4

SIGSEGV

<?php
declare(strict_types=1);
$a = (5 === 5);
write($a);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.