Gidsss / UwUIDE

A compiler made to be cute uwu >~<
6 stars 0 forks source link

method calls are now transpiled with self, declaration member checking checks value first before id #298

Closed am-cid closed 3 months ago

am-cid commented 3 months ago

changes

  1. gwobaw a-chan = a used to compile, now not anymore. check value first before member checking id
  2. fn calls are differentiated from method calls. fn calls are now transpiled to have self. if it is a method call

note: changes may look a lot but that's because most of them are refactors (no functionality change). the above two are the only functionality changes

etc

  1. use Signature class to make refactoring and type checking in TypeChecker easier
    • this is where bulk of the lines changed are. this has no functionality change

      test log for differentiating fn from method calls

      eg: source

      
      cwass Divide() [[
      fwunc halved-kun(x-chan) [[
      wetuwn(x / 2)~ 
      ]]
      fwunc quartered-kun(x-chan) [[
      pwint(test())~
      wetuwn((halved(x) / 4))~ 
      ]]
      ]]

fwunc test-chan() [[ wetuwn(0)~ ]]

#### transpiled
- before:
```python
class _Divide:
    def __repr__(self):
        return f"{self.__class__.__name__[1:]}({', '.join(f'{key[1:]}={value}' for key, value in self.__dict__.items())})"
    def __str__(self):
        return f"{self.__class__.__name__[1:]}({', '.join(f'{key[1:]}={value}' for key, value in self.__dict__.items())})"
    def _halved(self, _x: Int):
        _x: Int = Int(_x)
        return (_x / Int(2))

    def _quartered(self, _x: Int):
        _x: Int = Int(_x)
        print(_test())
        return (_halved(_x) / Int(4))

def _test():
    return (Int(0))

_notice that _halved() does not have self_

def _test(): return (Int(0))


_take note that in `_quartered()`, `_test()` has no self but `_havled()` has_
am-cid commented 3 months ago

current bug: all fn calls in classes are assumed to be method calls without checking

am-cid commented 3 months ago

fixed now, check #300 for more info. summary provided in description of this pr