Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dvtate committed Dec 16, 2023
1 parent f9cef94 commit d8c19dc
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 19 deletions.
1 change: 0 additions & 1 deletion debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#ifdef SCL_DEBUG_MODE
#define SCL_DEBUG_MSG(m) std::cout <<m;
#define SCL_DEBUG DLANG_DEBUG_MSG
#else
#define SCL_DEBUG_MSG(m)
#endif
Expand Down
6 changes: 3 additions & 3 deletions util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Created by tate on 02-05-20.
//

#ifndef DLANG_UTIL_HPP
#define DLANG_UTIL_HPP
#ifndef SCL_UTIL_HPP
#define SCL_UTIL_HPP

#include <string>
#include <istream>
Expand All @@ -28,4 +28,4 @@ namespace util {
std::pair<long, long> pos_to_line_offset(std::istream& file, const unsigned long long pos);
}

#endif //DLANG_UTIL_HPP
#endif //SCL_UTIL_HPP
4 changes: 2 additions & 2 deletions vm/bc/exec_bc_instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void exec_bc_instr(Frame& f, BCInstr cmd) {
return;

case BCInstr::OPCode::VAL_EMPTY:
f.eval_stack.emplace_back(Value());
f.eval_stack.emplace_back();
return;
case BCInstr::OPCode::VAL_TRUE:
f.eval_stack.emplace_back((ValueTypes::int_t) 1);
Expand Down Expand Up @@ -264,7 +264,7 @@ void exec_bc_instr(Frame& f, BCInstr cmd) {
}

case BCInstr::OPCode::VAL_CATCH:
f.eval_stack.emplace_back(Value((NativeFunction*) f.gc_make<CatchFn>(f)));
f.eval_stack.emplace_back((NativeFunction*) f.gc_make<CatchFn>(f));
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion vm/global_ids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class InputFn : public NativeFunction {
cs->throw_error(gen_error_object("EOF-Error", "input not received", *cs));

// return value
cs->stack.back()->eval_stack.emplace_back(Value(inp));
cs->stack.back()->eval_stack.emplace_back(inp);
// unfreeze origin thread
cs->stack.back()->rt->recv_msg(new UnfreezeCallStack(cs));
// die
Expand Down
12 changes: 6 additions & 6 deletions vm/lambda_return.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Created by tate on 23-05-20.
//

#ifndef DLANG_LAMBDA_RETURN_HPP
#define DLANG_LAMBDA_RETURN_HPP
#ifndef SCL_LAMBDA_RETURN_HPP
#define SCL_LAMBDA_RETURN_HPP


#include <iostream>
Expand Down Expand Up @@ -54,14 +54,14 @@ class LambdaReturnMsg : public RTMessage {
// TODO: Once compiler is smart enough to detect BS, this can be optimized

if (!this->stack_target || !this->frame_target) {
std::cout <<"invalid lambda return msg call ";
std::cerr <<"invalid lambda return msg call ";
}

while (this->stack_target->stack.back() != this->frame_target && !this->stack_target->stack.empty())
this->stack_target->stack.pop_back();

if (this->stack_target->stack.empty()) {
std::cout <<"o() called out of frame???\n";
std::cerr <<"o() called out of frame???\n";
return;
}

Expand All @@ -77,7 +77,7 @@ class LambdaReturnMsg : public RTMessage {
// i++; // don't pop frame_target...
// if (i <= 0) {
// // no longer on stack wtf??
// std::cout << "o() called out of scope???";
// std::cerr << "o() called out of scope???";
// // TODO: o() out of scope error
//
//
Expand Down Expand Up @@ -132,4 +132,4 @@ class LambdaReturnNativeFn : public NativeFunction {
void mark() override { }
};

#endif //DLANG_LAMBDA_RETURN_HPP
#endif //SCL_LAMBDA_RETURN_HPP
4 changes: 2 additions & 2 deletions vm/primitive_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ class StrSplitFn : public NativeClosure {
auto* ret = f.gc_make<ValueTypes::list_t>();
std::string& str = *(std::string*)this->data;
while ((next = str.find(delimiter, last)) != std::string::npos) {
ret->emplace_back(Value(str.substr(last, next-last)));
ret->emplace_back(str.substr(last, next-last));
last = next + 1;
}
ret->emplace_back(Value(str.substr(last)));
ret->emplace_back(str.substr(last));

// Return list of tokens
f.eval_stack.back() = Value(ret);
Expand Down
2 changes: 1 addition & 1 deletion vm/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ VM::VM(std::vector<Literal> lit_header, const std::vector<std::string>& argv, st
// Load argv
auto* args = ::new(this->gc.alloc<ValueTypes::list_t>()) ValueTypes::list_t();
for (const std::string& s : argv)
args->emplace_back(Value(s));
args->emplace_back(s);

main.vars[main.i_id] = ::new(this->gc.alloc<Value>()) Value(args);
main.vars[main.o_id] = ::new(this->gc.alloc<Value>()) Value(
Expand Down
6 changes: 3 additions & 3 deletions vm/vm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Created by tate on 17-05-20.
//

#ifndef DLANG_VM_HPP
#define DLANG_VM_HPP
#ifndef SCL_VM_HPP
#define SCL_VM_HPP

#include <iostream>
#include <thread>
Expand Down Expand Up @@ -314,4 +314,4 @@ namespace GC {
*/


#endif //DLANG_VM_HPP
#endif //SCL_VM_HPP

0 comments on commit d8c19dc

Please sign in to comment.