More VM callable functions
This commit is contained in:
parent
14991cba5f
commit
4e1ea552f1
@ -36,19 +36,16 @@ namespace pim
|
|||||||
void Generator::writeOpcode(int opcode)
|
void Generator::writeOpcode(int opcode)
|
||||||
{
|
{
|
||||||
programCounter++;
|
programCounter++;
|
||||||
printf("Opcode: %d\n", opcode);
|
|
||||||
program.push_back(opcode);
|
program.push_back(opcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Generator::writeConstant(std::string constant)
|
void Generator::writeConstant(std::string constant)
|
||||||
{
|
{
|
||||||
printf("Constant: %s\n", constant.c_str());
|
|
||||||
writeConstant(format::StringToNumber<int>(constant));
|
writeConstant(format::StringToNumber<int>(constant));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Generator::writeConstant(int constant)
|
void Generator::writeConstant(int constant)
|
||||||
{
|
{
|
||||||
printf("Constant: %d\n", constant);
|
|
||||||
program.push_back(constant & 0xFF);
|
program.push_back(constant & 0xFF);
|
||||||
program.push_back((constant>>8) & 0xFF);
|
program.push_back((constant>>8) & 0xFF);
|
||||||
program.push_back((constant>>16) & 0xFF);
|
program.push_back((constant>>16) & 0xFF);
|
||||||
@ -57,7 +54,6 @@ namespace pim
|
|||||||
|
|
||||||
void Generator::writeConstantPlaceholderOffset(int value, int * offset)
|
void Generator::writeConstantPlaceholderOffset(int value, int * offset)
|
||||||
{
|
{
|
||||||
printf("Constant: %d\n", value);
|
|
||||||
valueOffsetPlaceholders.push_back(ValueOffsetPlaceholder(program.size(), std::pair<int, int*>(value, offset)));
|
valueOffsetPlaceholders.push_back(ValueOffsetPlaceholder(program.size(), std::pair<int, int*>(value, offset)));
|
||||||
program.push_back(0);
|
program.push_back(0);
|
||||||
program.push_back(0);
|
program.push_back(0);
|
||||||
@ -67,7 +63,6 @@ namespace pim
|
|||||||
|
|
||||||
void Generator::writeConstantPlaceholder(std::string label)
|
void Generator::writeConstantPlaceholder(std::string label)
|
||||||
{
|
{
|
||||||
printf("Constant: %s\n", label.c_str());
|
|
||||||
placeholders.push_back(Placeholder(program.size(), label));
|
placeholders.push_back(Placeholder(program.size(), label));
|
||||||
program.push_back(0);
|
program.push_back(0);
|
||||||
program.push_back(0);
|
program.push_back(0);
|
||||||
@ -77,7 +72,6 @@ namespace pim
|
|||||||
|
|
||||||
void Generator::writeConstantPlaceholder(int * value)
|
void Generator::writeConstantPlaceholder(int * value)
|
||||||
{
|
{
|
||||||
printf("Constant: %p\n", value);
|
|
||||||
valuePlaceholders.push_back(ValuePlaceholder(program.size(), value));
|
valuePlaceholders.push_back(ValuePlaceholder(program.size(), value));
|
||||||
program.push_back(0);
|
program.push_back(0);
|
||||||
program.push_back(0);
|
program.push_back(0);
|
||||||
@ -87,7 +81,6 @@ namespace pim
|
|||||||
|
|
||||||
void Generator::writeConstantPropertyPlaceholder(std::string property)
|
void Generator::writeConstantPropertyPlaceholder(std::string property)
|
||||||
{
|
{
|
||||||
printf("Constant: %s\n", property.c_str());
|
|
||||||
propertyPlaceholders.push_back(PropertyPlaceholder(program.size(), property));
|
propertyPlaceholders.push_back(PropertyPlaceholder(program.size(), property));
|
||||||
program.push_back(0);
|
program.push_back(0);
|
||||||
program.push_back(0);
|
program.push_back(0);
|
||||||
@ -97,7 +90,6 @@ namespace pim
|
|||||||
|
|
||||||
void Generator::writeConstantMacroPlaceholder(std::string macro)
|
void Generator::writeConstantMacroPlaceholder(std::string macro)
|
||||||
{
|
{
|
||||||
printf("Constant: %s\n", macro.c_str());
|
|
||||||
macroPlaceholders.push_back(MacroPlaceholder(program.size(), macro));
|
macroPlaceholders.push_back(MacroPlaceholder(program.size(), macro));
|
||||||
program.push_back(0);
|
program.push_back(0);
|
||||||
program.push_back(0);
|
program.push_back(0);
|
||||||
@ -710,6 +702,7 @@ namespace pim
|
|||||||
{
|
{
|
||||||
popType(1);
|
popType(1);
|
||||||
writeOpcode(Opcode::Kill);
|
writeOpcode(Opcode::Kill);
|
||||||
|
pushType(DataType::Integer);
|
||||||
|
|
||||||
output << "kill" << std::endl;
|
output << "kill" << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ namespace pim
|
|||||||
tempInt |= programData[programPosition+3] << 24;
|
tempInt |= programData[programPosition+3] << 24;
|
||||||
|
|
||||||
|
|
||||||
std::cout << "Got integer " << tempInt << std::endl;
|
//std::cout << "Got integer " << tempInt << std::endl;
|
||||||
|
|
||||||
if(instruction.Opcode == Opcode::LoadProperty || instruction.Opcode == Opcode::StoreProperty)
|
if(instruction.Opcode == Opcode::LoadProperty || instruction.Opcode == Opcode::StoreProperty)
|
||||||
{
|
{
|
||||||
|
@ -406,10 +406,6 @@ namespace pim
|
|||||||
|
|
||||||
generator->ScopeLabel(loopLabel+"Next");
|
generator->ScopeLabel(loopLabel+"Next");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Check X
|
//Check X
|
||||||
generator->LoadVariable(xVar);
|
generator->LoadVariable(xVar);
|
||||||
generator->LoadVariable(xMax);
|
generator->LoadVariable(xMax);
|
||||||
@ -643,7 +639,11 @@ namespace pim
|
|||||||
void Parser::variableValue()
|
void Parser::variableValue()
|
||||||
{
|
{
|
||||||
std::string variable = token.Source;
|
std::string variable = token.Source;
|
||||||
if(accept(Token::Identifier))
|
if(look(Token::CreateSymbol) || look(Token::KillSymbol) || look(Token::GetSymbol) || look(Token::TransformSymbol))
|
||||||
|
{
|
||||||
|
particleAction();
|
||||||
|
}
|
||||||
|
else if(accept(Token::Identifier))
|
||||||
{
|
{
|
||||||
if(look(Token::LeftBracket))
|
if(look(Token::LeftBracket))
|
||||||
{
|
{
|
||||||
@ -669,10 +669,6 @@ namespace pim
|
|||||||
{
|
{
|
||||||
generator->RTConstant(variable);
|
generator->RTConstant(variable);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
particleAction();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::accept(int symbol)
|
bool Parser::accept(int symbol)
|
||||||
|
@ -186,8 +186,10 @@ namespace pim
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Opcode::Kill:
|
case Opcode::Kill:
|
||||||
//sim->kill_part(PSPop().Integer);
|
emit("8B 06"); //mov eax, [esi]
|
||||||
//PSPush((Word)0);
|
emit("50"); //push eax
|
||||||
|
emitCall((intptr_t)sim, (intptr_t)((void*)&Simulation::kill_part), 4);
|
||||||
|
emit("C7 06 00 00 00 00"); //mov [esi], eax
|
||||||
break;
|
break;
|
||||||
case Opcode::LoadProperty:
|
case Opcode::LoadProperty:
|
||||||
{
|
{
|
||||||
|
@ -140,7 +140,7 @@ public:
|
|||||||
void init_can_move();
|
void init_can_move();
|
||||||
void create_cherenkov_photon(int pp);
|
void create_cherenkov_photon(int pp);
|
||||||
void create_gain_photon(int pp);
|
void create_gain_photon(int pp);
|
||||||
TPT_NO_INLINE void kill_part(int i);
|
TPT_NO_INLINE TPT_VM_CALLABLE void kill_part(int i);
|
||||||
int flood_prop(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype);
|
int flood_prop(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype);
|
||||||
int flood_prop_2(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype, int parttype, char * bitmap);
|
int flood_prop_2(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype, int parttype, char * bitmap);
|
||||||
int flood_water(int x, int y, int i, int originaly, int check);
|
int flood_water(int x, int y, int i, int originaly, int check);
|
||||||
|
Reference in New Issue
Block a user