[compiler] add psize-of (#564)

This commit is contained in:
ManDude 2021-06-07 04:02:00 +01:00 committed by GitHub
parent 698d96cc4e
commit 63821755e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View File

@ -557,6 +557,7 @@ class Compiler {
Val* compile_none(const goos::Object& form, const goos::Object& rest, Env* env);
Val* compile_defenum(const goos::Object& form, const goos::Object& rest, Env* env);
Val* compile_size_of(const goos::Object& form, const goos::Object& rest, Env* env);
Val* compile_psize_of(const goos::Object& form, const goos::Object& rest, Env* env);
};
extern const std::unordered_map<

View File

@ -174,6 +174,7 @@ const std::unordered_map<
{"declare-type", &Compiler::compile_declare_type},
{"none", &Compiler::compile_none},
{"size-of", &Compiler::compile_size_of},
{"psize-of", &Compiler::compile_psize_of},
// LAMBDA
{"lambda", &Compiler::compile_lambda},

View File

@ -1260,3 +1260,7 @@ int Compiler::get_size_for_size_of(const goos::Object& form, const goos::Object&
Val* Compiler::compile_size_of(const goos::Object& form, const goos::Object& rest, Env* env) {
return compile_integer(get_size_for_size_of(form, rest), env);
}
Val* Compiler::compile_psize_of(const goos::Object& form, const goos::Object& rest, Env* env) {
return compile_integer((get_size_for_size_of(form, rest) + 0xf) & ~0xf, env);
}