Projects >> WhileyCompiler >>fd4dc6e266cf828649b848fea01c1c3af0b19b13

Chunk
Conflicting content
 * 

<<<<<<< HEAD:src/wyjc/transforms/JvmBytecodeWriter.java // Copyright (c) 2011, David J. Pearce (djp@ecs.vuw.ac.nz) // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of the nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL DAVID J. PEARCE BE LIABLE FOR ANY // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package wyjc.transforms; import java.io.FileOutputStream; import java.io.IOException; import wyil.ModuleLoader; import wyil.Transform; import wyil.lang.Module; import wyjc.io.ClassFileBuilder; import wyjvm.io.BytecodeFileWriter; import wyjvm.lang.ClassFile; import wyjvm.util.Continuations; import wyjvm.util.DeadCodeElimination; import wyjvm.util.Validation; public class JvmBytecodeWriter implements Transform { private ClassFileBuilder classBuilder; private final boolean validate = true; private final boolean deadCode = true; private final boolean continuations = true; public JvmBytecodeWriter(ModuleLoader loader) { classBuilder = new ClassFileBuilder(loader, wyjc.Main.MAJOR_VERSION, wyjc.Main.MINOR_VERSION); } public void apply(Module m) throws IOException { ClassFile file = classBuilder.build(m); if(validate) { // validate generated bytecode new Validation().apply(file); } if(deadCode) { // eliminate any dead code that was introduced. new DeadCodeElimination().apply(file); } if (continuations) { new Continuations().apply(file); } // calculate filename String filename = m.filename().replace(".whiley", ".jvm"); FileOutputStream out = new FileOutputStream(filename); BytecodeFileWriter writer = new BytecodeFileWriter(out,null); writer.write(file); out.flush(); } } ======= // Copyright (c) 2011, David J. Pearce (djp@ecs.vuw.ac.nz) // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of the nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL DAVID J. PEARCE BE LIABLE FOR ANY // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package wybs.lang; import java.util.*; import wyil.util.Pair; /** * Responsible for transforming files from one content type to another. * Typically this revolves around compiling the source file into some kind of * binary, although other kinds of transformations are possible. *

* *

* A given builder may support multiple transformations and the builder must * declare each of these. *

* * @author David J. Pearce * */ public interface Builder { /** * Get the namespace this builder is operating on. * @return */ public NameSpace namespace(); /** * Build a given set of source files to produce a given set of target files. * A delta represents a list of pairs (s,t), where s is a source file and t * is its corresponding target entry. That is, the source entry is * transformed into the target entry by the builder. * * @param delta * --- the set of files to be built. */ public void build(List,Path.Entry>> delta) throws Exception; } >>>>>>> b6a52e89f9eee31f8514a18170151f938d5570d1:src/wybs/lang/Builder.java
Solution content
// Copyright (c) 2011, David J. Pearce (djp@ecs.vuw.ac.nz)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//    * Redistributions of source code must retain the above copyright
//      notice, this list of conditions and the following disclaimer.
//    * Redistributions in binary form must reproduce the above copyright
//      notice, this list of conditions and the following disclaimer in the
//      documentation and/or other materials provided with the distribution.
//    * Neither the name of the  nor the
//      names of its contributors may be used to endorse or promote products
//      derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL DAVID J. PEARCE BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

package wybs.lang;

import java.util.*;

import wyil.util.Pair;

/**
 * 

* Responsible for transforming files from one content type to another. * Typically this revolves around compiling the source file into some kind of * binary, although other kinds of transformations are possible. *

* *

* A given builder may support multiple transformations and the builder must * declare each of these. *

* * @author David J. Pearce * */ public interface Builder { /** * Get the namespace this builder is operating on. * @return */ public NameSpace namespace(); /** * Build a given set of source files to produce a given set of target files. * A delta represents a list of pairs (s,t), where s is a source file and t * is its corresponding target entry. That is, the source entry is * transformed into the target entry by the builder. * * @param delta * --- the set of files to be built. */ public void build(List,Path.Entry>> delta) throws Exception; }
File
Builder.java
Developer's decision
Version 2
Kind of conflict
Class declaration
Comment
Import
Interface declaration
Package declaration