This repository has been archived by the owner on Dec 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathfuncs.cpp
69 lines (58 loc) · 1.79 KB
/
funcs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdio.h>
#include <iostream>
#include <vector>
#include "funcs.h"
#include "bignum.h"
#include "util.h"
#include "parser.h"
#include "lllparser.h"
#include "compiler.h"
#include "rewriter.h"
#include "tokenize.h"
#include "preprocess.h"
Node compileToLLL(std::string input) {
return rewrite(parseSerpent(input));
}
Node compileChunkToLLL(std::string input) {
return rewriteChunk(parseSerpent(input));
}
std::string compile(std::string input) {
return compileLLL(compileToLLL(input));
}
std::vector<Node> prettyCompile(std::string input) {
return prettyCompileLLL(compileToLLL(input));
}
std::string compileChunk(std::string input) {
return compileLLL(compileChunkToLLL(input));
}
std::vector<Node> prettyCompileChunk(std::string input) {
return prettyCompileLLL(compileChunkToLLL(input));
}
std::string mkSignature(std::string input) {
return mkExternLine(parseSerpent(input));
}
std::string mkFullSignature(std::string input) {
return mkFullExtern(parseSerpent(input));
}
std::string mkContractInfoDecl(std::string input) {
Node n = parseSerpent(input);
std::string s = mkFullExtern(n);
std::string c = compileLLL(rewrite(n));
return "{\n"
" \"code\": \"0x" + binToHex(c) + "\",\n"
" \"info\": {\n"
" \"abiDefinition\": " + indentLines(indentLines(s)).substr(8) + "\n"
" },\n"
" \"language\": \"serpent\",\n"
" \"languageVersion\": \"2\",\n"
" \"source\": \""+input+"\",\n"
" \"userDoc\": {}\n"
"}";
}
unsigned int getPrefix(Node signature) {
typeMetadata t = getTypes(signature);
return getPrefix(t.name, t.inTypes);
}
unsigned int getPrefix(std::string signature) {
return getPrefix(parseSerpent(signature));
}