Code Monkey home page Code Monkey logo

sslc's People

Contributors

jansimek avatar novarain avatar phobos2077 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

jansimek abryzak

sslc's Issues

Using same name for procedure and its argument leads to wrong code

procedure stuff(variable stuff, variable in_recursion := 0)
begin
  if not(in_recursion) then
   stuff := stuff(stuff, 1);
  else
  begin
     display_msg("doing critical stuff");
     stuff++;
     return stuff;
  end
end

procedure start begin call stuff(0); end

According to int2sll it compiles to

procedure stuff(variable arg0, variable arg1);
procedure start;

procedure stuff(variable arg0, variable arg1)
begin
    if (not(arg1)) then begin
        arg0 := arg0(arg0, 1); // wait what...
    end
    else begin
        display_msg("doing critical stuff");
        arg0 := arg0 + 1;
        return arg0;
    end
end

procedure start
begin
    call stuff(0, 0);
end

get_array syntax is broken for exported variables

export variable wtf;

procedure start begin
   variable k := "a";
   wtf := temp_array(-1, 0);
   wtf[k] := 1;
   display_msg(wtf[k]);
end

This gives error "')' expected after args list". The same syntax with a normal variable works.

Compile error when foreach is followed by if statement

procedure start begin
  variable k;
  foreach k in list_as_array(0)
    if (k) then arr2[k] := v;
end

This gives error:

:5:16: 'else' expected.

If you add parentheses around foreach header block, replace list_as_array with a symbol or remove if, the error is gone. This is wrong behavior.

Disallow merging variable name with keywords

procedure proc(variable &end)
begin&end++;
  if&end>10then&end=-1; return &end;
end

All vars should follow same syntax rules; having a way to have very unique var name is real nice (for example when global scope variable is defined deep down in header), fact that it introduces own subset of syntax rules is not :/

Disallowing merging constants with keywords would be nice too~

Optimization: string literal used to call procedures gets deleted

With -O2 option, given code:

procedure my_proc begin
   display_msg("my_proc called");
end

procedure start begin
   variable n;
   variable procName;
   call my_proc;
   n := dude_obj;
   procName := "my_"+"proc"+n;
   call procName;
end

Round-trips to this:

procedure my_proc;
procedure start;


procedure my_proc begin
  display_msg("my_proc called");
end

procedure start begin
  variable LVar0 := 0;
  variable LVar1 := 0;
  call my_proc();
  LVar0 := dude_obj;
  call LVar1();
end

It should correctly count calling a variable as usage and prevent it from removal. Since variable itself isn't removed, it looks like an error in constant expression optimizations. This doesn't happen if you pass this variable to an opcode, like debug_msg.

Unused argument in a procedure gets removed by optimization, breaking logic

procedure test(variable a, variable b) begin
   return b * 2;
end

procedure start begin
   display_msg(test(1,2));
end

Round trips to:

procedure test(variable arg0, variable arg1);
procedure start;


procedure test(variable arg0, variable arg1) begin
  return arg0 * 2;
end

procedure start begin
  display_msg(test(1, 2));
end

The generated code uses arg0 instead of arg1, thus breaking the logic of the function. This only happens with "full" optimization.

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.