Fixed problems
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
use <collections::list>;
|
use <super::task>;
|
||||||
use <core::task>;
|
use <super::logger>;
|
||||||
use <core::logger>;
|
use <super::event>;
|
||||||
use <core::event>;
|
|
||||||
|
|
||||||
public class Application {
|
public class Application {
|
||||||
String name;
|
String name;
|
||||||
|
|
||||||
list::List<task::Task> tasks;
|
Vec<task::Task> tasks;
|
||||||
list::List<String> plugins;
|
Vec<String> plugins;
|
||||||
|
|
||||||
logger::Logger logger;
|
logger::Logger logger;
|
||||||
|
|
||||||
@@ -17,8 +16,8 @@ public class Application {
|
|||||||
public constructor(String name) {
|
public constructor(String name) {
|
||||||
self.name = name;
|
self.name = name;
|
||||||
|
|
||||||
self.tasks = new list::List();
|
self.tasks = new Vec();
|
||||||
self.plugins = new list::List();
|
self.plugins = new Vec();
|
||||||
|
|
||||||
self.logger = new logger::Logger("app");
|
self.logger = new logger::Logger("app");
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ public class Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register_plugin(self mut*, String name) {
|
public void register_plugin(self mut*, String name) {
|
||||||
self.plugins.push(name);
|
self.plugins.push(name.clone());
|
||||||
|
|
||||||
self.emit(event::Event::PluginLoaded(name));
|
self.emit(event::Event::PluginLoaded(name));
|
||||||
}
|
}
|
||||||
@@ -89,7 +88,7 @@ public class Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
event::Event::Error(message) => {
|
event::Event::Error(message) => {
|
||||||
self.logger.error(message);
|
self.logger.error(&message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,23 +7,23 @@ public enum LogLevel {
|
|||||||
public class Logger {
|
public class Logger {
|
||||||
String prefix;
|
String prefix;
|
||||||
|
|
||||||
public constructor(String prefix) {
|
public constructor(str* prefix) {
|
||||||
self.prefix = prefix;
|
self.prefix = prefix.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(self*, String message) {
|
public void info(self*, str* message) {
|
||||||
self.log(LogLevel::Info, message);
|
self.log(LogLevel::Info, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warning(self*, String message) {
|
public void warning(self*, str* message) {
|
||||||
self.log(LogLevel::Warning, message);
|
self.log(LogLevel::Warning, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void error(self*, String message) {
|
public void error(self*, str* message) {
|
||||||
self.log(LogLevel::Error, message);
|
self.log(LogLevel::Error, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void log(self*, LogLevel level, String message) {
|
void log(self*, LogLevel level, str* message) {
|
||||||
match(level) {
|
match(level) {
|
||||||
LogLevel::Info => {
|
LogLevel::Info => {
|
||||||
println!("[INFO] {} {}", self.prefix, message);
|
println!("[INFO] {} {}", self.prefix, message);
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ public struct Task {
|
|||||||
public i32 executions,
|
public i32 executions,
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task create_task(String name) {
|
public Task create_task(str* name) {
|
||||||
return Task {
|
return Task {
|
||||||
name: name,
|
name: name.to_string(),
|
||||||
state: TaskState::Pending,
|
state: TaskState::Pending,
|
||||||
executions: 0,
|
executions: 0,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
mod core;
|
mod core;
|
||||||
|
|
||||||
use <core::app>;
|
use <core::app>;
|
||||||
use <plugins::greeting>;
|
// use <plugins::greeting>;
|
||||||
use <plugins::statistics>;
|
// use <plugins::statistics>;
|
||||||
|
|
||||||
i32 main() {
|
void main() {
|
||||||
var app = new app::Application("mist-app");
|
var app = new app::Application("mist-app");
|
||||||
|
|
||||||
greeting::register(&mut app);
|
// greeting::register(&mut app);
|
||||||
statistics::register(&mut app);
|
// statistics::register(&mut app);
|
||||||
|
|
||||||
app.boot();
|
app.boot();
|
||||||
app.run();
|
app.run();
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
public class MyClass {
|
|
||||||
String message;
|
|
||||||
|
|
||||||
public constructor(str* name) {
|
|
||||||
self.message = format!("Hello {}!", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void greet(self*) {
|
|
||||||
println!("{}", self.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum MyEnum {
|
|
||||||
Named,
|
|
||||||
Tuple(i32, String),
|
|
||||||
Struct { i32 x }
|
|
||||||
}
|
|
||||||
@@ -272,7 +272,6 @@ statement_list = {
|
|||||||
statement = _{
|
statement = _{
|
||||||
expr_stmt
|
expr_stmt
|
||||||
| match_stmt
|
| match_stmt
|
||||||
| var_decl_statement
|
|
||||||
| assign_statement
|
| assign_statement
|
||||||
| if_stmt
|
| if_stmt
|
||||||
| while_stmt
|
| while_stmt
|
||||||
@@ -282,6 +281,7 @@ statement = _{
|
|||||||
| break_stmt
|
| break_stmt
|
||||||
| continue_stmt
|
| continue_stmt
|
||||||
| block
|
| block
|
||||||
|
| var_decl_statement
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user