001/* 002 * Copyright (c) 2012-2017 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 */ 009 010package org.eclipse.golo.compiler.ir; 011 012public final class NamedArgument extends ExpressionStatement { 013 014 private String name; 015 private ExpressionStatement expression; 016 017 NamedArgument(String name) { 018 super(); 019 this.name = name; 020 } 021 022 public String getName() { 023 return name; 024 } 025 026 public ExpressionStatement getExpression() { 027 return expression; 028 } 029 030 public NamedArgument value(Object value) { 031 expression = (ExpressionStatement) value; 032 makeParentOf(expression); 033 return this; 034 } 035 036 @Override 037 public void accept(GoloIrVisitor visitor) { 038 visitor.visitNamedArgument(this); 039 } 040 041 @Override 042 public void walk(GoloIrVisitor visitor) { 043 expression.accept(visitor); 044 } 045 046 @Override 047 protected void replaceElement(GoloElement original, GoloElement newElement) { 048 if (expression != original) { 049 throw doesNotContain(original); 050 } 051 value((ExpressionStatement) newElement); 052 } 053}