Skip to content

Commit 799ee3d

Browse files
authored
Merge pull request #8 from yukikamome316/syoch-remake
Syoch value toka wo simplize sitayo
2 parents ab2ab3b + 32fea80 commit 799ee3d

71 files changed

Lines changed: 2505 additions & 2619 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/settings.json

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
{
55
// "cmd": "python3 autotool/auto/autoc.py \"make; ./MineCode -c demo/test\"",
66
// "cmd": "meson .. .",
7-
"cmd": "ninja",
7+
"cmd": "ninja; src/minecodec -c ../demo/debug",
88
"isAsync": true,
99
"silent": true
1010
}
1111
]
1212
},
1313
"files.associations": {
1414
"*.mc": "json",
15+
"*.meson": "meson",
1516
"array": "cpp",
1617
"atomic": "cpp",
1718
"hash_map": "cpp",
@@ -79,7 +80,31 @@
7980
"regex": "cpp",
8081
"shared_mutex": "cpp",
8182
"valarray": "cpp",
82-
"cassert": "cpp"
83+
"cassert": "cpp",
84+
"__bit_reference": "cpp",
85+
"__functional_base": "cpp",
86+
"__memory": "cpp",
87+
"filesystem": "cpp",
88+
"__locale": "cpp",
89+
"*.def": "cpp",
90+
"*.inc": "cpp",
91+
"*.gen": "cpp",
92+
"hash_set": "cpp",
93+
"__config": "cpp",
94+
"__debug": "cpp",
95+
"__errc": "cpp",
96+
"__hash_table": "cpp",
97+
"__mutex_base": "cpp",
98+
"__node_handle": "cpp",
99+
"__nullptr": "cpp",
100+
"__split_buffer": "cpp",
101+
"__string": "cpp",
102+
"__threading_support": "cpp",
103+
"__tree": "cpp",
104+
"__tuple": "cpp",
105+
"locale": "cpp",
106+
"queue": "cpp",
107+
"stack": "cpp"
83108
},
84109
"todo-tree.tree.showBadges": true,
85110
"todo-tree.tree.showCountsInTree": true,

docs/reference-ja.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# MineCode リフェレンス
2+
## MineCodeについて
3+
MineCodeは主にWii Uのチートコード(機械語)を作成するためのツールです
4+
5+
## 型の概念
6+
MineCodeには型の概念がなく、すべて整数型として処理されます。
7+
floatなどの少数型は現時点では、サポートしていません(今度のアップデートで対応する可能性)。
8+
文字列型はその文字列へのポインタ(整数)になって格納されます。
9+
10+
## mcl
11+
MineCodeでは色々な情報をjsonで記述できるmclというシステムがあります。
12+
mclの例はこのリポジトリのmclsディレクトリにあるのでそこを参考にしてください。
13+
構造は以下のとおりです。
14+
```jsonc
15+
{
16+
"name": "そのmclの名前",
17+
"ver": 1, // 現時点では1を指定してください
18+
// ストリームのような機能を提供できます
19+
"put": {
20+
"label": {
21+
"type": "asm", // アセンブラであることを示します
22+
// "asm" の他に "MineCode"も使用できます。
23+
"proc": "$arg:" // $arg には渡されたものが入ります
24+
},
25+
// 木構造で書くこともできます
26+
"a": {
27+
"b": {
28+
"type": "asm",
29+
"proc": "hello:" // $argが使われてなくてもエラーにはなりませんが推奨しません
30+
}
31+
}
32+
},
33+
// ポインタの宣言
34+
// 上から順に処理されるので、依存関係順に書いてください
35+
"pointers": [
36+
["ポインタの名前", "ポインタ式"],
37+
//
38+
["manager", "[0x20000000]"]
39+
],
40+
// 関数の宣言
41+
"functions": { // これもまた木構造でもかけます
42+
"exit": {
43+
"addr": 33554432, // json の制約上10進数で書く必要があります
44+
"args": [ // 現時点では無視されます
45+
{
46+
// 引数の型です
47+
// 使える識別子は
48+
// int, cstr, wstr, ptr
49+
// cstrとwstrはstd::stringとstd::wstringの違いと同じです
50+
"T": "int",
51+
// デフォルトで渡される値の式です
52+
"default": "0"
53+
}
54+
]
55+
}
56+
}
57+
}
58+
```
59+
60+
## 変数
61+
MineCodeは変数をサポートしています。
62+
この変数は型が無いため(すべて整数)型チェックができないという欠点があります。
63+
64+
### 特徴
65+
MineCodeの型はC系の言語と違い、自動的に変数が宣言されます。
66+
なので以下のようなソースがエラーなく動作します。
67+
```
68+
a = 1
69+
b = a + 1
70+
```
71+
72+
## 関数
73+
MineCodeでは型の概念がないため関数の定義が非常に簡単です。
74+
ユーザー関数はまだまだ未熟ですが例を以下に示します
75+
```
76+
// int とか 実引数名は現時点では見ていません
77+
func hoge(int a, int b){
78+
}
79+
```
80+
アドレス指定関数呼び出しは他の言語より簡単に呼べます。
81+
※型チェックが行われないためクラッシュする可能性があります。
82+
例を以下に示します
83+
```
84+
func[0x02000000](0) // 0x02000000にある関数を呼べる
85+
```
86+
87+
## フロー制御
88+
### For (特定の範囲だけのループ)
89+
MineCodeには範囲を指定してループできる構文が有ります。
90+
それを以下に示します。
91+
```
92+
for i in 0...10{
93+
94+
}
95+
```
96+
97+
### If / While
98+
多言語と同じなので略。

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
project('minecode', 'cpp')
1+
project('minecode', 'cpp',default_options : ['c_std=c11', 'cpp_std=c++17'])
22
subdir('src')

