public override Expression VisitRefLocal([NotNull] LogicScriptParser.RefLocalContext context) { if (Context.IsInConstant) { Context.Errors.AddError("You can only reference constants from other constants", context.Span(), true); } var @ref = new ReferenceVisitor(Context).Visit(context); return(new ReferenceExpression(context.Span(), @ref)); }
public override Statement VisitAssignTruncate([NotNull] LogicScriptParser.AssignTruncateContext context) { var @ref = new ReferenceVisitor(Context).Visit(context.reference()); if ([email protected]) { Context.Errors.AddError("The left hand side of an assignment must be writable", context.reference().Span()); } var value = new ExpressionVisitor(Context).Visit(context.expression()); return(new AssignStatement(context.Span(), @ref, value, @ref.BitSize)); }
public override Expression VisitRefPort([NotNull] LogicScriptParser.RefPortContext context) { if (Context.Outer.Constants.TryGetValue(context.GetText(), out var val)) { return(val); } if (Context.IsInConstant) { Context.Errors.AddError("You can only reference constants from other constants", context.Span(), true); } var @ref = new ReferenceVisitor(Context).Visit(context); if ([email protected]) { Context.Errors.AddError("An identifier in an expression must be readable", context.Span()); } return(new ReferenceExpression(context.Span(), @ref)); }