2015-03-07 17:26:19 +01:00
|
|
|
/*
|
|
|
|
* Monicelli: an esoteric language compiler
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Stefano Sanfilippo
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-03-08 12:19:06 +01:00
|
|
|
#include "Runtime.hpp"
|
2015-03-07 14:12:18 +01:00
|
|
|
|
2015-03-08 12:19:06 +01:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cassert>
|
2015-03-07 14:12:18 +01:00
|
|
|
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
void Monicelli_putBool(Monicelli_Bool value) {
|
2015-03-07 19:44:34 +01:00
|
|
|
puts(value? "vero\n": "falso\n");
|
2015-03-07 14:12:18 +01:00
|
|
|
}
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
void Monicelli_putChar(Monicelli_Char value) {
|
2015-03-07 14:12:18 +01:00
|
|
|
printf("%c", value);
|
|
|
|
}
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
void Monicelli_putInt(Monicelli_Int value) {
|
2015-03-07 19:44:34 +01:00
|
|
|
printf("%ld\n", value);
|
2015-03-07 14:12:18 +01:00
|
|
|
}
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
void Monicelli_putFloat(Monicelli_Float value) {
|
2015-03-08 12:34:51 +01:00
|
|
|
printf("%g\n", value);
|
2015-03-07 14:12:18 +01:00
|
|
|
}
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
void Monicelli_putDouble(Monicelli_Double value) {
|
2015-03-08 12:34:51 +01:00
|
|
|
printf("%lg\n", value);
|
2015-03-07 14:12:18 +01:00
|
|
|
}
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
Monicelli_Bool Monicelli_getBool() {
|
|
|
|
Monicelli_Bool tmp;
|
2015-03-07 14:12:18 +01:00
|
|
|
printf("%s", "? ");
|
|
|
|
scanf("%c", &tmp);
|
|
|
|
return tmp != 0? 1: 0;
|
|
|
|
}
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
Monicelli_Char Monicelli_getChar() {
|
|
|
|
Monicelli_Char tmp;
|
2015-03-07 14:12:18 +01:00
|
|
|
printf("%s", "? ");
|
|
|
|
scanf("%c", &tmp);
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
Monicelli_Int Monicelli_getInt() {
|
|
|
|
Monicelli_Int tmp;
|
2015-03-07 14:12:18 +01:00
|
|
|
printf("%s", "? ");
|
|
|
|
scanf("%ld", &tmp);
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
Monicelli_Float Monicelli_getFloat() {
|
|
|
|
Monicelli_Float tmp;
|
2015-03-07 14:12:18 +01:00
|
|
|
printf("%s", "? ");
|
|
|
|
scanf("%f", &tmp);
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
Monicelli_Double Monicelli_getDouble() {
|
|
|
|
Monicelli_Double tmp;
|
2015-03-07 14:12:18 +01:00
|
|
|
printf("%s", "? ");
|
|
|
|
scanf("%lf", &tmp);
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
void Monicelli_abort() {
|
2015-03-07 14:12:18 +01:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2015-03-08 21:37:29 +01:00
|
|
|
void Monicelli_assert(Monicelli_Bool condition) {
|
2015-03-07 14:12:18 +01:00
|
|
|
assert(condition);
|
|
|
|
}
|
|
|
|
|