Time derivative of user defined class makes compiler crash
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Freeode |
In Progress
|
High
|
Eike |
Bug Description
Here is a little program that makes the compiler crash with an internal error. It involves assigning to the time derivative of a user defined class. The error happens in the code generator.
I can't spontaneously understand the error to fix it, so I file a bug.
This is the program that crashes the compiler. When the alternative, commented out, code is used, the program compiles.
-------
------
class Vec2:
class Vec2:
data x: Float role_unknown
data x: Float role_unknown
data y: Float role_unknown
data y: Float role_unknown
func __assign__(this, other):
x = other.x
x = other.x
y = other.y
y = other.y
func __diff__(this):
data res: Vec2
data res: Vec2
return res
return res
data vg: Vec2
vg.x = 0
vg.x = 0
vg.y = -9.81
vg.y = -9.81
class Throw:
data v: Vec2
data v: Vec2
func dynamic(this):
#$v.x = 0 #This code
#$v.x = 0 #This code
#$v.y = -9.81 #works
#$v.y = -9.81 #works
$v = vg #This code crashes the compiler
$v = vg #This code crashes the compiler
compile Throw
-------
------
summary: |
- Time terivative of user defined class makes compiler crash + Time derivative of user defined class makes compiler crash |
tags: | added: interpreter |
Changed in freeode: | |
milestone: | none → 0.4.2 |
Changed in freeode: | |
assignee: | nobody → Eike (eike-welk) |
status: | Confirmed → In Progress |
description: | updated |
Possible algorithm for derived variables of user defined class:
Instance must have an attribute:
data _dt: Pointer
Function to return/create differential:
func __diff__(self):
associate_ state_diff( self.x, m.x)
if self._dt.is_set():
return self._dt.get()
else:
data m: MyClass
self._dt = m
return m