~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/output/MIVarUpdateInfo.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2000, 2006 QNX Software Systems and others.
 
3
 * All rights reserved. This program and the accompanying materials
 
4
 * are made available under the terms of the Eclipse Public License v1.0
 
5
 * which accompanies this distribution, and is available at
 
6
 * http://www.eclipse.org/legal/epl-v10.html
 
7
 *
 
8
 * Contributors:
 
9
 *     QNX Software Systems - Initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.cdt.debug.mi.core.output;
 
12
 
 
13
import java.util.ArrayList;
 
14
import java.util.List;
 
15
 
 
16
/**
 
17
 * GDB/MI var-update.
 
18
 * -var-update *
 
19
 * ^done,changelist={name="var3",in_scope="true",type_changed="false",name="var2",in_scope="true",type_changed="false"}
 
20
 */
 
21
public class MIVarUpdateInfo extends MIInfo {
 
22
 
 
23
        MIVarChange[] changeList;
 
24
 
 
25
        public MIVarUpdateInfo(MIOutput record) {
 
26
                super(record);
 
27
                parse();
 
28
        }
 
29
 
 
30
        public MIVarChange[] getMIVarChanges() {
 
31
                return changeList;
 
32
        }
 
33
 
 
34
        void parse() {
 
35
                List aList = new ArrayList();
 
36
                if (isDone()) {
 
37
                        MIOutput out = getMIOutput();
 
38
                        MIResultRecord rr = out.getMIResultRecord();
 
39
                        if (rr != null) {
 
40
                                MIResult[] results =  rr.getMIResults();
 
41
                                for (int i = 0; i < results.length; i++) {
 
42
                                        String var = results[i].getVariable();
 
43
                                        if (var.equals("changelist")) { //$NON-NLS-1$
 
44
                                                MIValue value = results[i].getMIValue();
 
45
                                                if (value instanceof MITuple) {
 
46
                                                        parseChangeList((MITuple)value, aList);
 
47
                                                } else if (value instanceof MIList) {
 
48
                                                        parseChangeList((MIList)value, aList);
 
49
                                                }
 
50
                                        }
 
51
                                }
 
52
                        }
 
53
                }
 
54
                changeList = (MIVarChange[])aList.toArray(new MIVarChange[aList.size()]);
 
55
        }
 
56
 
 
57
        /**
 
58
         * For MI2 the format is now a MIList.
 
59
         * @param tuple
 
60
         * @param aList
 
61
         */
 
62
        void parseChangeList(MIList miList, List aList) {
 
63
                MIValue[] values = miList.getMIValues();
 
64
                for (int i = 0; i < values.length; ++i) {
 
65
                        if (values[i] instanceof MITuple) {
 
66
                                parseChangeList((MITuple)values[i], aList);
 
67
                        } else if (values[i] instanceof MIList) {
 
68
                                parseChangeList((MIList)values[i], aList);
 
69
                        }
 
70
                }
 
71
        } 
 
72
        
 
73
        void parseChangeList(MITuple tuple, List aList) {
 
74
                MIResult[] results = tuple.getMIResults();
 
75
                MIVarChange change = null;
 
76
                for (int i = 0; i < results.length; i++) {
 
77
                        String var = results[i].getVariable();
 
78
                        MIValue value = results[i].getMIValue();
 
79
                        if (value instanceof MITuple) {
 
80
                                parseChangeList((MITuple)value, aList);
 
81
                        }
 
82
                        else
 
83
                        {
 
84
                                String str = ""; //$NON-NLS-1$
 
85
                                if (value instanceof MIConst) {
 
86
                                        str = ((MIConst)value).getString();
 
87
                                }
 
88
                                if (var.equals("name")) { //$NON-NLS-1$
 
89
                                        change = new MIVarChange(str);
 
90
                                        aList.add(change);
 
91
                                } else if (var.equals("in_scope")) { //$NON-NLS-1$
 
92
                                        if (change != null) {
 
93
                                                change.setInScope("true".equals(str)); //$NON-NLS-1$
 
94
                                        }
 
95
                                } else if (var.equals("type_changed")) { //$NON-NLS-1$
 
96
                                        if (change != null) {
 
97
                                                change.setChanged("true".equals(str)); //$NON-NLS-1$
 
98
                                        }
 
99
                                }                               
 
100
                        }
 
101
                }
 
102
        }
 
103
}