OSDN Git Service

Merge remote branch 'origin/2.0'
[qt-creator-jp/qt-creator-jp.git] / src / libs / qmljs / qmljsinterpreter.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** Commercial Usage
10 **
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
27 **
28 **************************************************************************/
29
30 #ifndef QMLJS_INTERPRETER_H
31 #define QMLJS_INTERPRETER_H
32
33 #include <qmljs/qmljsdocument.h>
34 #include <qmljs/qmljs_global.h>
35 #include <qmljs/qmljscomponentversion.h>
36 #include <qmljs/parser/qmljsastfwd_p.h>
37
38 #include <QtCore/QFileInfoList>
39 #include <QtCore/QList>
40 #include <QtCore/QString>
41 #include <QtCore/QHash>
42 #include <QtCore/QSet>
43
44 namespace QmlJS {
45
46 class NameId;
47 class Document;
48
49 namespace Interpreter {
50
51 ////////////////////////////////////////////////////////////////////////////////
52 // Forward declarations
53 ////////////////////////////////////////////////////////////////////////////////
54 class Engine;
55 class Value;
56 class NullValue;
57 class UndefinedValue;
58 class NumberValue;
59 class BooleanValue;
60 class StringValue;
61 class ObjectValue;
62 class FunctionValue;
63 class Reference;
64 class ColorValue;
65 class AnchorLineValue;
66
67 typedef QList<const Value *> ValueList;
68
69 class FakeMetaObject;
70 class FakeMetaMethod;
71 class FakeMetaProperty;
72 class FakeMetaEnum;
73
74 ////////////////////////////////////////////////////////////////////////////////
75 // Value visitor
76 ////////////////////////////////////////////////////////////////////////////////
77 class QMLJS_EXPORT ValueVisitor
78 {
79 public:
80     ValueVisitor();
81     virtual ~ValueVisitor();
82
83     virtual void visit(const NullValue *);
84     virtual void visit(const UndefinedValue *);
85     virtual void visit(const NumberValue *);
86     virtual void visit(const BooleanValue *);
87     virtual void visit(const StringValue *);
88     virtual void visit(const ObjectValue *);
89     virtual void visit(const FunctionValue *);
90     virtual void visit(const Reference *);
91     virtual void visit(const ColorValue *);
92     virtual void visit(const AnchorLineValue *);
93 };
94
95 ////////////////////////////////////////////////////////////////////////////////
96 // QML/JS value
97 ////////////////////////////////////////////////////////////////////////////////
98 class QMLJS_EXPORT Value
99 {
100     Value(const Value &other);
101     void operator = (const Value &other);
102
103 public:
104     Value();
105     virtual ~Value();
106
107     virtual const NullValue *asNullValue() const;
108     virtual const UndefinedValue *asUndefinedValue() const;
109     virtual const NumberValue *asNumberValue() const;
110     virtual const BooleanValue *asBooleanValue() const;
111     virtual const StringValue *asStringValue() const;
112     virtual const ObjectValue *asObjectValue() const;
113     virtual const FunctionValue *asFunctionValue() const;
114     virtual const Reference *asReference() const;
115     virtual const ColorValue *asColorValue() const;
116     virtual const AnchorLineValue *asAnchorLineValue() const;
117
118     virtual void accept(ValueVisitor *) const = 0;
119
120     virtual bool getSourceLocation(QString *fileName, int *line, int *column) const;
121 };
122
123 template <typename _RetTy> _RetTy value_cast(const Value *v);
124
125 template <> Q_INLINE_TEMPLATE const NullValue *value_cast(const Value *v)
126 {
127     if (v) return v->asNullValue();
128     else   return 0;
129 }
130
131 template <> Q_INLINE_TEMPLATE const UndefinedValue *value_cast(const Value *v)
132 {
133     if (v) return v->asUndefinedValue();
134     else   return 0;
135 }
136
137 template <> Q_INLINE_TEMPLATE const NumberValue *value_cast(const Value *v)
138 {
139     if (v) return v->asNumberValue();
140     else   return 0;
141 }
142
143 template <> Q_INLINE_TEMPLATE const BooleanValue *value_cast(const Value *v)
144 {
145     if (v) return v->asBooleanValue();
146     else   return 0;
147 }
148
149 template <> Q_INLINE_TEMPLATE const StringValue *value_cast(const Value *v)
150 {
151     if (v) return v->asStringValue();
152     else   return 0;
153 }
154
155 template <> Q_INLINE_TEMPLATE const ObjectValue *value_cast(const Value *v)
156 {
157     if (v) return v->asObjectValue();
158     else   return 0;
159 }
160
161 template <> Q_INLINE_TEMPLATE const FunctionValue *value_cast(const Value *v)
162 {
163     if (v) return v->asFunctionValue();
164     else   return 0;
165 }
166
167 template <> Q_INLINE_TEMPLATE const Reference *value_cast(const Value *v)
168 {
169     if (v) return v->asReference();
170     else   return 0;
171 }
172
173 template <> Q_INLINE_TEMPLATE const ColorValue *value_cast(const Value *v)
174 {
175     if (v) return v->asColorValue();
176     else   return 0;
177 }
178
179 template <> Q_INLINE_TEMPLATE const AnchorLineValue *value_cast(const Value *v)
180 {
181     if (v) return v->asAnchorLineValue();
182     else   return 0;
183 }
184
185 ////////////////////////////////////////////////////////////////////////////////
186 // Value nodes
187 ////////////////////////////////////////////////////////////////////////////////
188 class QMLJS_EXPORT NullValue: public Value
189 {
190 public:
191     virtual const NullValue *asNullValue() const;
192     virtual void accept(ValueVisitor *visitor) const;
193 };
194
195 class QMLJS_EXPORT UndefinedValue: public Value
196 {
197 public:
198     virtual const UndefinedValue *asUndefinedValue() const;
199     virtual void accept(ValueVisitor *visitor) const;
200 };
201
202 class QMLJS_EXPORT NumberValue: public Value
203 {
204 public:
205     virtual const NumberValue *asNumberValue() const;
206     virtual void accept(ValueVisitor *visitor) const;
207 };
208
209 class QMLJS_EXPORT BooleanValue: public Value
210 {
211 public:
212     virtual const BooleanValue *asBooleanValue() const;
213     virtual void accept(ValueVisitor *visitor) const;
214 };
215
216 class QMLJS_EXPORT StringValue: public Value
217 {
218 public:
219     virtual const StringValue *asStringValue() const;
220     virtual void accept(ValueVisitor *visitor) const;
221 };
222
223 class QMLJS_EXPORT MemberProcessor
224 {
225     MemberProcessor(const MemberProcessor &other);
226     void operator = (const MemberProcessor &other);
227
228 public:
229     MemberProcessor();
230     virtual ~MemberProcessor();
231
232     // Returns false to stop the processor.
233     virtual bool processProperty(const QString &name, const Value *value);
234     virtual bool processEnumerator(const QString &name, const Value *value);
235     virtual bool processSignal(const QString &name, const Value *value);
236     virtual bool processSlot(const QString &name, const Value *value);
237     virtual bool processGeneratedSlot(const QString &name, const Value *value);
238 };
239
240 class QMLJS_EXPORT ScopeChain
241 {
242 public:
243     ScopeChain();
244
245     struct QmlComponentChain
246     {
247         QmlComponentChain();
248         ~QmlComponentChain();
249
250         QList<QmlComponentChain *> instantiatingComponents;
251         Document::Ptr document;
252
253         void add(QList<const ObjectValue *> *list) const;
254         void clear();
255     };
256
257     const ObjectValue *globalScope;
258     QmlComponentChain qmlComponentScope;
259     QList<const ObjectValue *> qmlScopeObjects;
260     const ObjectValue *qmlTypes;
261     QList<const ObjectValue *> jsScopes;
262
263     // rebuilds the flat list of all scopes
264     void update();
265     QList<const ObjectValue *> all() const;
266
267 private:
268     QList<const ObjectValue *> _all;
269 };
270
271 class QMLJS_EXPORT Context
272 {
273 public:
274     Context(Engine *engine);
275     ~Context();
276
277     Engine *engine() const;
278     const ScopeChain &scopeChain() const;
279     ScopeChain &scopeChain();
280
281     const ObjectValue *typeEnvironment(const Document *doc) const;
282     void setTypeEnvironment(const Document *doc, const ObjectValue *typeEnvironment);
283
284     const Value *lookup(const QString &name);
285     const ObjectValue *lookupType(const Document *doc, AST::UiQualifiedId *qmlTypeName);
286     const ObjectValue *lookupType(const Document *doc, const QStringList &qmlTypeName);
287     const Value *lookupReference(const Reference *reference);
288
289     const Value *property(const ObjectValue *object, const QString &name) const;
290     void setProperty(const ObjectValue *object, const QString &name, const Value *value);
291
292     QString defaultPropertyName(const ObjectValue *object);
293
294     bool documentImportsPlugins(const Document *doc) const;
295     void setDocumentImportsPlugins(const Document *doc);
296
297 private:
298     typedef QHash<QString, const Value *> Properties;
299
300     Engine *_engine;
301     QHash<const ObjectValue *, Properties> _properties;
302     QHash<QString, const ObjectValue *> _typeEnvironments;
303     QSet<QString> _documentsImportingPlugins;
304     ScopeChain _scopeChain;
305     int _qmlScopeObjectIndex;
306     bool _qmlScopeObjectSet;
307     QList<const Reference *> _referenceStack;
308 };
309
310 class QMLJS_EXPORT Reference: public Value
311 {
312 public:
313     Reference(Engine *engine);
314     virtual ~Reference();
315
316     Engine *engine() const;
317
318     // Value interface
319     virtual const Reference *asReference() const;
320     virtual void accept(ValueVisitor *) const;
321
322 private:
323     virtual const Value *value(Context *context) const;
324
325     Engine *_engine;
326     friend class Context;
327 };
328
329 class QMLJS_EXPORT ColorValue: public Value
330 {
331 public:
332     // Value interface
333     virtual const ColorValue *asColorValue() const;
334     virtual void accept(ValueVisitor *) const;
335 };
336
337 class QMLJS_EXPORT AnchorLineValue: public Value
338 {
339 public:
340     // Value interface
341     virtual const AnchorLineValue *asAnchorLineValue() const;
342     virtual void accept(ValueVisitor *) const;
343 };
344
345 class QMLJS_EXPORT ObjectValue: public Value
346 {
347 public:
348     ObjectValue(Engine *engine);
349     virtual ~ObjectValue();
350
351     Engine *engine() const;
352
353     QString className() const;
354     void setClassName(const QString &className);
355
356     const ObjectValue *prototype(Context *context) const;
357     void setPrototype(const Value *prototype);
358
359     virtual void processMembers(MemberProcessor *processor) const;
360
361     virtual const Value *property(const QString &name, Context *context) const;
362     virtual void setProperty(const QString &name, const Value *value);
363     virtual void removeProperty(const QString &name);
364
365     virtual const Value *lookupMember(const QString &name, Context *context, bool examinePrototypes = true) const;
366
367     // Value interface
368     virtual const ObjectValue *asObjectValue() const;
369     virtual void accept(ValueVisitor *visitor) const;
370
371 private:
372     bool checkPrototype(const ObjectValue *prototype, QSet<const ObjectValue *> *processed) const;
373
374 private:
375     Engine *_engine;
376     const Value *_prototype;
377     QHash<QString, const Value *> _members;
378     QString _className;
379 };
380
381 class QMLJS_EXPORT QmlObjectValue: public ObjectValue
382 {
383 public:
384     QmlObjectValue(const FakeMetaObject *metaObject, Engine *engine);
385     virtual ~QmlObjectValue();
386
387     virtual void processMembers(MemberProcessor *processor) const;
388     const Value *propertyValue(const FakeMetaProperty &prop) const;
389
390     QString packageName() const;
391     ComponentVersion version() const;
392     QString defaultPropertyName() const;
393     QString propertyType(const QString &propertyName) const;
394     bool isListProperty(const QString &name) const;
395     bool isEnum(const QString &typeName) const;
396     bool enumContainsKey(const QString &enumName, const QString &enumKeyName) const;
397     bool hasChildInPackage() const;
398
399 protected:
400     const Value *findOrCreateSignature(int index, const FakeMetaMethod &method, QString *methodName) const;
401     bool isDerivedFrom(const FakeMetaObject *base) const;
402
403 private:
404     const FakeMetaObject *_metaObject;
405     mutable QHash<int, const Value *> _metaSignature;
406 };
407
408 class QMLJS_EXPORT QmlEnumValue: public NumberValue
409 {
410 public:
411     QmlEnumValue(const FakeMetaEnum &metaEnum, Engine *engine);
412     virtual ~QmlEnumValue();
413
414     QString name() const;
415     QStringList keys() const;
416
417 private:
418     FakeMetaEnum *_metaEnum;
419 };
420
421 class QMLJS_EXPORT Activation
422 {
423 public:
424     explicit Activation(Context *parentContext = 0);
425     virtual ~Activation();
426
427     Context *context() const;
428     Context *parentContext() const;
429
430     bool calledAsConstructor() const;
431     void setCalledAsConstructor(bool calledAsConstructor);
432
433     bool calledAsFunction() const;
434     void setCalledAsFunction(bool calledAsFunction);
435
436     ObjectValue *thisObject() const;
437     void setThisObject(ObjectValue *thisObject);
438
439     ValueList arguments() const;
440     void setArguments(const ValueList &arguments);
441
442 private:
443     ObjectValue *_thisObject;
444     ValueList _arguments;
445     bool _calledAsFunction;
446     Context *_parentContext;
447 };
448
449
450 class QMLJS_EXPORT FunctionValue: public ObjectValue
451 {
452 public:
453     FunctionValue(Engine *engine);
454     virtual ~FunctionValue();
455
456     // [[construct]]
457     const Value *construct(const ValueList &actuals = ValueList()) const;
458
459     // [[call]]
460     const Value *call(const ValueList &actuals = ValueList()) const;
461
462     const Value *call(const ObjectValue *thisObject,
463                       const ValueList &actuals = ValueList()) const;
464
465
466     virtual const Value *returnValue() const;
467
468     virtual int argumentCount() const;
469     virtual const Value *argument(int index) const;
470     virtual QString argumentName(int index) const;
471     virtual bool isVariadic() const;
472
473     virtual const Value *invoke(const Activation *activation) const;
474
475     // Value interface
476     virtual const FunctionValue *asFunctionValue() const;
477     virtual void accept(ValueVisitor *visitor) const;
478 };
479
480 class QMLJS_EXPORT Function: public FunctionValue
481 {
482 public:
483     Function(Engine *engine);
484     virtual ~Function();
485
486     void addArgument(const Value *argument);
487     void setReturnValue(const Value *returnValue);
488
489     // ObjectValue interface
490     virtual const Value *property(const QString &name, Context *context) const;
491
492     // FunctionValue interface
493     virtual const Value *returnValue() const;
494     virtual int argumentCount() const;
495     virtual const Value *argument(int index) const;
496     virtual const Value *invoke(const Activation *activation) const;
497
498 private:
499     ValueList _arguments;
500     const Value *_returnValue;
501 };
502
503
504 ////////////////////////////////////////////////////////////////////////////////
505 // typing environment
506 ////////////////////////////////////////////////////////////////////////////////
507
508 class QMLJS_EXPORT CppQmlTypesLoader
509 {
510 public:
511     /** \return an empty list when successful, error messages otherwise. */
512     static QStringList load(const QFileInfoList &xmlFiles);
513     static QList<const FakeMetaObject *> builtinObjects;
514
515     // parses the xml string and fills the newObjects map
516     static QString parseQmlTypeXml(const QByteArray &xml, QMap<QString, FakeMetaObject *> *newObjects);
517 private:
518     static void setSuperClasses(QMap<QString, FakeMetaObject *> *newObjects);
519 };
520
521 class QMLJS_EXPORT CppQmlTypes
522 {
523 public:
524     void load(Interpreter::Engine *interpreter, const QList<const FakeMetaObject *> &objects);
525
526     QList<Interpreter::QmlObjectValue *> typesForImport(const QString &prefix, ComponentVersion version) const;
527     Interpreter::QmlObjectValue *typeForImport(const QString &qualifiedName) const;
528
529     bool hasPackage(const QString &package) const;
530
531     QHash<QString, QmlObjectValue *> types() const
532     { return _typesByFullyQualifiedName; }
533
534 private:
535     QHash<QString, QList<QmlObjectValue *> > _typesByPackage;
536     QHash<QString, QmlObjectValue *> _typesByFullyQualifiedName;
537 };
538
539 class ConvertToNumber: protected ValueVisitor // ECMAScript ToInt()
540 {
541 public:
542     ConvertToNumber(Engine *engine);
543
544     const Value *operator()(const Value *value);
545
546 protected:
547     const Value *switchResult(const Value *value);
548
549     virtual void visit(const NullValue *);
550     virtual void visit(const UndefinedValue *);
551     virtual void visit(const NumberValue *);
552     virtual void visit(const BooleanValue *);
553     virtual void visit(const StringValue *);
554     virtual void visit(const ObjectValue *);
555     virtual void visit(const FunctionValue *);
556
557 private:
558     Engine *_engine;
559     const Value *_result;
560 };
561
562 class ConvertToString: protected ValueVisitor // ECMAScript ToString
563 {
564 public:
565     ConvertToString(Engine *engine);
566
567     const Value *operator()(const Value *value);
568
569 protected:
570     const Value *switchResult(const Value *value);
571
572     virtual void visit(const NullValue *);
573     virtual void visit(const UndefinedValue *);
574     virtual void visit(const NumberValue *);
575     virtual void visit(const BooleanValue *);
576     virtual void visit(const StringValue *);
577     virtual void visit(const ObjectValue *);
578     virtual void visit(const FunctionValue *);
579
580 private:
581     Engine *_engine;
582     const Value *_result;
583 };
584
585 class ConvertToObject: protected ValueVisitor // ECMAScript ToObject
586 {
587 public:
588     ConvertToObject(Engine *engine);
589
590     const Value *operator()(const Value *value);
591
592 protected:
593     const Value *switchResult(const Value *value);
594
595     virtual void visit(const NullValue *);
596     virtual void visit(const UndefinedValue *);
597     virtual void visit(const NumberValue *);
598     virtual void visit(const BooleanValue *);
599     virtual void visit(const StringValue *);
600     virtual void visit(const ObjectValue *);
601     virtual void visit(const FunctionValue *);
602
603 private:
604     Engine *_engine;
605     const Value *_result;
606 };
607
608 class TypeId: protected ValueVisitor
609 {
610     QString _result;
611
612 public:
613     QString operator()(const Value *value);
614
615 protected:
616     virtual void visit(const NullValue *);
617     virtual void visit(const UndefinedValue *);
618     virtual void visit(const NumberValue *);
619     virtual void visit(const BooleanValue *);
620     virtual void visit(const StringValue *);
621     virtual void visit(const ObjectValue *object);
622     virtual void visit(const FunctionValue *object);
623     virtual void visit(const ColorValue *);
624     virtual void visit(const AnchorLineValue *);
625 };
626
627 class QMLJS_EXPORT Engine
628 {
629     Engine(const Engine &other);
630     void operator = (const Engine &other);
631
632 public:
633     Engine();
634     ~Engine();
635
636     const NullValue *nullValue() const;
637     const UndefinedValue *undefinedValue() const;
638     const NumberValue *numberValue() const;
639     const BooleanValue *booleanValue() const;
640     const StringValue *stringValue() const;
641     const ColorValue *colorValue() const;
642     const AnchorLineValue *anchorLineValue() const;
643
644     ObjectValue *newObject(const ObjectValue *prototype);
645     ObjectValue *newObject();
646     Function *newFunction();
647     const Value *newArray(); // ### remove me
648
649     // QML objects
650     const ObjectValue *qmlKeysObject();
651     const Value *defaultValueForBuiltinType(const QString &typeName) const;
652
653     // global object
654     ObjectValue *globalObject() const;
655     const ObjectValue *mathObject() const;
656     const ObjectValue *qtObject() const;
657
658     // prototypes
659     ObjectValue *objectPrototype() const;
660     ObjectValue *functionPrototype() const;
661     ObjectValue *numberPrototype() const;
662     ObjectValue *booleanPrototype() const;
663     ObjectValue *stringPrototype() const;
664     ObjectValue *arrayPrototype() const;
665     ObjectValue *datePrototype() const;
666     ObjectValue *regexpPrototype() const;
667
668     // ctors
669     const FunctionValue *objectCtor() const;
670     const FunctionValue *functionCtor() const;
671     const FunctionValue *arrayCtor() const;
672     const FunctionValue *stringCtor() const;
673     const FunctionValue *booleanCtor() const;
674     const FunctionValue *numberCtor() const;
675     const FunctionValue *dateCtor() const;
676     const FunctionValue *regexpCtor() const;
677
678     // operators
679     const Value *convertToBoolean(const Value *value);
680     const Value *convertToNumber(const Value *value);
681     const Value *convertToString(const Value *value);
682     const Value *convertToObject(const Value *value);
683     QString typeId(const Value *value);
684
685     // typing:
686     CppQmlTypes &cppQmlTypes()
687     { return _cppQmlTypes; }
688     const CppQmlTypes &cppQmlTypes() const
689     { return _cppQmlTypes; }
690
691     void registerValue(Value *value); // internal
692
693 private:
694     void initializePrototypes();
695
696     void addFunction(ObjectValue *object, const QString &name, const Value *result, int argumentCount);
697     void addFunction(ObjectValue *object, const QString &name, int argumentCount);
698
699 private:
700     ObjectValue *_objectPrototype;
701     ObjectValue *_functionPrototype;
702     ObjectValue *_numberPrototype;
703     ObjectValue *_booleanPrototype;
704     ObjectValue *_stringPrototype;
705     ObjectValue *_arrayPrototype;
706     ObjectValue *_datePrototype;
707     ObjectValue *_regexpPrototype;
708
709     Function *_objectCtor;
710     Function *_functionCtor;
711     Function *_arrayCtor;
712     Function *_stringCtor;
713     Function *_booleanCtor;
714     Function *_numberCtor;
715     Function *_dateCtor;
716     Function *_regexpCtor;
717
718     ObjectValue *_globalObject;
719     ObjectValue *_mathObject;
720     ObjectValue *_qtObject;
721     ObjectValue *_qmlKeysObject;
722
723     NullValue _nullValue;
724     UndefinedValue _undefinedValue;
725     NumberValue _numberValue;
726     BooleanValue _booleanValue;
727     StringValue _stringValue;
728     ColorValue _colorValue;
729     AnchorLineValue _anchorLineValue;
730     QList<Value *> _registeredValues;
731
732     ConvertToNumber _convertToNumber;
733     ConvertToString _convertToString;
734     ConvertToObject _convertToObject;
735     TypeId _typeId;
736
737     CppQmlTypes _cppQmlTypes;
738 };
739
740
741 // internal
742 class QMLJS_EXPORT QmlPrototypeReference: public Reference
743 {
744 public:
745     QmlPrototypeReference(AST::UiQualifiedId *qmlTypeName, const Document *doc, Engine *engine);
746     virtual ~QmlPrototypeReference();
747
748     AST::UiQualifiedId *qmlTypeName() const;
749
750 private:    
751     virtual const Value *value(Context *context) const;
752
753     AST::UiQualifiedId *_qmlTypeName;
754     const Document *_doc;
755 };
756
757 class QMLJS_EXPORT ASTVariableReference: public Reference
758 {
759     AST::VariableDeclaration *_ast;
760
761 public:
762     ASTVariableReference(AST::VariableDeclaration *ast, Engine *engine);
763     virtual ~ASTVariableReference();
764
765 private:
766     virtual const Value *value(Context *context) const;
767 };
768
769 class QMLJS_EXPORT ASTFunctionValue: public FunctionValue
770 {
771     AST::FunctionDeclaration *_ast;
772     QList<NameId *> _argumentNames;
773
774 public:
775     ASTFunctionValue(AST::FunctionDeclaration *ast, Engine *engine);
776     virtual ~ASTFunctionValue();
777
778     AST::FunctionDeclaration *ast() const;
779
780     virtual const Value *returnValue() const;
781     virtual int argumentCount() const;
782     virtual const Value *argument(int) const;
783     virtual QString argumentName(int index) const;
784     virtual bool isVariadic() const;
785 };
786
787 class QMLJS_EXPORT ASTPropertyReference: public Reference
788 {
789     AST::UiPublicMember *_ast;
790     const Document *_doc;
791     QString _onChangedSlotName;
792
793 public:
794     ASTPropertyReference(AST::UiPublicMember *ast, const Document *doc, Engine *engine);
795     virtual ~ASTPropertyReference();
796
797     AST::UiPublicMember *ast() const { return _ast; }
798     QString onChangedSlotName() const { return _onChangedSlotName; }
799
800     virtual bool getSourceLocation(QString *fileName, int *line, int *column) const;
801
802 private:
803     virtual const Value *value(Context *context) const;
804 };
805
806 class QMLJS_EXPORT ASTSignalReference: public Reference
807 {
808     AST::UiPublicMember *_ast;
809     const Document *_doc;
810     QString _slotName;
811
812 public:
813     ASTSignalReference(AST::UiPublicMember *ast, const Document *doc, Engine *engine);
814     virtual ~ASTSignalReference();
815
816     AST::UiPublicMember *ast() const { return _ast; }
817     QString slotName() const { return _slotName; }
818
819     virtual bool getSourceLocation(QString *fileName, int *line, int *column) const;
820
821 private:
822     virtual const Value *value(Context *context) const;
823 };
824
825 class QMLJS_EXPORT ASTObjectValue: public ObjectValue
826 {
827     AST::UiQualifiedId *_typeName;
828     AST::UiObjectInitializer *_initializer;
829     const Document *_doc;
830     QList<ASTPropertyReference *> _properties;
831     QList<ASTSignalReference *> _signals;
832     ASTPropertyReference *_defaultPropertyRef;
833
834 public:
835     ASTObjectValue(AST::UiQualifiedId *typeName,
836                    AST::UiObjectInitializer *initializer,
837                    const Document *doc,
838                    Engine *engine);
839     virtual ~ASTObjectValue();
840
841     bool getSourceLocation(QString *fileName, int *line, int *column) const;
842     virtual void processMembers(MemberProcessor *processor) const;
843
844     QString defaultPropertyName() const;
845 };
846
847 } } // end of namespace QmlJS::Interpreter
848
849 #endif // QMLJS_INTERPRETER_H