Package Hack.Translators

Examples of Hack.Translators.HackTranslatorException


    // Checks the given comparison file name and throws an AssemblerException
    // if not legal.
    private void checkComparisonFile(String fileName) throws HackTranslatorException {
        if (!fileName.endsWith("." + getDestinationExtension())) {
            throw new HackTranslatorException(fileName + " is not a ." + getDestinationExtension()
                    + " file");
        }

        File file = new File(fileName);
        if (!file.exists()) {
            throw new HackTranslatorException("File " + fileName + " does not exist");
        }
    }
View Full Code Here


                comp.setContents(comparisonFileName);

                comparisonProgram = new short[comp.getNumberOfLines()];
                for (int i = 0; i < comp.getNumberOfLines(); i++) {
                    if (comp.getLineAt(i).length() != Definitions.BITS_PER_WORD) {
                        throw new HackTranslatorException("Error in file " + comparisonFileName + ": Line " + i + " does not contain exactly " + Definitions.BITS_PER_WORD + " characters");
                    }
                    try {
                        comparisonProgram[i] = (short) Conversions.binaryToInt(comp.getLineAt(i));
                    } catch (NumberFormatException nfe) {
                        throw new HackTranslatorException("Error in file " + comparisonFileName + ": Line " + i + " does not contain only 1/0 characters");
                    }
                }
            }
        } catch (IOException ioe) {
            throw new HackTranslatorException("Error reading from file " + comparisonFileName);
        }
    }
View Full Code Here

                        }
                    }
                }
            }
        } catch (IOException ioe) {
            throw new HackTranslatorException("Error reading from file " + getSourceFileName());
        }
    }
View Full Code Here

                    ((HackAssemblerGUI) getGui()).getComparison().addHighlight(getDestPC() - 1, true);
                }
            }

            if (!compare) {
                throw new HackTranslatorException("Comparison failure");
            }
        }

        return compiledRange;
    }
View Full Code Here

                        }
                    }
                }
            }
        } catch (IOException ioe) {
            throw new HackTranslatorException("Error reading from file " + getSourceFileName());
        } catch (AssemblerException ae) {
            throw new HackTranslatorException(ae.getMessage(), getSourcePC());
        }
    }
View Full Code Here

TOP

Related Classes of Hack.Translators.HackTranslatorException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.