Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identify different assignment cases #19

Open
7 tasks
Konrad1991 opened this issue Jul 8, 2024 · 0 comments
Open
7 tasks

Identify different assignment cases #19

Konrad1991 opened this issue Jul 8, 2024 · 0 comments

Comments

@Konrad1991
Copy link
Owner

Konrad1991 commented Jul 8, 2024

On left side: bool,int,double, Logical, Integer or Numeric

On right side: bool,int,double, Logical, Integer,Numeric or an expression.

  • Ignore self assignment e.g. a = a. Throw an error in R.
  • Define c code for a scalar on left side:
    vm -> scalarNum[idx] = ...
  • define c code for a Vector on left side:
    vm -> numerics[vecIdx] -> data[i] = ...
  • Check whether the variable to which the result get assigned is found on the rhs. In case it is found use the temp vectors I.e. the c code from the last bullet point. Otherwise define c code where the result of an expression is directly stored in the variable at lhs.
  • Throw error in R if expression is on left side.
  • Deduce types of expressions on rhs. Check each type of the variables directly involved in the calculation of the result. Thus, ignore for example variables passed to cmr or subsetting. Take the most flexible type which is found. Double > int> bool. If at least one double is found than the type of the expression is double. If no double but at least one integer is found than the type is integer. If only boils are found than the type is bool
  • Check types of lhs and rhs. Add required casts. Each element of the rhs directly involved in calculating the result which has a different type than the lhs has to be casted. Thus,for the term a = b*c[d] where a is of type Numeric, b is of type Integer, c is of type Numeric and d is of type Integer, b has to be casted but not d.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant