Advertisement

Variable type identification

Started by January 17, 2011 02:10 PM
1 comment, last by SiCrane 13 years, 10 months ago
Is there any way to determine variable type only by variable name (for example GetVarDeclByVarName(const char* var_name) or GetVarTypeIdByVarName(const char* var_name)? I'm implementing IDE for AngelScript and this functionality would be very helpful for me to write autocompletion and intellisense-like mechanisms.
Unfortunately not. You have to enumerate the variables to find the right one. Use GetVarCount and GetVar for that. Remember that multiple variables in a function may use the same name if they have different scope.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
You need some sort of context for the the variable in order to get it's properties. For instance, if it's a module variable you can use asIScriptModule::GetGlobalVarIndexByName() to get the variable index and then asIScriptModule::GetGlobalVar() to get its type. Similarly there's asIObjectType::GetProperty() to get the information about a property's type and asIScriptFunction::GetVar() to get the type of a function's local variables.

This topic is closed to new replies.

Advertisement