Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
45af75a
update: separete sources variable
Jul 24, 2021
e89ae8f
update: separete some parser funcs
Jul 24, 2021
acaf359
update: add test
Jul 24, 2021
f670040
update: separete more function
Jul 24, 2021
3c32e97
update: separete cond.cpp
Jul 24, 2021
03299f9
refactor: format
Jul 24, 2021
2db0403
update: format
Jul 24, 2021
b45e524
refactor: format
Jul 24, 2021
921ee0d
update: add utility funcs
Jul 25, 2021
f2c3857
update: simplize and format
Jul 25, 2021
e171e45
update: separete source code
Jul 25, 2021
cfc3946
fix: fix some warnings
Jul 25, 2021
b9d88c2
fix: fix all warning
Jul 25, 2021
8efde1f
update: separete cond
Jul 25, 2021
a0cd90a
update: move cond[util|eval]
Jul 25, 2021
64826fc
update: move expr.hpp
Jul 25, 2021
ba51c08
update: separete ptr
Jul 25, 2021
384f420
update: separete term
Jul 25, 2021
aa5dc25
update: separete expo
Jul 25, 2021
7a21657
update: separete expo_wrap
Jul 25, 2021
acd5877
update: separete value
Jul 25, 2021
a93d7ec
update: separete
Jul 25, 2021
74c7c05
refactor: remove old include cguard
Jul 25, 2021
8846799
update: remove some header depend
Jul 25, 2021
8a778d2
other: add reference of MineCode language
Jul 25, 2021
a60b56e
update: separete optimizer
Jul 25, 2021
373363a
update: separete optimizer
Jul 25, 2021
9780477
update: separete evaluter
Jul 25, 2021
f93b1dd
update: separete evaluter of term
Jul 25, 2021
94b0698
update: separete all of evalute functions
Jul 25, 2021
bffe652
update: rename power to primary
Jul 25, 2021
00d5280
update: rename file
Jul 25, 2021
86acdc1
update:separete
Jul 25, 2021
2c48349
update: change file
Jul 25, 2021
bf1adc4
update: add alias header
Jul 25, 2021
00f98e3
fix: fix some class member declare
Jul 25, 2021
8d3a0c4
fix: fix pointer declare
Jul 25, 2021
d823372
update: fix name
Jul 25, 2021
4a9140a
update: add immutable ctor
Jul 25, 2021
d1146d7
style? : update add TODO
Jul 25, 2021
467bbc8
fix: fix member name for compile error
Jul 25, 2021
3125397
fix: function declare
Jul 25, 2021
ad3d66c
update: add virtual keyword
Jul 25, 2021
cc568e3
update: add TODO
Jul 25, 2021
f69ce46
fix: fix expr parser
Jul 25, 2021
bbd7842
update: add empty file edit for next time
Jul 25, 2021
bb52c5d
update: change power() return value
Jul 25, 2021
f5da15a
update: fix power evaluter
Jul 25, 2021
0edae07
update: change vector type
Jul 25, 2021
4feef39
update: fix some error depends on type change
Jul 25, 2021
9fbc7a0
update: update some
Jul 25, 2021
cee1fee
update: add default ctor/dtor
Jul 25, 2021
8863a2d
update: add member accessser
Jul 25, 2021
e9cf86f
update: add eval() in child of primary classes
Jul 25, 2021
4619473
update: add public keydowrds
Jul 25, 2021
51110b9
fix: add missing header depend
Jul 25, 2021
1c996d8
fix: add class publish keyword
Jul 25, 2021
51c5820
update: impl some dtors and eval as prototype
Jul 25, 2021
0b4f12d
update: add argument to primary.eval
Jul 25, 2021
f51c58f
update: add argument to source
Jul 25, 2021
0a5901a
update: impl primary::inner::eval
Jul 25, 2021
ea44511
update: impl primary::FuncCall::eval
Jul 25, 2021
8557fa8
update: impl Immutable
Jul 25, 2021
5a72290
update: impl primary::pointer::eval
Jul 25, 2021
731b4df
update: impl primary::variable::eval
Jul 25, 2021
be2b1e5
update: add missing argument
Jul 25, 2021
4038b97
update: move header
Jul 25, 2021
733853b
update: fix some error
Jul 25, 2021
9020bcb
update: add some value subclasses
Jul 25, 2021
123d5b7
update: remove comment
Jul 25, 2021
1fa3baf
update: add some sources
Jul 25, 2021
5a2e082
update: add prototype declare
Jul 25, 2021
fac83b0
update: add missing header depend
Jul 25, 2021
0d27d2c
update: add dtor/eval
Jul 25, 2021
a23b878
other: add file associations
Jul 25, 2021
7a4b874
fix: some errors
Jul 25, 2021
229cc36
update: add alias header
Jul 25, 2021
8b5995d
update: add mroe public
Jul 25, 2021
620e01b
fix: fix expr parser
Jul 25, 2021
c56567f
fix: fix stmtProcessor
Jul 25, 2021
1f6f863
update: fix some errors
Jul 25, 2021
90b7a68
other: add associations
Jul 25, 2021
08b9068
fix: add value ctor
Jul 25, 2021
19d2e89
fix: ident can not be proc bug
Jul 25, 2021
e453bcb
fix: some warnings
Jul 25, 2021
af91028
update: add primary::str
Jul 25, 2021
a4c94b5
fix: fix crazy typo
Jul 25, 2021
f572ad4
update: rewrite in primary
Jul 25, 2021
32fea80
update: remove value
Jul 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
{
// "cmd": "python3 autotool/auto/autoc.py \"make; ./MineCode -c demo/test\"",
// "cmd": "meson .. .",
"cmd": "ninja",
"cmd": "ninja; src/minecodec -c ../demo/debug",
"isAsync": true,
"silent": true
}
]
},
"files.associations": {
"*.mc": "json",
"*.meson": "meson",
"array": "cpp",
"atomic": "cpp",
"hash_map": "cpp",
Expand Down Expand Up @@ -79,7 +80,31 @@
"regex": "cpp",
"shared_mutex": "cpp",
"valarray": "cpp",
"cassert": "cpp"
"cassert": "cpp",
"__bit_reference": "cpp",
"__functional_base": "cpp",
"__memory": "cpp",
"filesystem": "cpp",
"__locale": "cpp",
"*.def": "cpp",
"*.inc": "cpp",
"*.gen": "cpp",
"hash_set": "cpp",
"__config": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__hash_table": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__nullptr": "cpp",
"__split_buffer": "cpp",
"__string": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__tuple": "cpp",
"locale": "cpp",
"queue": "cpp",
"stack": "cpp"
},
"todo-tree.tree.showBadges": true,
"todo-tree.tree.showCountsInTree": true,
Expand Down
98 changes: 98 additions & 0 deletions docs/reference-ja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# MineCode リフェレンス
## MineCodeについて
MineCodeは主にWii Uのチートコード(機械語)を作成するためのツールです

## 型の概念
MineCodeには型の概念がなく、すべて整数型として処理されます。
floatなどの少数型は現時点では、サポートしていません(今度のアップデートで対応する可能性)。
文字列型はその文字列へのポインタ(整数)になって格納されます。

## mcl
MineCodeでは色々な情報をjsonで記述できるmclというシステムがあります。
mclの例はこのリポジトリのmclsディレクトリにあるのでそこを参考にしてください。
構造は以下のとおりです。
```jsonc
{
"name": "そのmclの名前",
"ver": 1, // 現時点では1を指定してください
// ストリームのような機能を提供できます
"put": {
"label": {
"type": "asm", // アセンブラであることを示します
// "asm" の他に "MineCode"も使用できます。
"proc": "$arg:" // $arg には渡されたものが入ります
},
// 木構造で書くこともできます
"a": {
"b": {
"type": "asm",
"proc": "hello:" // $argが使われてなくてもエラーにはなりませんが推奨しません
}
}
},
// ポインタの宣言
// 上から順に処理されるので、依存関係順に書いてください
"pointers": [
["ポインタの名前", "ポインタ式"],
// 例
["manager", "[0x20000000]"]
],
// 関数の宣言
"functions": { // これもまた木構造でもかけます
"exit": {
"addr": 33554432, // json の制約上10進数で書く必要があります
"args": [ // 現時点では無視されます
{
// 引数の型です
// 使える識別子は
// int, cstr, wstr, ptr
// cstrとwstrはstd::stringとstd::wstringの違いと同じです
"T": "int",
// デフォルトで渡される値の式です
"default": "0"
}
]
}
}
}
```

## 変数
MineCodeは変数をサポートしています。
この変数は型が無いため(すべて整数)型チェックができないという欠点があります。

### 特徴
MineCodeの型はC系の言語と違い、自動的に変数が宣言されます。
なので以下のようなソースがエラーなく動作します。
```
a = 1
b = a + 1
```

## 関数
MineCodeでは型の概念がないため関数の定義が非常に簡単です。
ユーザー関数はまだまだ未熟ですが例を以下に示します
```
// int とか 実引数名は現時点では見ていません
func hoge(int a, int b){
}
```
アドレス指定関数呼び出しは他の言語より簡単に呼べます。
※型チェックが行われないためクラッシュする可能性があります。
例を以下に示します
```
func[0x02000000](0) // 0x02000000にある関数を呼べる
```