src/include/cond/and.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
#pragma once
3+
4+
#include <inttypes.h>
5+
6+
#include <vector>
7+
8+
#include "primary.hpp"
9+
namespace parserTypes {
10+
struct condAnd {
11+
std::vector<struct condChild> conds;
12+
};
13+
} // namespace parserTypes

src/include/cond/cond.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include "and.hpp"
2+
#include "or.hpp"
3+
#include "primary.hpp"

src/include/cond/or.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
#pragma once
3+
4+
#include <inttypes.h>
5+
6+
#include <vector>
7+
8+
#include "and.hpp"
9+
10+
namespace parserTypes {
11+
struct cond {
12+
std::vector<struct condAnd> conds;
13+
};
14+
} // namespace parserTypes

src/include/cond/primary.hpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
#pragma once
3+
4+
#include <inttypes.h>
5+
6+
#include <expr/expr_t.hpp>
7+
#include <primary/primary.hpp>
8+
#include <vector>
9+
10+
#include "or.hpp"
11+
namespace parserTypes {
12+
struct condChild {
13+
enum Type {
14+
COND,
15+
16+
SINGLE, // var (to val1)
17+
SINGLE_INV,
18+
19+
EQU, // ==
20+
NEQ, // !=
21+
LT, // <
22+
GT, // >
23+
GE, // <=
24+
LE // >=
25+
};
26+
27+
struct cond child;
28+
primary::BasePrimary *single;
29+
30+
expr val1;
31+
Type op;
32+
expr val2;
33+
};
34+
} // namespace parserTypes

src/include/eval.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
#define EVAL_H
44
#include <string>
55

6-
namespace parserTypes
7-
{
8-
class expr;
9-
class expo;
10-
class term;
11-
class power;
6+
namespace parserTypes {
7+
class expr;
8+
class expo;
9+
class term;
1210

13-
class ptr;
11+
class ptr;
12+
namespace primary {
13+
class BasePrimary;
1414
}
15+
} // namespace parserTypes
1516
class parserCore;
16-
namespace eval
17-
{
18-
using namespace parserTypes;
19-
void Expr(parserCore *that, expr val, int dest = 13);
20-
void Expo(parserCore *that, expo val, int dest = 13);
21-
void Term(parserCore *that, term val, int dest = 13);
22-
void Power(parserCore *that, power val, int dest = 13);
23-
void Ptr(parserCore *that, ptr val, int dest = 13);
24-
void Var(parserCore *that, std::wstring obj, int dest);
25-
void Ptr_Addr(parserCore *that, ptr obj, int dest);
26-
} // namespace eval
17+
namespace eval {
18+
using namespace parserTypes;
19+
void Expr(parserCore *that, expr val, int dest = 13);
20+
void Expo(parserCore *that, expo val, int dest = 13);
21+
void Term(parserCore *that, term val, int dest = 13);
22+
void Power(parserCore *that, primary::BasePrimary &val, int dest = 13);
23+
void Ptr(parserCore *that, ptr val, int dest = 13);
24+
void Var(parserCore *that, std::wstring obj, int dest);
25+
void Ptr_Addr(parserCore *that, ptr obj, int dest);
26+
} // namespace eval
2727

2828
#endif

0 commit comments

Comments
 (0)