package Ġnet . as che ja . ro kk star . interpreter Ċ Ċ import Ġnet . as che ja . ro kk star . ast .* Ċ import Ġnet . as che ja . ro kk star . types ystem . Value Ċ import Ġnet . as che ja . ro kk star . types ystem . values .* Ċ Ċ internal Ġfun ĠR ock star VM . evaluate Boolean ( expression : ĠExpression ) Ġ= ĊĠĠĠ Ġthis . evaluate ( expression ). to Boolean () Ċ Ċ fun ĠR ock star VM . evaluate ( expression : ĠExpression ): ĠValue Ġ= Ġwhen Ġ( expression ) Ġ{ ĊĠĠĠ Ġis ĠValue Ġ-> Ġexpression ĊĠĠĠ Ġis ĠConstant Ġ-> Ġexpression . to Value () ĊĠĠĠ Ġis ĠVariable Lookup Ġ-> Ġthis . get Variable ( expression . identifier ) ĊĠĠĠ Ġis ĠBinary Operator Expression Ġ-> Ġthis . evaluate Binary Expression ( expression ) ĊĠĠĠ Ġis ĠUnary Operator Expression Ġ-> Ġthis . evaluate Unary Expression ( expression ) ĊĠĠĠ Ġis ĠFunction Call Expression Ġ-> Ġthis . run Function ( expression ) Ċ } Ċ Ċ fun ĠConstant . to Value (): ĠValue Ġ= Ġwhen Ġ( this ) Ġ{ ĊĠĠĠĠĠĠĠ Ġis ĠNull Constant Ġ-> ĠNull Value ĊĠĠĠĠĠĠĠ Ġis ĠUndefined Constant Ġ-> ĠUndefined Value ĊĠĠĠĠĠĠĠ Ġis ĠNumber Constant Ġ-> ĠNumber Value ( value ) ĊĠĠĠĠĠĠĠ Ġis ĠBoolean Constant Ġ-> ĠBoolean Value ( value ) ĊĠĠĠĠĠĠĠ Ġis ĠString Constant Ġ-> ĠString Value ( value ) ĊĠĠĠ Ġ} Ċ Ċ fun ĠR ock star VM . evaluate Binary Expression ( expression : ĠBinary Operator Expression ): ĠValue Ġ{ ĊĠĠĠ Ġval Ġleft Ġ= Ġevaluate ( expression . left ) ĊĠĠĠ Ġval Ġright Ġ= Ġevaluate ( expression . right ) ĊĠĠĠ Ġreturn Ġwhen Ġ( expression . operator ) Ġ{ ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . MULTI PLY Ġ-> Ġleft Ġ* Ġright ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . DI VID E Ġ-> Ġleft Ġ/ Ġright ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . ADD Ġ-> Ġleft Ġ+ Ġright ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . SUB TRACT Ġ-> Ġleft Ġ- Ġright ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . EQUAL S Ġ-> ĠBoolean Value ( left Ġ== Ġright ) ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . NOT _ EQUAL S Ġ-> ĠBoolean Value ( left Ġ!= Ġright ) ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . GRE ATER Ġ-> ĠBoolean Value ( left Ġ> Ġright ) ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . LESS Ġ-> ĠBoolean Value ( left Ġ< Ġright ) ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . GRE ATER _ EQUAL S Ġ-> ĠBoolean Value ( left Ġ>= Ġright ) ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . LESS _ EQUAL S Ġ-> ĠBoolean Value ( left Ġ<= Ġright ) ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . AND Ġ-> ĠBoolean Value ( left . to Boolean () Ġ&& Ġright . to Boolean ()) ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . OR Ġ-> ĠBoolean Value ( left . to Boolean () Ġ|| Ġright . to Boolean ()) ĊĠĠĠĠĠĠĠ ĠBinary Operator Expression . Operator . NOR Ġ-> ĠBoolean Value (! left . to Boolean () Ġ&& Ġ! right . to Boolean ()) ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun ĠR ock star VM . evaluate Unary Expression ( expression : ĠUnary Operator Expression ): ĠValue Ġ{ ĊĠĠĠ Ġval Ġsubject Ġ= Ġexpression . expression ĊĠĠĠ Ġreturn Ġwhen Ġ( expression . operator ) Ġ{ ĊĠĠĠĠĠĠĠ ĠUnary Operator Expression . Operator . NOT Ġ-> Ġ! evaluate ( subject ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