1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * ASSERTION: 29 * Test circular declaration of translations 30 * 31 * SECTION: Translators/ Translator Declarations 32 * SECTION: Translators/ Translate Operator 33 */ 34 35 #pragma D option quiet 36 37 struct input_struct { 38 int i; 39 char c; 40 }; 41 42 struct output_struct { 43 int myi; 44 char myc; 45 }; 46 47 translator struct output_struct < struct input_struct ivar > 48 { 49 myi = ((struct input_struct ) ivar).i; 50 myc = ((struct input_struct ) ivar).c; 51 }; 52 53 translator struct input_struct < struct output_struct uvar > 54 { 55 i = ((struct output_struct ) uvar).myi; 56 c = ((struct output_struct ) uvar).myc; 57 }; 58 59 struct input_struct f1; 60 struct output_struct f2; 61 62 BEGIN 63 { 64 f1.i = 10; 65 f1.c = 'c'; 66 67 f2.myi = 100; 68 f2.myc = 'd'; 69 70 printf("Testing circular translations\n"); 71 forwardi = xlate < struct output_struct > (f1).myi; 72 forwardc = xlate < struct output_struct > (f1).myc; 73 backwardi = xlate < struct input_struct > (f2).i; 74 backwardc = xlate < struct input_struct > (f2).c; 75 76 printf("forwardi: %d\tforwardc: %c\n", forwardi, forwardc); 77 printf("backwardi: %d\tbackwardc: %c", backwardi, backwardc); 78 exit(0); 79 } 80 81 BEGIN 82 /(10 == forwardi) && ('c' == forwardc) && (100 == backwardi) && 83 ('d' == backwardc)/ 84 { 85 exit(0); 86 } 87 88 BEGIN 89 /(10 != forwardi) || ('c' != forwardc) || (100 != backwardi) || 90 ('d' != backwardc)/ 91 { 92 exit(1); 93 } 94 95 ERROR 96 { 97 exit(1); 98 } 99