Skip to content

Implement str and bool runtime functions - #152

Merged
namannimmo10 merged 16 commits into
lcompilers:mainfrom
namannimmo10:builtin2
Feb 24, 2022
Merged

Implement str and bool runtime functions#152
namannimmo10 merged 16 commits into
lcompilers:mainfrom
namannimmo10:builtin2

Conversation

@namannimmo10

Copy link
Copy Markdown
Collaborator

Inspiration: #1 (comment)

@namannimmo10

Copy link
Copy Markdown
CollaboratorAuthor

We should do something about this line:

throwCodeGenError("Unsupported len value in ASR");

Nonetheless, the ASR looks good to me.

@certik

Copy link
Copy Markdown
Contributor

Is this an intrinsic function? I don't see it here: https://docs.python.org/3/library/functions.html

Also it's time to refactor this whole function into LFortran's style. Let's not put anymore functions here until we refactor, as it is unmaintainable longterm. Let me know if you know how to do the refactor.

@namannimmo10

Copy link
Copy Markdown
CollaboratorAuthor

Is this an intrinsic function?

No. We will add a generic function, str() down the road, but right now I'm trying to make str_int and str_float work.

I have two ideas for doing that:

  1. Using decorators...
  2. Using type guard:
>>>defstr(val: i32|f64):
... # "isinstance" type guard
... ifisinstance(val, i32):
... # type of `val` is narrowed to `i32`
... returnstr_int(val)
... elifisinstance(val, f64):
... # else, type of `val` is narrowed to `f64`
... returnstr_float(val)
...
>>>

You are talking about this file, right?

@certikcertik mentioned this pull request Feb 21, 2022
@namannimmo10namannimmo10 changed the title Implement str_int functionImplement str runtime functionFeb 24, 2022
@namannimmo10

Copy link
Copy Markdown
CollaboratorAuthor

Once we merge this, I will add the rest.

@certikcertik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this looks great!

@certikcertik changed the title Implement str runtime functionImplement bool runtime functionFeb 24, 2022
@namannimmo10namannimmo10 changed the title Implement bool runtime functionImplement str and bool runtime functionsFeb 24, 2022
@namannimmo10
namannimmo10 merged commit 7fea711 into lcompilers:mainFeb 24, 2022
@namannimmo10
namannimmo10 deleted the builtin2 branch February 24, 2022 18:09
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@namannimmo10@certik