/*
* myLib.cc
*
* Created on: Mar 17, 2010
* Author: matthew
*/
#include <string>
#include <vector>
#include "myLib.h"
void show_report(vector<message> &msg)
{
cout<<endl<<"COMPILING REPORT:"<<endl;
cout<<"--------------------------------------------------------------------"<<endl;
if(msg.size()==0)
cout<<"Compiled successfully!"<<endl;
for(int a=0; a<msg.size(); a++)
{
cout<<"ERROR at line "<<msg[a].line<<": "<<msg[a].text<<endl;
}
cout<<"--------------------------------------------------------------------"<<endl;
}
void debug_message(string msg)
{
cout<<"[Debug Message] "<<msg<<endl;
}
void error(string msg)
{
cout<<"[Fatal Error] "<<msg<<endl;
}
void c_error(vector<message> &report, int line, string text)
{
message msg;
msg.line=line;
msg.text=text;
report.push_back(msg);
}
int bit_4(int source, int dest)
{
if(dest/128==source/128)
{
return 1;
}
else if(dest/128==0)
{
return 0;
}
else
{
return -1;
}
}
string binary(int dec)
{
string res;
while(dec>0)
{
if(dec%2==1)res.insert(res.begin(),'1');
else res.insert(res.begin(),'0');
dec/=2;
}
while(res.size()<7)
{
res.insert(res.begin(),'0');
}
return res;
}