object Expr.Visitor <object> .VisitAssignExpr(Expr.Assign expr) { Object value = Evaluate(expr.value); environment.Assign(expr.name, value); return(value); }
public Unit VisitAssignExpr(Expr.Assign expr) { Resolve(expr.Value); ResolveLocal(expr, expr.Name); return(new Unit()); }
public object VisitAssignExpr(Expr.Assign expr) { object value = Evaluate(expr.Value); environment.Assign(expr.Name, value); return(value); }
public object visitAssign(Expr.Assign assign) { object value = evaluate(assign.Value); environment.assign(assign.Name, value); return(value); }
public VoidObject VisitAssignExpr(Expr.Assign expr) { Resolve(expr.Value); ResolveLocalOrGlobal(expr, expr.Name); return(VoidObject.Void); }
public object VisitAssignExpr(Expr.Assign expr) { Resolve(expr.value); ResolveLocal(expr, expr.name, false); return(null); }
public override VoidObject VisitAssignExpr(Expr.Assign expr) { base.VisitAssignExpr(expr); Binding variableBinding = GetVariableOrFunctionCallback(expr); if (variableBinding == null) { // An attempt is made to assign a value to an undefined variable. This is an error, but it's handled // elsewhere so we can silently ignore it at this point. return(VoidObject.Void); } if (variableBinding is FunctionBinding) { // Functions are immutable, handled by a class in the Perlang.Interpreter.Immutability namespace. We can // ignore it at this point; the attempt to reassign it will be detected elsewhere. return(VoidObject.Void); } var targetTypeReference = variableBinding.TypeReference; var sourceTypeReference = expr.Value.TypeReference; long?sourceConstantValueSize = null; if (expr.Value is Expr.Literal { Value : INumericLiteral parsedNumber })
public override VoidObject VisitAssignExpr(Expr.Assign expr) { base.VisitAssignExpr(expr); // Letting the type be inferred in an assignment expression is important to make constructs like // "var i = 100; var j = i+= 2;" work correctly. This is indeed an odd way of writing code, but as long // as += is an expression and not a statement, we need to have predictable semantics for cases like // this. if (!expr.TypeReference.IsResolved && expr.Value.TypeReference.IsResolved) { expr.TypeReference.ClrType = expr.Value.TypeReference.ClrType; } return(VoidObject.Void); }
public object VisitAssignExpr(Expr.Assign expr) { object value = Evaluate(expr.Value); int distance; if (Locals.TryGetValue(expr, out distance)) { Environment.AssignAt(distance, expr.Name, value); } else { Globals.Assign(expr.Name, value); } return(value); }
public object VisitAssignExpr(Expr.Assign expr) { var value = Evaluate(expr.value); var valuePresent = _locals.TryGetValue(expr, out var distance); if (valuePresent) { _environment.AssignAt(distance, expr.name, value); } else { Globals.Assign(expr.name, value); } return(value); }
public object visitAssignExpr(Expr.Assign expr) { object value = evaluate(expr.value); int distance; if (locals.ContainsKey(expr)) { distance = locals[expr]; environment.assignAt(distance, expr.name, value); } else { globals.assign(expr.name, value); } return(value); }
public object Visit(Expr.Assign expr) { object value = Evaluate(expr.value); int?distance = _locals.Get(expr); if (distance != null) { _environment.AssignAt(distance.Value, expr.Name, value); } else { _globals.Assign(expr.Name, value); } return(value); }
public override VoidObject VisitAssignExpr(Expr.Assign expr) { base.VisitAssignExpr(expr); Binding?binding = getVariableOrFunctionBinding(expr); // 'null' here can either be because of an internal error (failure to locate a binding that _should_ exist), // or a completely valid case when trying to reassign an undefined variable. Regretfully, we cannot // distinguish between these two scenarios at the moment. if (binding?.IsImmutable == true) { immutabilityValidationErrorCallback(new ImmutabilityValidationError( expr.Name, $"{binding.ObjectTypeTitleized} '{expr.Name.Lexeme}' is immutable and cannot be modified." )); } return(VoidObject.Void); }
public string VisitAssignExpr(Expr.Assign expr) { return($"{expr.Name.Lexeme} = {PrintExpr(expr.Value)}"); }
public string VisitAssignExpr(Expr.Assign expr) { return(Parenthesize(expr.Name.Lexeme, expr.Value)); }
public TypeSpecifier VisitAssignmentExpression(Expr.Assign exp) { if (exp.Var is Expr.Variable exprname) { var name = exprname.Name.Source; var variable = _namedValues[name]; var type = Visit(exp.Value); var value = _valueStack.Pop(); var casted = CheckedCast(value, type, variable.KtsType); var store = LLVM.BuildStore(_builder, casted, variable.Value); _valueStack.Push(store); if (variable.Binding != null) { HandleBinding(variable, false); } return(variable.KtsType); } else if (exp.Var is Expr.IndexAccess exprindex) { var name = exprindex.Identifier.Source; var variable = _namedValues[name]; var vartype = new TypeSpecifier { Dimensions = 0, Type = variable.KtsType.Type }; if (variable.IsDecayed) { LLVMValueRef[] indices = new LLVMValueRef[exprindex.Expressions.Count]; for (int i = 0; i < indices.Length; i++) { var indexType = Visit(exprindex.Expressions[i]); var indexVal = _valueStack.Pop(); var integerIndex = CheckedCast(indexVal, indexType, new TypeSpecifier { Dimensions = 0, Type = TypeEnum.I64 }); indices[i] = integerIndex; } var load = LLVM.BuildLoad(_builder, variable.Value, ""); var address = LLVM.BuildInBoundsGEP(_builder, load, indices, ""); var exprType = Visit(exp.Value); var exprVal = _valueStack.Pop(); var casted = CheckedCast(exprVal, exprType, vartype); LLVMValueRef store = LLVM.BuildStore(_builder, casted, address); _valueStack.Push(store); return(vartype); } else { LLVMValueRef[] indices = new LLVMValueRef[exprindex.Expressions.Count + 1]; indices[0] = LLVM.ConstInt(LLVM.Int64Type(), 0, _lFalse); for (int i = 1; i < indices.Length; i++) { var indexType = Visit(exprindex.Expressions[i - 1]); var indexVal = _valueStack.Pop(); var integerIndex = CheckedCast(indexVal, indexType, new TypeSpecifier { Dimensions = 0, Type = TypeEnum.I64 }); indices[i] = integerIndex; } var address = LLVM.BuildInBoundsGEP(_builder, variable.Value, indices, ""); var exprType = Visit(exp.Value); var exprVal = _valueStack.Pop(); var casted = CheckedCast(exprVal, exprType, vartype); LLVMValueRef store = LLVM.BuildStore(_builder, casted, address); _valueStack.Push(store); if (variable.Binding != null) { HandleBinding(variable, false); } return(vartype); } } else { throw new Exception("Should be either index access or primitive assignment"); } }
public string VisitAssignExpr(Expr.Assign expr) { return(Printer(expr.Name.Lexeme, expr.Value)); }
public string visitAssignExpr(Expr.Assign expr) { throw new NotImplementedException(); }
public object VisitAssignExpr(Expr.Assign expr, object options = null) { return(null); }
public T VisitAssignmentExpression(Expr.Assign exp);
public string VisitAssignExpr(Expr.Assign expr) { throw new System.NotImplementedException(); }
public object VisitAssignExpr(Expr.Assign expr, object options) { return(Parenthesize2("=", expr.token.lexeme, expr.value)); }
public object visitAssignExpr(Expr.Assign expr) { captureToken(expr.name); setNamedVariable(expr.name, expr.value); return(null); }
public object visitAssignExpr(Expr.Assign expr) { resolve(expr.value); resolveLocal(expr, expr.name); return(null); }
public string visitAssign(Expr.Assign assign) { throw new System.NotImplementedException(); }
public string VisitAssignExpr(Expr.Assign expr) { return(Parenthesize("=", expr.value)); }
public object VisitAssignExpr(Expr.Assign expr) { Resolve(expr.Value); ResolveLocal(expr, expr.Name); return(null); }