package com.pixelmaid.dresscode.antlr.types.tree.functions;
import com.pixelmaid.dresscode.antlr.types.VarType;
import com.pixelmaid.dresscode.antlr.types.tree.DCNode;
import com.pixelmaid.dresscode.antlr.types.tree.NodeEvent;
import com.pixelmaid.dresscode.antlr.types.tree.PropertyNode;
import com.pixelmaid.dresscode.drawing.primitive2d.Drawable;
public class GetRotationNode extends NodeEvent implements DCNode{
private DCNode expression;
public GetRotationNode(DCNode e) {
expression = e;
}
@Override
public VarType evaluate() {
VarType value = expression.evaluate();
if(!(value.isDrawable())){
throw new RuntimeException("Illegal rotation property access: " + this);
}
Drawable d = value.asDrawable();
Double r= d.getRotation();
return new VarType(r);
}
@Override
public String toString() {
return String.format("size(%s)", expression);
}
}