~oontvoo/+junk/test_hw

« back to all changes in this revision

Viewing changes to src/jminusminus/JMethodDeclaration.java

  • Committer: vnguyen
  • Date: 2013-05-10 04:33:44 UTC
  • Revision ID: oontvoo@hotmail.com-20130510043344-e1d5kaolxzunrmkl
support boolean expressions on Java, method returning double, taking double as params, and support ternary op (with doubles)

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
        for (JFormalParameter param : params) {
151
151
            LocalVariableDefn defn = new LocalVariableDefn(param.type(),
152
152
                    this.context.nextOffset());
 
153
            // if param is double, increase offset by 1,
 
154
            // because it is a ddouble word
 
155
            if (param.type() == Type.DOUBLE)
 
156
                this.context.nextOffset();
 
157
            
153
158
            defn.initialize();
154
159
            this.context.addEntry(param.line(), param.name(), defn);
155
160
        }
183
188
                || returnType == Type.CHAR) {
184
189
            partial.addNoArgInstruction(ICONST_0);
185
190
            partial.addNoArgInstruction(IRETURN);
186
 
        } else {
 
191
        } 
 
192
        else if (returnType == Type.DOUBLE)
 
193
        {
 
194
            partial.addNoArgInstruction(DCONST_0);
 
195
            partial.addNoArgInstruction(DRETURN);
 
196
        }
 
197
        else {
187
198
            // A reference type.
188
199
            partial.addNoArgInstruction(ACONST_NULL);
189
200
            partial.addNoArgInstruction(ARETURN);