Explorar o código

use inkwell rather than calling llvm directly

Signed-off-by: Sean Young <sean@mess.org>
Sean Young %!s(int64=6) %!d(string=hai) anos
pai
achega
894960f53a
Modificáronse 5 ficheiros con 306 adicións e 657 borrados
  1. 2 2
      Cargo.toml
  2. 289 648
      src/emit.rs
  3. 3 7
      src/main.rs
  4. BIN=BIN
      stdlib/stdlib.bc
  5. 12 0
      stdlib/stdlib.c

+ 2 - 2
Cargo.toml

@@ -5,7 +5,7 @@ authors = ["Sean Young <sean@mess.org>"]
 homepage = "https://github.com/hyperledger-labs/solang"
 license = "Apache-2.0 OR MIT"
 build = "build.rs"
-description = "Solidity to WASM Smart Contracts Compiler"
+description = "Solidity to WASM Smart Contract Compiler"
 
 [build-dependencies]
 lalrpop = "0.17.0"
@@ -13,7 +13,7 @@ lalrpop = "0.17.0"
 [dependencies]
 lalrpop-util = "0.17.0"
 regex = "0.2.1"
-llvm-sys = "80"
+inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "llvm8-0" }
 num-bigint = "0.2"
 num-traits = "0.2.6"
 parity-wasm = "0.35"

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 289 - 648
src/emit.rs


+ 3 - 7
src/main.rs

@@ -4,7 +4,6 @@ extern crate ethereum_types;
 extern crate hex;
 extern crate lalrpop_util;
 extern crate lazy_static;
-extern crate llvm_sys;
 extern crate num_bigint;
 extern crate num_traits;
 extern crate parity_wasm;
@@ -12,6 +11,7 @@ extern crate serde;
 extern crate tiny_keccak;
 extern crate unescape;
 extern crate wasmi;
+extern crate inkwell;
 
 use clap::{App, Arg};
 mod ast;
@@ -150,16 +150,12 @@ fn main() {
             let contract = emit::Contract::new(contract, &filename);
 
             if let Some("llvm") = matches.value_of("EMIT") {
-                contract.dump_llvm();
+                contract.dump_llvm(&output_file(&contract.name, "ll")).unwrap();
                 continue;
             }
 
             if let Some("bc") = matches.value_of("EMIT") {
-                let bc = contract.bitcode();
-                let bc_filename = output_file(&contract.name, "bc");
-
-                let mut file = File::create(bc_filename).unwrap();
-                file.write_all(&bc).unwrap();
+                contract.bitcode(&output_file(&contract.name, "bc"));
                 continue;
             }
 

BIN=BIN
stdlib/stdlib.bc


+ 12 - 0
stdlib/stdlib.c

@@ -17,6 +17,18 @@ extern void get_storage32(uint32_t key, void *dest, int32_t length);
 extern void set_storage32(uint32_t key, void *src, int32_t length);
 
 
+/*
+ */
+__attribute__((visibility("hidden")))
+void __memset8(void *_dest, uint64_t val, size_t length)
+{
+	uint64_t *dest = _dest;
+
+	do {
+		*dest++ = val;
+	} while (--length);
+}
+
 /*
  * Our memcpy can only deal with multiples of 8 bytes. This is enough for
  * simple allocator below.

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio