/* ----------------------------------------------------------------------------- GSFramework Copyright 2001-2013 Emmanuel Julien. All Rights Reserved. ----------------------------------------------------------------------------- */ #ifndef __NSQUIRRELANALYZER__ #define __NSQUIRRELANALYZER__ #include "memory/nshared_ptr.h" #include "memory/nweak_ptr.h" #include "container/nlist.h" #include "nstring/nstring.h" namespace GS { namespace SquirrelAnalyzer { struct Offset { int line, column; Offset(int l = 0, int c = 0) : line(l), column(c) {} }; struct Symbol : public SharedObject { enum Type { TypeNone, TypeVariable, TypeFunction, TypeClass }; String name; Type type; Offset offset; Symbol() : type(TypeNone) {} }; struct Variable : public Symbol { enum VarType { VarNone, VarLocal, VarGlobal, VarMember, VarEnum }; VarType var_type; Variable() : var_type(VarNone) { type = TypeVariable; } }; struct Function : public Symbol { SharedList symbols; String prototype; Function() { type = TypeFunction; } }; struct Class : public Symbol { String extends; SharedList symbols; Class() { type = TypeClass; } }; struct Source { String name; SharedList symbols; }; struct SourceSymbol { SharedPtr source; SharedPtr symbol; }; struct Program { AutoList sources; bool FindSymbol(const char *name, AutoList &symbols); }; void DumpProgram(const Program &); /// Analyze a source, store result in program object. Source *Analyze(const char *nut, Program &, bool replace = true); } // SquirrelAnalyser } // GS #endif // __NSQUIRRELANALYZER__