1 /******************************************************************************** 2 * 3 * Copyright (C) 2008 Fujitsu Services Ltd. 4 * 5 * Author: Nick Battle 6 * 7 * This file is part of VDMJ. 8 * 9 * VDMJ is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation, either version 3 of the License, or 12 * (at your option) any later version. 13 * 14 * VDMJ is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with VDMJ. If not, see <http://www.gnu.org/licenses/>. 21 * 22 ******************************************************************************/ 23 24 package org.overturetool.vdmj.statements; 25 26 import java.io.Serializable; 27 28 import org.overturetool.vdmj.lex.LexLocation; 29 import org.overturetool.vdmj.runtime.Context; 30 import org.overturetool.vdmj.runtime.ContextException; 31 import org.overturetool.vdmj.runtime.ValueException; 32 import org.overturetool.vdmj.typechecker.Environment; 33 import org.overturetool.vdmj.typechecker.TypeChecker; 34 import org.overturetool.vdmj.types.Type; 35 import org.overturetool.vdmj.types.TypeList; 36 import org.overturetool.vdmj.values.Value; 37 38 /*** 39 * A class to hold an object assignment designator. 40 */ 41 42 public abstract class ObjectDesignator implements Serializable 43 { 44 private static final long serialVersionUID = 1L; 45 46 public final LexLocation location; 47 48 public ObjectDesignator(LexLocation location) 49 { 50 this.location = location; 51 } 52 53 @Override 54 abstract public String toString(); 55 56 abstract public Type typeCheck(Environment env, TypeList qualifiers); 57 58 abstract public Value eval(Context ctxt); 59 60 public Value abort(int number, String msg, Context ctxt) 61 { 62 throw new ContextException(number, msg, location, ctxt); 63 } 64 65 public Value abort(ValueException ve) 66 { 67 throw new ContextException(ve, location); 68 } 69 70 public void report(int number, String msg) 71 { 72 TypeChecker.report(number, msg, location); 73 } 74 75 public void concern(boolean serious, int number, String msg) 76 { 77 if (serious) 78 { 79 TypeChecker.report(number, msg, location); 80 } 81 else 82 { 83 TypeChecker.warning(number, msg, location); 84 } 85 } 86 87 public void detail(String tag, Object obj) 88 { 89 TypeChecker.detail(tag, obj); 90 } 91 92 public void detail(boolean serious, String tag, Object obj) 93 { 94 if (serious) 95 { 96 TypeChecker.detail(tag, obj); 97 } 98 } 99 100 public void detail2(String tag1, Object obj1, String tag2, Object obj2) 101 { 102 TypeChecker.detail2(tag1, obj1, tag2, obj2); 103 } 104 105 public void detail2( 106 boolean serious, String tag1, Object obj1, String tag2, Object obj2) 107 { 108 if (serious) 109 { 110 TypeChecker.detail2(tag1, obj1, tag2, obj2); 111 } 112 } 113 }