## フロー制御
### For (特定の範囲だけのループ)
MineCodeには範囲を指定してループできる構文が有ります。
それを以下に示します。
```
for i in 0...10{

}
```

### If / While
多言語と同じなので略。
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
project('minecode', 'cpp')
project('minecode', 'cpp',default_options : ['c_std=c11', 'cpp_std=c++17'])
subdir('src')
13 changes: 13 additions & 0 deletions src/include/cond/and.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#pragma once

#include <inttypes.h>

#include <vector>

#include "primary.hpp"
namespace parserTypes {
struct condAnd {
std::vector<struct condChild> conds;
};
} // namespace parserTypes
3 changes: 3 additions & 0 deletions src/include/cond/cond.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "and.hpp"
#include "or.hpp"
#include "primary.hpp"
File renamed without changes.
14 changes: 14 additions & 0 deletions src/include/cond/or.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

#pragma once

#include <inttypes.h>

#include <vector>

#include "and.hpp"

namespace parserTypes {
struct cond {
std::vector<struct condAnd> conds;
};
} // namespace parserTypes
34 changes: 34 additions & 0 deletions src/include/cond/primary.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#pragma once

#include <inttypes.h>

#include <expr/expr_t.hpp>
#include <primary/primary.hpp>
#include <vector>

#include "or.hpp"
namespace parserTypes {
struct condChild {
enum Type {
COND,

SINGLE, // var (to val1)
SINGLE_INV,

EQU, // ==
NEQ, // !=
LT, // <
GT, // >
GE, // <=
LE // >=
};

struct cond child;
primary::BasePrimary *single;

expr val1;
Type op;
expr val2;
};
} // namespace parserTypes
File renamed without changes.
36 changes: 18 additions & 18 deletions src/include/eval.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
#define EVAL_H
#include <string>

namespace parserTypes
{
class expr;
class expo;
class term;
class power;
namespace parserTypes {
class expr;
class expo;
class term;

class ptr;
class ptr;
namespace primary {
class BasePrimary;
}
} // namespace parserTypes
class parserCore;
namespace eval
{
using namespace parserTypes;
void Expr(parserCore *that, expr val, int dest = 13);
void Expo(parserCore *that, expo val, int dest = 13);
void Term(parserCore *that, term val, int dest = 13);
void Power(parserCore *that, power val, int dest = 13);
void Ptr(parserCore *that, ptr val, int dest = 13);
void Var(parserCore *that, std::wstring obj, int dest);
void Ptr_Addr(parserCore *that, ptr obj, int dest);
} // namespace eval
namespace eval {
using namespace parserTypes;
void Expr(parserCore *that, expr val, int dest = 13);
void Expo(parserCore *that, expo val, int dest = 13);
void Term(parserCore *that, term val, int dest = 13);
void Power(parserCore *that, primary::BasePrimary &val, int dest = 13);
void Ptr(parserCore *that, ptr val, int dest = 13);
void Var(parserCore *that, std::wstring obj, int dest);
void Ptr_Addr(parserCore *that, ptr obj, int dest);
} // namespace eval

#endif
10 changes: 10 additions & 0 deletions src/include/expr/expo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include <primary/primary.hpp>
#include <vector>
namespace parserTypes {
struct expo {
std::vector<primary::BasePrimary*> parts;
bool isSingle();
};
} // namespace parserTypes
13 changes: 13 additions & 0 deletions src/include/expr/expo_wrap.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <vector>

#include "expo.hpp"
namespace parserTypes {
struct expo_wrap {
enum Type { MUL, DIV, MOD };

Type type;
struct expo value;
};
} // namespace parserTypes
9 changes: 9 additions & 0 deletions src/include/expr/expr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include <primary/primary.hpp>

#include "expo.hpp"
#include "expo_wrap.hpp"
#include "expr.hpp"
#include "ptr.hpp"
#include "term.hpp"
13 changes: 13 additions & 0 deletions src/include/expr/expr_t.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <vector>

#include "term.hpp"

namespace parserTypes {
// TODO: rename this to Expr
struct expr {
std::vector<struct term> parts;
bool isSingle();
};
} // namespace parserTypes
17 changes: 17 additions & 0 deletions src/include/expr/ptr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <memory>

namespace parserTypes {
class expr;
class ptr {
std::shared_ptr<expr> base;

public:
ptr(expr &_base);
ptr(expr *_base);
ptr();

expr getBase();
};
} // namespace parserTypes
11 changes: 11 additions & 0 deletions src/include/expr/term.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include <vector>

#include "expo_wrap.hpp"
namespace parserTypes {
struct term {
std::vector<struct expo_wrap> parts;
bool isSingle();
};
} // namespace parserTypes
Loading