public void VisitDivide(DMASTDivide divide) { var lhs = DMExpression.Create(_dmObject, _proc, divide.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, divide.B, _inferredPath); Result = new Expressions.Divide(divide.Location, lhs, rhs); }
public void VisitIn(DMASTExpressionIn expressionIn) { var expr = DMExpression.Create(_dmObject, _proc, expressionIn.Value, _inferredPath); var container = DMExpression.Create(_dmObject, _proc, expressionIn.List, _inferredPath); Result = new Expressions.In(expressionIn.Location, expr, container); }
public void ProcessStatementForRange(DMASTProcStatementForRange statementForRange) { DMExpression.Emit(_dmObject, _proc, statementForRange.RangeStart); DMExpression.Emit(_dmObject, _proc, statementForRange.RangeEnd); DMExpression.Emit(_dmObject, _proc, statementForRange.Step); _proc.CreateRangeEnumerator(); _proc.StartScope(); { if (statementForRange.Initializer != null) { ProcessStatement(statementForRange.Initializer); } string loopLabel = _proc.NewLabelName(); _proc.LoopStart(loopLabel); { DMExpression outputVariable = DMExpression.Create(_dmObject, _proc, statementForRange.Variable); (DMReference outputRef, _) = outputVariable.EmitReference(_dmObject, _proc); _proc.Enumerate(outputRef); _proc.BreakIfFalse(); ProcessBlockInner(statementForRange.Body); _proc.LoopContinue(loopLabel); _proc.LoopJumpToStart(loopLabel); } _proc.LoopEnd(); } _proc.EndScope(); _proc.DestroyEnumerator(); }
public void VisitListIndex(DMASTListIndex listIndex) { var expr = DMExpression.Create(_dmObject, _proc, listIndex.Expression, _inferredPath); var index = DMExpression.Create(_dmObject, _proc, listIndex.Index, expr.Path); Result = new Expressions.ListIndex(listIndex.Location, expr, index, expr.Path, listIndex.Conditional); }
public void VisitNewDereference(DMASTNewDereference newDereference) { var expr = DMExpression.Create(_dmObject, _proc, newDereference.Dereference, _inferredPath); var args = new ArgumentList(newDereference.Location, _dmObject, _proc, newDereference.Parameters, _inferredPath); Result = new Expressions.New(newDereference.Location, expr, args); }
public void VisitGreaterThanOrEqual(DMASTGreaterThanOrEqual greaterThanOrEqual) { var lhs = DMExpression.Create(_dmObject, _proc, greaterThanOrEqual.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, greaterThanOrEqual.B, _inferredPath); Result = new Expressions.GreaterThanOrEqual(greaterThanOrEqual.Location, lhs, rhs); }
public void VisitOr(DMASTOr or) { var lhs = DMExpression.Create(_dmObject, _proc, or.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, or.B, _inferredPath); Result = new Expressions.Or(or.Location, lhs, rhs); }
public void VisitLogicalOrAssign(DMASTLogicalOrAssign lor) { var lhs = DMExpression.Create(_dmObject, _proc, lor.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, lor.B, _inferredPath); Result = new Expressions.LogicalOrAssign(lor.Location, lhs, rhs); }
public void VisitDivideAssign(DMASTDivideAssign divideAssign) { var lhs = DMExpression.Create(_dmObject, _proc, divideAssign.A); var rhs = DMExpression.Create(_dmObject, _proc, divideAssign.B); Result = new Expressions.DivideAssign(divideAssign.Location, lhs, rhs); }
public void VisitRemove(DMASTRemove remove) { var lhs = DMExpression.Create(_dmObject, _proc, remove.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, remove.B, _inferredPath); Result = new Expressions.Remove(remove.Location, lhs, rhs); }
public void VisitMask(DMASTMask mask) { var lhs = DMExpression.Create(_dmObject, _proc, mask.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, mask.B, _inferredPath); Result = new Expressions.Mask(mask.Location, lhs, rhs); }
public void VisitCombine(DMASTCombine combine) { var lhs = DMExpression.Create(_dmObject, _proc, combine.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, combine.B, _inferredPath); Result = new Expressions.Combine(combine.Location, lhs, rhs); }
public void VisitPower(DMASTPower power) { var lhs = DMExpression.Create(_dmObject, _proc, power.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, power.B, _inferredPath); Result = new Expressions.Power(power.Location, lhs, rhs); }
public void VisitModulus(DMASTModulus modulus) { var lhs = DMExpression.Create(_dmObject, _proc, modulus.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, modulus.B, _inferredPath); Result = new Expressions.Modulo(modulus.Location, lhs, rhs); }
public void VisitEqual(DMASTEqual equal) { var lhs = DMExpression.Create(_dmObject, _proc, equal.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, equal.B, _inferredPath); Result = new Expressions.Equal(equal.Location, lhs, rhs); }
public void VisitLeftShiftAssign(DMASTLeftShiftAssign leftShiftAssign) { var lhs = DMExpression.Create(_dmObject, _proc, leftShiftAssign.A); var rhs = DMExpression.Create(_dmObject, _proc, leftShiftAssign.B); Result = new Expressions.LeftShiftAssign(leftShiftAssign.Location, lhs, rhs); }
public void VisitNotEquivalent(DMASTNotEquivalent notEquivalent) { var lhs = DMExpression.Create(_dmObject, _proc, notEquivalent.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, notEquivalent.B, _inferredPath); Result = new Expressions.NotEquivalent(notEquivalent.Location, lhs, rhs); }
public void VisitRightShiftAssign(DMASTRightShiftAssign rightShiftAssign) { var lhs = DMExpression.Create(_dmObject, _proc, rightShiftAssign.A); var rhs = DMExpression.Create(_dmObject, _proc, rightShiftAssign.B); Result = new Expressions.RightShiftAssign(rightShiftAssign.Location, lhs, rhs); }
public void VisitLessThanOrEqual(DMASTLessThanOrEqual lessThanOrEqual) { var lhs = DMExpression.Create(_dmObject, _proc, lessThanOrEqual.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, lessThanOrEqual.B, _inferredPath); Result = new Expressions.LessThanOrEqual(lessThanOrEqual.Location, lhs, rhs); }
public void VisitXorAssign(DMASTXorAssign xorAssign) { var lhs = DMExpression.Create(_dmObject, _proc, xorAssign.A); var rhs = DMExpression.Create(_dmObject, _proc, xorAssign.B); Result = new Expressions.XorAssign(xorAssign.Location, lhs, rhs); }
public void VisitAnd(DMASTAnd and) { var lhs = DMExpression.Create(_dmObject, _proc, and.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, and.B, _inferredPath); Result = new Expressions.And(and.Location, lhs, rhs); }
public void VisitModulusAssign(DMASTModulusAssign modulusAssign) { var lhs = DMExpression.Create(_dmObject, _proc, modulusAssign.A); var rhs = DMExpression.Create(_dmObject, _proc, modulusAssign.B); Result = new Expressions.ModulusAssign(modulusAssign.Location, lhs, rhs); }
public void VisitNewIdentifier(DMASTNewIdentifier newIdentifier) { var expr = DMExpression.Create(_dmObject, _proc, newIdentifier.Identifier, _inferredPath); var args = new ArgumentList(newIdentifier.Location, _dmObject, _proc, newIdentifier.Parameters, _inferredPath); Result = new Expressions.New(newIdentifier.Location, expr, args); }
public void VisitLeftShift(DMASTLeftShift leftShift) { var lhs = DMExpression.Create(_dmObject, _proc, leftShift.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, leftShift.B, _inferredPath); Result = new Expressions.LeftShift(leftShift.Location, lhs, rhs); }
public void VisitIsType(DMASTIsType isType) { var expr = DMExpression.Create(_dmObject, _proc, isType.Value, _inferredPath); var path = DMExpression.Create(_dmObject, _proc, isType.Type, _inferredPath); Result = new Expressions.IsType(isType.Location, expr, path); }
public void VisitRightShift(DMASTRightShift rightShift) { var lhs = DMExpression.Create(_dmObject, _proc, rightShift.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, rightShift.B, _inferredPath); Result = new Expressions.RightShift(rightShift.Location, lhs, rhs); }
public void VisitCall(DMASTCall call) { var procArgs = new ArgumentList(call.Location, _dmObject, _proc, call.ProcParameters, _inferredPath); switch (call.CallParameters.Length) { case 1: { var a = DMExpression.Create(_dmObject, _proc, call.CallParameters[0].Value, _inferredPath); Result = new Expressions.CallStatement(call.Location, a, procArgs); } break; case 2: { var a = DMExpression.Create(_dmObject, _proc, call.CallParameters[0].Value, _inferredPath); var b = DMExpression.Create(_dmObject, _proc, call.CallParameters[1].Value, _inferredPath); Result = new Expressions.CallStatement(call.Location, a, b, procArgs); } break; default: throw new CompileErrorException(call.Location, "invalid argument count for call()"); } }
public void VisitBinaryOr(DMASTBinaryOr binaryOr) { var lhs = DMExpression.Create(_dmObject, _proc, binaryOr.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, binaryOr.B, _inferredPath); Result = new Expressions.BinaryOr(binaryOr.Location, lhs, rhs); }
private void SetVariableValue(DMVariable variable, DMASTExpression value, DMValueType valType = DMValueType.Anything) { DMVisitorExpression._scopeMode = variable.IsGlobal ? "static" : "normal"; DMExpression expression = DMExpression.Create(_currentObject, variable.IsGlobal ? DMObjectTree.GlobalInitProc : null, value, variable.Type); DMVisitorExpression._scopeMode = "normal"; expression.ValType = valType; if (expression.TryAsConstant(out var constant)) { variable.Value = constant; return; } if (variable.IsConst) { throw new CompileErrorException(value.Location, "Value of const var must be a constant"); } //Whether this should be initialized at runtime bool isValid = expression switch { //TODO: A better way of handling procs evaluated at compile time Expressions.ProcCall procCall => procCall.GetTargetProc(_currentObject).Proc?.Name switch { "rgb" => true, "generator" => true, "matrix" => true, "icon" => true, "file" => true, "sound" => true, _ => variable.IsGlobal },
public void VisitMultiply(DMASTMultiply multiply) { var lhs = DMExpression.Create(_dmObject, _proc, multiply.A, _inferredPath); var rhs = DMExpression.Create(_dmObject, _proc, multiply.B, _inferredPath); Result = new Expressions.Multiply(multiply.Location, lhs, rhs); }