├── .classpath
├── .gitignore
├── .project
├── .settings
├── org.eclipse.core.resources.prefs
└── org.eclipse.jdt.core.prefs
├── LICENSE
├── README.md
├── docs
├── Rule定义.txt
├── VB 加法.PNG
├── VisualBasic6.g4.bad
└── 工作簿1.xlsx
├── lib
├── antlr-4.5.3-complete.jar
├── commons-collections-3.2.1.jar
├── commons-io-2.4.jar
├── commons-lang3-3.1.jar
├── commons-logging-1.1.3.jar
└── log4j-1.2.17.jar
├── src
├── ExecuteVb.java
├── ShowTree.java
├── Test.java
├── Vba.g4
├── VbaMacro.g4
├── org
│ └── siphon
│ │ └── visualbasic
│ │ ├── ArgumentException.java
│ │ ├── ArgumentMode.java
│ │ ├── Callback.java
│ │ ├── ClassModuleDecl.java
│ │ ├── ClassTypeDecl.java
│ │ ├── ConstDecl.java
│ │ ├── ControlArray.java
│ │ ├── ControlDef.java
│ │ ├── EnumDecl.java
│ │ ├── EventDecl.java
│ │ ├── FormModuleDecl.java
│ │ ├── Interpreter.java
│ │ ├── Library.java
│ │ ├── MeDecl.java
│ │ ├── MethodDecl.java
│ │ ├── MethodType.java
│ │ ├── ModuleDecl.java
│ │ ├── ModuleMemberDecl.java
│ │ ├── ModuleType.java
│ │ ├── NumberRange.java
│ │ ├── OverflowException.java
│ │ ├── Project.java
│ │ ├── ProjectReference.java
│ │ ├── PropertyDecl.java
│ │ ├── RuleDecl.java
│ │ ├── SourceLocation.java
│ │ ├── TheClass.java
│ │ ├── UdtDecl.java
│ │ ├── UnspportedActiveXReferenceException.java
│ │ ├── VarDecl.java
│ │ ├── VbDecl.java
│ │ ├── VbTypeDecl.java
│ │ ├── Visibility.java
│ │ ├── compile
│ │ ├── AmbiguousIdentifierException.java
│ │ ├── AutoMergeMap.java
│ │ ├── BlockCompiler.java
│ │ ├── CompileException.java
│ │ ├── Compiler.java
│ │ ├── ImplementorClassModuleDecl.java
│ │ ├── ImpossibleException.java
│ │ ├── JavaClassModuleDecl.java
│ │ ├── JavaEventDecl.java
│ │ ├── JavaMethod.java
│ │ ├── JavaModuleDecl.java
│ │ ├── NameIndex.java
│ │ ├── NamedArgument.java
│ │ ├── NotFoundException.java
│ │ ├── NotMatchException.java
│ │ ├── ValueStatementCompiler.java
│ │ ├── ValueStatementDesc.java
│ │ ├── VbErrorsException.java
│ │ └── VbFixedStringType.java
│ │ └── runtime
│ │ ├── ArgumentDecl.java
│ │ ├── ArrayDef.java
│ │ ├── CallFrame.java
│ │ ├── Comparision.java
│ │ ├── Debugger.java
│ │ ├── DebuggerAction.java
│ │ ├── DivByZeroException.java
│ │ ├── ErrObject.java
│ │ ├── EventSubscriber.java
│ │ ├── JavaModuleInstance.java
│ │ ├── LogicalExpr.java
│ │ ├── MathExpr.java
│ │ ├── ModuleInstance.java
│ │ ├── NullValueException.java
│ │ ├── RuntimeLibrary.java
│ │ ├── Statement.java
│ │ ├── StringExpr.java
│ │ ├── UdtInstance.java
│ │ ├── VarOwner.java
│ │ ├── VbArray.java
│ │ ├── VbBoundObject.java
│ │ ├── VbEventHandler.java
│ │ ├── VbRuntimeException.java
│ │ ├── VbValue.java
│ │ ├── VbVarType.java
│ │ ├── VbVariable.java
│ │ ├── framework
│ │ ├── Debug.java
│ │ ├── Enums.java
│ │ ├── VbEvent.java
│ │ ├── VbMethod.java
│ │ ├── VbParam.java
│ │ ├── stdole
│ │ │ ├── StdFont.java
│ │ │ └── StdOleLibrary.java
│ │ ├── vb
│ │ │ ├── CommandButton.java
│ │ │ ├── Control.java
│ │ │ ├── Form.java
│ │ │ ├── Frame.java
│ │ │ ├── TextBox.java
│ │ │ └── VBLibrary.java
│ │ └── vba
│ │ │ ├── Collection.java
│ │ │ ├── Constants.java
│ │ │ ├── Conversion.java
│ │ │ ├── DateTime.java
│ │ │ ├── Information.java
│ │ │ ├── Interaction.java
│ │ │ ├── Math.java
│ │ │ ├── Strings.java
│ │ │ └── VBALibrary.java
│ │ ├── interaction
│ │ ├── JavaArrayIterator.java
│ │ └── VbValueIterator.java
│ │ └── statements
│ │ ├── AssignStatement.java
│ │ ├── BinaryStatement.java
│ │ ├── CalcStatements.java
│ │ ├── CompareStatements.java
│ │ ├── EvalAssignableObject.java
│ │ ├── EvalAssignableStatement.java
│ │ ├── ExitMethodStatement.java
│ │ ├── ForEachStatement.java
│ │ ├── ForNextStatement.java
│ │ ├── GoSubStatement.java
│ │ ├── GotoStatement.java
│ │ ├── IfNotGotoStatement.java
│ │ ├── InitLibraryStatement.java
│ │ ├── IsStatement.java
│ │ ├── LiteralStatement.java
│ │ ├── LoadLibraryStatement.java
│ │ ├── LogicalStatements.java
│ │ ├── MidStatment.java
│ │ ├── NamedArgumentStatement.java
│ │ ├── NewStatement.java
│ │ ├── OnErrorStatement.java
│ │ ├── PrintStatement.java
│ │ ├── RaiseEventStatement.java
│ │ ├── RedimStatement.java
│ │ ├── ResumeStatement.java
│ │ ├── ReturnStatement.java
│ │ ├── SelectCaseConditionStatement.java
│ │ ├── SelectCaseStatement.java
│ │ ├── ShowFormStatement.java
│ │ ├── StopStatement.java
│ │ ├── TypeOfIsStatement.java
│ │ ├── UndeterminedLabelGotoStatement.java
│ │ ├── VariableStatement.java
│ │ └── WithStatement.java
├── vba.tokens
├── vba
│ ├── Vba.tokens
│ ├── VbaBaseListener.java
│ ├── VbaLexer.java
│ ├── VbaLexer.tokens
│ ├── VbaListener.java
│ └── VbaParser.java
└── vbaLexer.tokens
├── target
└── generated-sources
│ └── antlr4
│ └── .gitignore
├── test
└── test
│ ├── Dragon.java
│ ├── JavaReflection.java
│ ├── LangTest.java
│ ├── Sprite.java
│ └── TypesTest.java
└── vba
├── .gitignore
├── AddTest
├── AddTest.vbp
└── Module1.bas
├── Calculator
├── Calc.vbp
├── Form1.frm
├── calc_mac.png
├── calc_win.png
└── vb_calc_win.png
├── CallTest
├── CallTest.vbp
├── CallTest.vbw
├── Class1.cls
└── Module1.bas
├── Class1.cls
├── ClassTest
├── Class1.cls
├── ClassTest.vbp
├── ClassTest.vbw
└── Module1.bas
├── CollectionTest
├── CollectionTest.vbp
├── CollectionTest.vbw
└── Module1.bas
├── CompareTest
├── CompareTest.vbp
└── Module1.bas
├── ConstByRef
├── Module1.bas
└── Test.vbp
├── ControlArray
├── Form1.frm
└── Test.vbp
├── CreateObject
├── Module1.bas
└── Test.vbp
├── CurrencyTest
├── CurrencyTest.vbp
└── Module1.bas
├── CustomCollection
├── ButtonArray.cls
├── Form1.frm
├── MyButton.cls
└── 工程1.vbp
├── DefaultProperty
├── Class1.cls
├── Form1.frm
└── 工程1.vbp
├── DivTest
├── DivTest.vbp
└── Module1.bas
├── ErrHandle
├── ErrHandle.vbp
└── Module1.bas
├── EventTest
├── Class1.cls
├── Class2.cls
├── EventTest.vbp
└── Module1.bas
├── Form1
├── Form1.frm
└── Proj.vbp
├── FormFromSubMain
├── Form1.frm
├── Module1.bas
└── Test.vbp
├── FormTwoControls
├── 2controls.jpg
├── Form1.frm
└── Test.vbp
├── Frame
├── Form1.frm
└── Test.vbp
├── IDivMod
├── DivTest.vbw
├── IDivModTest.vbp
├── IDivModTest.vbw
└── Module1.bas
├── Implements
├── Dragon.cls
├── Module1.bas
├── SaveLoadable.cls
├── Sprite.cls
├── Test.vbp
└── Test.vbw
├── Interactive
├── Module1.bas
└── Test.vbp
├── LikeTest
├── LikeTest.vbp
└── Module1.bas
├── LogicOp
├── LogicOp.vbp
└── Module1.bas
├── Mid
├── Module1.bas
└── Test.vbp
├── MissingTest
├── MissingTest.vbp
├── MissingTest.vbw
└── Module1.bas
├── MultiTest
├── Module1.bas
└── MultiTest.vbp
├── NewMacros.bas
├── PosNegTest
├── Module1.bas
├── PosNegTest.vbp
└── PosNegTest.vbw
├── Prj1
├── MathOp.cls
├── Module1.bas
├── Prj1.vbp
└── Prj1.vbw
├── PropertyTest
├── Module1.bas
├── Person.cls
└── PropertyTest.vbp
├── Random
├── Module1.bas
└── Test.vbp
├── RedimTest
├── Module1.bas
└── RedimTest.vbp
├── RuleTest
├── Module1.bas
├── RuleTest.vbp
└── RuleTest.vbw
├── SubtractTest
├── Module1.bas
└── SubtractTest.vbp
├── array-dim.bas
├── array-redim.bas
├── base-type.bas
├── call.bas
├── call_test.bas
├── class-test.bas
├── const-enum.bas
├── decls.bas
├── do-while.bas
├── every_call
├── MOp.cls
└── test.bas
├── for-next.bas
├── func-call.bas
├── gosub.bas
├── goto.bas
├── if-then-else.bas
├── select-case.bas
├── test.bas
└── udt.bas
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/
2 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | vba-interpreter
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.xtext.ui.shared.xtextBuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.xtext.ui.shared.xtextNature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//docs/Rule\u5B9A\u4E49.txt=gbk
3 | encoding//vba/AddTest/Module1.bas=gbk
4 | encoding//vba/CallTest/Module1.bas=gbk
5 | encoding//vba/CollectionTest/Module1.bas=gbk
6 | encoding//vba/CompareTest/Module1.bas=gbk
7 | encoding//vba/ConstByRef/Module1.bas=gbk
8 | encoding//vba/CurrencyTest/Module1.bas=gbk
9 | encoding//vba/DivTest/Module1.bas=gbk
10 | encoding//vba/Form1/Form1.frm=gbk
11 | encoding//vba/Form1/Proj.vbp=gbk
12 | encoding//vba/FormFromSubMain/Form1.frm=gbk
13 | encoding//vba/FormFromSubMain/Module1.bas=gbk
14 | encoding//vba/IDivMod/Module1.bas=gbk
15 | encoding//vba/Implements/Module1.bas=gbk
16 | encoding//vba/LikeTest/Module1.bas=gbk
17 | encoding//vba/LogicOp/Module1.bas=gbk
18 | encoding//vba/MissingTest/Module1.bas=gbk
19 | encoding//vba/MultiTest/Module1.bas=gbk
20 | encoding//vba/PosNegTest/Module1.bas=gbk
21 | encoding//vba/Random/Module1.bas=gbk
22 | encoding//vba/RedimTest/Module1.bas=gbk
23 | encoding//vba/RuleTest/Module1.bas=gbk
24 | encoding//vba/SubtractTest/Module1.bas=gbk
25 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5 | org.eclipse.jdt.core.compiler.compliance=1.8
6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate
8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11 | org.eclipse.jdt.core.compiler.source=1.8
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/docs/Rule定义.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/docs/Rule定义.txt
--------------------------------------------------------------------------------
/docs/VB 加法.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/docs/VB 加法.PNG
--------------------------------------------------------------------------------
/docs/VisualBasic6.g4.bad:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/docs/VisualBasic6.g4.bad
--------------------------------------------------------------------------------
/docs/工作簿1.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/docs/工作簿1.xlsx
--------------------------------------------------------------------------------
/lib/antlr-4.5.3-complete.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/lib/antlr-4.5.3-complete.jar
--------------------------------------------------------------------------------
/lib/commons-collections-3.2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/lib/commons-collections-3.2.1.jar
--------------------------------------------------------------------------------
/lib/commons-io-2.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/lib/commons-io-2.4.jar
--------------------------------------------------------------------------------
/lib/commons-lang3-3.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/lib/commons-lang3-3.1.jar
--------------------------------------------------------------------------------
/lib/commons-logging-1.1.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/lib/commons-logging-1.1.3.jar
--------------------------------------------------------------------------------
/lib/log4j-1.2.17.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/lib/log4j-1.2.17.jar
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/ArgumentException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public class ArgumentException extends Exception {
25 |
26 | private int argumetIndex;
27 |
28 | public int getArgumetIndex() {
29 | return argumetIndex;
30 | }
31 |
32 | public ArgumentException(int argumetIndex, Throwable cause) {
33 | super(cause);
34 | this.argumetIndex = argumetIndex;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/ArgumentMode.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public enum ArgumentMode {
25 | ByVal,
26 | ByRef
27 | }
28 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/Callback.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | import org.siphon.visualbasic.runtime.VbRuntimeException;
25 |
26 | public interface Callback {
27 | void run() throws VbRuntimeException, ArgumentException;
28 | }
29 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/ClassTypeDecl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | import org.siphon.visualbasic.compile.JavaClassModuleDecl;
25 |
26 | public class ClassTypeDecl extends VbTypeDecl {
27 |
28 | public static final VbTypeDecl JAVA_OBJECT_TYPE = new ClassTypeDecl(null, JavaClassModuleDecl.JAVA_OBJECT);
29 | public final ClassModuleDecl classModule;
30 |
31 | public ClassTypeDecl(Library library, ClassModuleDecl classModule) {
32 | super(library);
33 | this.classModule = classModule;
34 | this.name = classModule.name;
35 | this.visibility = classModule.visibility;
36 | }
37 |
38 | @Override
39 | public boolean hasMember(String name) {
40 | return classModule.members.containsKey(name.toUpperCase());
41 | }
42 |
43 | @Override
44 | public VbDecl getMember(String name) {
45 | return classModule.members.get(name.toUpperCase());
46 | }
47 |
48 | @Override
49 | public String toString() {
50 | if (this.library == null) {
51 | return this.name;
52 | } else {
53 | return this.library.name + "." + this.name;
54 | }
55 | }
56 |
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/ConstDecl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | import org.siphon.visualbasic.runtime.VbValue;
25 |
26 | public class ConstDecl extends VarDecl{
27 |
28 | public final VbValue constValue;
29 |
30 | public ConstDecl(Library library, ModuleDecl module, VbValue constValue){
31 | super(library, module);
32 | this.constValue = constValue;
33 | }
34 |
35 |
36 | @Override
37 | public String toString() {
38 | String s = "";
39 | s += visibility.toString() + " Const ";
40 | s += name + " ";
41 | assert (varType != null);
42 | s += varType.toString();
43 | s += " = " + this.constValue;
44 | return s;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/ControlDef.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | import java.util.ArrayList;
25 | import java.util.HashMap;
26 | import java.util.List;
27 | import java.util.Map;
28 | import java.util.TreeMap;
29 |
30 | import org.siphon.visualbasic.runtime.VbValue;
31 | import org.siphon.visualbasic.runtime.VbVarType;
32 |
33 | public class ControlDef {
34 | private VbVarType type;
35 |
36 | public VbVarType getType() {
37 | return type;
38 | }
39 |
40 | public void setType(VbVarType vbVarType) {
41 | this.type = vbVarType;
42 | }
43 |
44 | public String getName() {
45 | return name;
46 | }
47 |
48 | public void setName(String name) {
49 | this.name = name;
50 | }
51 |
52 | public List getChildren() {
53 | return children;
54 | }
55 |
56 | public void setChildren(List children) {
57 | this.children = children;
58 | }
59 |
60 | public Map getAttributes() {
61 | return attributes;
62 | }
63 |
64 | public Map getComplexAttributes() {
65 | return complexAttributes;
66 | }
67 |
68 | private String name;
69 | private Map attributes = new TreeMap<>();
70 | private Map complexAttributes = new TreeMap<>();
71 | private List children = new ArrayList<>();
72 | }
73 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/EventDecl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | import java.util.ArrayList;
25 | import java.util.List;
26 |
27 | import org.siphon.visualbasic.runtime.ArgumentDecl;
28 |
29 | public class EventDecl extends VbDecl {
30 |
31 | public List arguments = null;
32 |
33 | public EventDecl(Library library, ModuleDecl module) {
34 | super(library);
35 | }
36 |
37 | @Override
38 | public String toString() {
39 | return String.format("(Event %s)", this.name);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/MeDecl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public class MeDecl extends VarDecl {
25 |
26 | public MeDecl(Library library, ModuleDecl module) {
27 | super(library, module);
28 | }
29 |
30 |
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/MethodType.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public enum MethodType {
25 | Sub,
26 | Function,
27 | PropertyGet,
28 | PropertySet,
29 | PropertyLet,
30 | Rule
31 | }
32 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/ModuleMemberDecl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public class ModuleMemberDecl extends VbDecl {
25 |
26 | public ModuleDecl module;
27 |
28 | public static final VarDecl AMBIGUOUS = new VarDecl(null, null);
29 |
30 | public ModuleMemberDecl(Library library, ModuleDecl module) {
31 | super(library);
32 | this.module = module;
33 | }
34 |
35 | public Library getLibrary() {
36 | if(this.library == null) {
37 | if(this.module != null)
38 | return this.module.library;
39 | }
40 | return this.library;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/ModuleType.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public enum ModuleType {
25 | Module,
26 | ClassModule,
27 | Form, // 不做实现
28 | UserControl // 不做实现
29 | }
30 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/NumberRange.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public class NumberRange {
25 |
26 | private final Number minValue;
27 | public Number getMinValue() {
28 | return minValue;
29 | }
30 |
31 | public Number getMaxValue() {
32 | return maxValue;
33 | }
34 |
35 | private final Number maxValue;
36 |
37 | public NumberRange(Number minValue, Number maxValue) {
38 | this.minValue = minValue;
39 | this.maxValue = maxValue;
40 | }
41 |
42 | public void checkRange(Number number){
43 | double d = number.doubleValue();
44 | if(Double.isInfinite(d)) return ; // 到时应报除以0
45 | if(d < this.getMinValue().doubleValue()
46 | || d > this.getMaxValue().doubleValue()){
47 | throw new OverflowException();
48 | }
49 | }
50 |
51 | public boolean isIn(Number number){
52 | double d = number.doubleValue();
53 | if(Double.isInfinite(d)) return true; // 到时应报除以0
54 | if(d < this.getMinValue().doubleValue()
55 | || d > this.getMaxValue().doubleValue()){
56 | return false;
57 | }
58 | return true;
59 | }
60 |
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/OverflowException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public class OverflowException extends RuntimeException {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/ProjectReference.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | import java.io.File;
25 |
26 | public class ProjectReference {
27 |
28 | public ProjectReference(File vbpFile) {
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/TheClass.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | // VB 类模块中 Class_Initialize 对应的事件源对象
25 | public class TheClass extends ClassModuleDecl {
26 |
27 | public final EventDecl initializeEvent;
28 | public final EventDecl terminateEvent;
29 |
30 | public TheClass(Library lib, org.siphon.visualbasic.compile.Compiler compiler) {
31 | super(lib, compiler);
32 |
33 | EventDecl initialize = new EventDecl(lib, this);
34 | initialize.name = "Initialize";
35 | this.addEvent(null, initialize);
36 | this.initializeEvent = initialize;
37 |
38 | EventDecl terminate = new EventDecl(lib, this);
39 | terminate.name = "Terminate";
40 | this.addEvent(null, terminate);
41 | this.terminateEvent = terminate;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/UdtDecl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | import java.util.SortedMap;
25 | import java.util.TreeMap;
26 |
27 | public class UdtDecl extends VbTypeDecl{
28 |
29 | public UdtDecl(Library library) {
30 | super(library);
31 | }
32 |
33 | public SortedMap members = new TreeMap<>();
34 |
35 | public void addMember(VarDecl var) {
36 | members.put(var.upperCaseName(), var);
37 | }
38 |
39 | @Override
40 | public boolean hasMember(String name) {
41 | return this.members.containsKey(name.toUpperCase());
42 | }
43 |
44 |
45 | @Override
46 | public String toString() {
47 | return String.format("(UDT %s.%s)", this.library.name, this.name);
48 | }
49 |
50 | @Override
51 | public VbDecl getMember(String name) {
52 | return members.get(name);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/UnspportedActiveXReferenceException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public class UnspportedActiveXReferenceException extends Exception {
25 |
26 | public UnspportedActiveXReferenceException(String activeXLibName) {
27 | super(String.format("dont support activex reference: ref %s", activeXLibName));
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/VbDecl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public class VbDecl {
25 | public String name;
26 | public Visibility visibility = Visibility.PRIVATE;
27 | protected final Library library;
28 |
29 | public Library getLibrary() {
30 | return this.library;
31 | }
32 |
33 | public VbDecl(Library library){
34 | this.library = library;
35 | }
36 |
37 | public static final VbDecl AMBIGUOUS = new VbDecl(null);
38 | public static final VbDecl COMPILER_UNKNOWN = new VbDecl(null);
39 |
40 | public String upperCaseName(){
41 | return name.toUpperCase();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/VbTypeDecl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public abstract class VbTypeDecl extends VbDecl {
25 |
26 | public VbTypeDecl(Library library) {
27 | super(library);
28 | }
29 |
30 |
31 | public abstract boolean hasMember(String name);
32 |
33 | public abstract VbDecl getMember(String name);
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/Visibility.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic;
23 |
24 | public enum Visibility {
25 | PRIVATE,
26 | PUBLIC,
27 | FRIEND,
28 | GLOBAL,
29 | Hidden;
30 | }
31 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/compile/AmbiguousIdentifierException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.compile;
23 |
24 | public class AmbiguousIdentifierException extends Exception {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/compile/ImplementorClassModuleDecl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.compile;
23 |
24 | import java.util.HashMap;
25 | import java.util.Map;
26 |
27 | import org.siphon.visualbasic.ClassModuleDecl;
28 | import org.siphon.visualbasic.Library;
29 | import org.siphon.visualbasic.MethodDecl;
30 | import org.siphon.visualbasic.VbDecl;
31 |
32 | // 派生类实现接口,对于每个要实现的接口,生成一个 Implementor,记录实现与接口声明之间的映射。用于 VbValue.varType.typeDecl。见 ClassModuleDecl.buildImplements
33 | public class ImplementorClassModuleDecl extends ClassModuleDecl {
34 |
35 | public Map mirrors = new HashMap<>();
36 |
37 | public ImplementorClassModuleDecl(Library lib, Compiler compiler) {
38 | super(lib, compiler);
39 | }
40 |
41 | public VbDecl getMirrorMember(VbDecl decl) {
42 | assert mirrors.get(decl) != null; // TODO remove this line
43 | return mirrors.get(decl);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/compile/ImpossibleException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.compile;
23 |
24 | public class ImpossibleException extends RuntimeException {
25 |
26 | /**
27 | *
28 | */
29 | private static final long serialVersionUID = 5185158367687873268L;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/compile/JavaEventDecl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.compile;
23 |
24 | import java.lang.reflect.Field;
25 | import java.lang.reflect.Method;
26 | import java.lang.reflect.Parameter;
27 | import java.util.ArrayList;
28 |
29 | import org.siphon.visualbasic.ArgumentMode;
30 | import org.siphon.visualbasic.EventDecl;
31 | import org.siphon.visualbasic.Library;
32 | import org.siphon.visualbasic.MethodDecl;
33 | import org.siphon.visualbasic.MethodType;
34 | import org.siphon.visualbasic.ModuleDecl;
35 | import org.siphon.visualbasic.Visibility;
36 | import org.siphon.visualbasic.runtime.ArgumentDecl;
37 | import org.siphon.visualbasic.runtime.VbValue;
38 | import org.siphon.visualbasic.runtime.VbVarType;
39 | import org.siphon.visualbasic.runtime.framework.VbMethod;
40 | import org.siphon.visualbasic.runtime.framework.VbParam;
41 |
42 | public class JavaEventDecl extends EventDecl {
43 |
44 | public final Field javaField;
45 | private boolean withIntepreter;
46 |
47 | public JavaEventDecl setWithIntepreter(boolean withIntepreter) {
48 | this.withIntepreter = withIntepreter;
49 | return this;
50 | }
51 |
52 | public boolean isWithIntepreter() {
53 | return withIntepreter;
54 | }
55 |
56 | // java field must be List
57 | public JavaEventDecl(Library library, ModuleDecl module, Field javaField) {
58 | super(library, module);
59 |
60 | this.javaField = javaField;
61 | this.name = javaField.getName();
62 |
63 | }
64 |
65 |
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/compile/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.compile;
23 |
24 | public class NotFoundException extends Exception {
25 |
26 | public NotFoundException() {
27 | }
28 |
29 |
30 | public NotFoundException(String message) {
31 | super(message);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/compile/NotMatchException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.compile;
23 |
24 | public class NotMatchException extends Exception {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/compile/ValueStatementDesc.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.compile;
23 |
24 | import org.antlr.v4.runtime.ParserRuleContext;
25 | import org.siphon.visualbasic.VbDecl;
26 | import org.siphon.visualbasic.runtime.Statement;
27 | import org.siphon.visualbasic.runtime.VbVarType;
28 |
29 | public class ValueStatementDesc {
30 |
31 | private Statement statement;
32 |
33 | private VbVarType varType;
34 |
35 | private ParserRuleContext ast;
36 |
37 | public Statement getStatement() {
38 | return statement;
39 | }
40 |
41 | public ValueStatementDesc setStatement(Statement statement) {
42 | this.statement = statement;
43 | return this;
44 | }
45 |
46 | public VbVarType getVarType() {
47 | return varType;
48 | }
49 |
50 | public ValueStatementDesc setVarType(VbVarType varType) {
51 | this.varType = varType;
52 | return this;
53 | }
54 |
55 | public ParserRuleContext getAst() {
56 | return ast;
57 | }
58 |
59 | public ValueStatementDesc setAst(ParserRuleContext ast){
60 | this.ast = ast;
61 | return this;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/compile/VbErrorsException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.compile;
23 |
24 | import java.util.List;
25 |
26 | import org.apache.commons.lang3.StringUtils;
27 |
28 | public class VbErrorsException extends Exception {
29 |
30 | public VbErrorsException(List errors) {
31 | super("errors exists: \r\n " + StringUtils.join(errors, "\r\n"));
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/compile/VbFixedStringType.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.compile;
23 |
24 | import org.siphon.visualbasic.runtime.VbVarType;
25 |
26 | public class VbFixedStringType extends VbVarType {
27 |
28 | public final long length;
29 |
30 | public VbFixedStringType(long length) {
31 | super(VbVarType.vbString);
32 |
33 | this.length = length;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/ArgumentDecl.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | import org.siphon.visualbasic.ArgumentMode;
25 | import org.siphon.visualbasic.VarDecl;
26 |
27 | public class ArgumentDecl extends VarDecl {
28 |
29 | public ArgumentDecl() {
30 | super(null, null);
31 | }
32 |
33 | public boolean optional;
34 | public ArgumentMode mode;
35 | public boolean isParamArray;
36 | public VbValue defaultValue;
37 | }
38 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/ArrayDef.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | import org.apache.commons.lang3.StringUtils;
25 |
26 | public class ArrayDef {
27 |
28 | public static class Rank{
29 | public final int lBound;
30 |
31 | public final int rBound;
32 |
33 | public Rank(int lBound, int rBound){
34 | this.lBound = lBound;
35 | this.rBound = rBound;
36 | }
37 |
38 | public int length(){return this.rBound - this.lBound + 1; }
39 |
40 | @Override
41 | public String toString() {
42 | return lBound + " To " + rBound;
43 | }
44 | }
45 |
46 | public static class RankAsStatement{
47 | public final Statement lBound;
48 |
49 | public final Statement rBound;
50 |
51 | public RankAsStatement(Statement lBound, Statement rBound){
52 | this.lBound = lBound;
53 | this.rBound = rBound;
54 | }
55 |
56 | @Override
57 | public String toString() {
58 | return lBound + " To " + rBound;
59 | }
60 | }
61 |
62 | public final Rank[] ranks;
63 |
64 | public final VbVarType baseType;
65 |
66 | public ArrayDef(VbVarType vbVarType, Rank[] ranks){
67 | this.ranks = ranks;
68 | this.baseType = vbVarType;
69 | }
70 |
71 | public boolean isDynmaic(){
72 | return this.ranks == null;
73 | }
74 |
75 | @Override
76 | public String toString() {
77 | String s = "array of " + baseType;
78 | if(ranks != null){
79 | s += " " + StringUtils.join(ranks, ',');
80 | }
81 | return s;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/DebuggerAction.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | public enum DebuggerAction {
25 | NONE,
26 | STEP_OVER,
27 | STEP_RETURN,
28 | STEP_INTO,
29 | }
30 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/DivByZeroException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | public class DivByZeroException extends RuntimeException {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/EventSubscriber.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | import org.siphon.visualbasic.EventDecl;
25 | import org.siphon.visualbasic.MethodDecl;
26 |
27 | public class EventSubscriber {
28 |
29 | private ModuleInstance subscriber;
30 | private MethodDecl listener;
31 | private EventDecl eventDecl;
32 |
33 | public EventSubscriber(ModuleInstance subscriber, EventDecl eventDecl, MethodDecl listener) {
34 | this.subscriber = subscriber;
35 | this.eventDecl = eventDecl;
36 | this.listener = listener;
37 | }
38 |
39 | public ModuleInstance getSubscriber() {
40 | return subscriber;
41 | }
42 |
43 | public MethodDecl getListener() {
44 | return listener;
45 | }
46 |
47 | public EventDecl getEventDecl() {
48 | return eventDecl;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/NullValueException.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | public class NullValueException extends RuntimeException {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/RuntimeLibrary.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | import java.util.HashMap;
25 | import java.util.Map;
26 |
27 | import org.siphon.visualbasic.Library;
28 | import org.siphon.visualbasic.VarDecl;
29 |
30 | public class RuntimeLibrary {
31 |
32 | public Map modules = new HashMap<>();
33 |
34 | public final Map variables = new HashMap<>();
35 |
36 | private final Library library;
37 |
38 | public RuntimeLibrary(Library lib) {
39 | this.library = lib;
40 | }
41 |
42 | public Library getLibrary() {
43 | return library;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/Statement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | import java.util.List;
25 |
26 | import org.siphon.visualbasic.ClassModuleDecl;
27 | import org.siphon.visualbasic.ClassTypeDecl;
28 | import org.siphon.visualbasic.Interpreter;
29 | import org.siphon.visualbasic.MethodDecl;
30 | import org.siphon.visualbasic.ModuleMemberDecl;
31 | import org.siphon.visualbasic.PropertyDecl;
32 | import org.siphon.visualbasic.SourceLocation;
33 |
34 | public abstract class Statement {
35 |
36 | protected final SourceLocation sourceLocation;
37 |
38 | public SourceLocation getSourceLocation() {
39 | return sourceLocation;
40 | }
41 |
42 | public abstract VbValue eval(Interpreter interpreter, CallFrame frame) throws VbRuntimeException;
43 |
44 | public Statement(SourceLocation sourceLocation){
45 | if(sourceLocation == null)
46 | System.err.println("sourceLocation is null");
47 | this.sourceLocation = sourceLocation;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/UdtInstance.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | import java.util.HashMap;
25 | import java.util.Map;
26 |
27 | import org.siphon.visualbasic.UdtDecl;
28 | import org.siphon.visualbasic.VarDecl;
29 |
30 | public class UdtInstance {
31 |
32 | public final UdtDecl decl;
33 |
34 |
35 | public UdtInstance(UdtDecl udtDecl) {
36 | this.decl = udtDecl;
37 | for(VarDecl vd : udtDecl.members.values()){
38 | members.put(vd.name.toUpperCase(), vd.createVar());
39 | }
40 | }
41 |
42 | private Map members = new HashMap<>();
43 |
44 |
45 | public VbVariable getVar(String name){
46 | return members.get(name.toUpperCase());
47 | }
48 |
49 | public VbValue getValue(String name){
50 | return members.get(name.toUpperCase()).value;
51 | }
52 |
53 | public void setValue(String name, VbValue value){
54 | members.get(name.toUpperCase()).value = value;
55 | }
56 |
57 | public UdtInstance clone(){
58 | UdtInstance inst = new UdtInstance(this.decl);
59 | for(VarDecl vd : decl.members.values()){
60 | String name = vd.name.toUpperCase();
61 | inst.members.get(name).value = this.members.get(name).value.clone();
62 | }
63 | return inst;
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/VarOwner.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | public enum VarOwner {
25 | ModuleVar,
26 | MethodVar,
27 | Argument
28 | }
29 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/VbBoundObject.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | public class VbBoundObject {
25 | private JavaModuleInstance vbModuleInstance;
26 |
27 | public JavaModuleInstance getVbModuleInstance() {
28 | return vbModuleInstance;
29 | }
30 |
31 | public void setVbModuleInstance(JavaModuleInstance vbModuleInstance) {
32 | this.vbModuleInstance = vbModuleInstance;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/VbEventHandler.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime;
23 |
24 | import java.util.List;
25 |
26 | import org.siphon.visualbasic.ArgumentException;
27 | import org.siphon.visualbasic.Interpreter;
28 |
29 | public interface VbEventHandler {
30 | void handle(Interpreter interpreter, CallFrame callFrame, Object... arguments) throws VbRuntimeException, ArgumentException;
31 | }
32 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/framework/Debug.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.framework;
23 |
24 | import org.siphon.visualbasic.runtime.VbValue;
25 |
26 | public class Debug {
27 |
28 | @VbMethod
29 | public void Print(VbValue object){
30 | if(object instanceof VbValue){
31 | if(object.isNull()){
32 | System.out.println("Null");
33 | } else {
34 | System.out.println(VbValue.CStr((VbValue) object).value);
35 | }
36 | } else {
37 | System.out.println(object);
38 | }
39 | }
40 |
41 | @VbMethod
42 | public void Trace(VbValue object){
43 | System.out.println(object);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/framework/VbEvent.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.framework;
23 |
24 | import java.lang.annotation.ElementType;
25 | import java.lang.annotation.Retention;
26 | import java.lang.annotation.RetentionPolicy;
27 | import java.lang.annotation.Target;
28 |
29 | @Target(value = ElementType.FIELD)
30 | @Retention(value = RetentionPolicy.RUNTIME)
31 | public @interface VbEvent {
32 | public String value();
33 | }
34 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/framework/VbMethod.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.framework;
23 |
24 | import java.lang.annotation.ElementType;
25 | import java.lang.annotation.Retention;
26 | import java.lang.annotation.RetentionPolicy;
27 | import java.lang.annotation.Target;
28 |
29 | @Target(value = ElementType.METHOD)
30 | @Retention(value = RetentionPolicy.RUNTIME)
31 | public @interface VbMethod {
32 | public boolean isDefault() default false;
33 | public boolean isIterator() default false;
34 | public boolean isDictionary() default false;
35 | /**
36 | * accept Interpreter and Frame as first 2 arguments
37 | * @return
38 | */
39 | public boolean withIntepreter() default false;
40 | public String value() default "";
41 | }
42 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/framework/VbParam.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.framework;
23 |
24 | import java.lang.annotation.ElementType;
25 | import java.lang.annotation.Retention;
26 | import java.lang.annotation.RetentionPolicy;
27 | import java.lang.annotation.Target;
28 |
29 | import org.siphon.visualbasic.ArgumentMode;
30 | import org.siphon.visualbasic.runtime.VbVarType;
31 |
32 | @Target(value = ElementType.PARAMETER)
33 | @Retention(value = RetentionPolicy.RUNTIME)
34 | public @interface VbParam {
35 | VbVarType.TypeEnum type() default VbVarType.TypeEnum.vbVariant;
36 | boolean paramArray() default false;
37 | boolean optional() default false;
38 | String defaultString() default "";
39 | int defaultInt() default 0;
40 | long defaultLong() default 0;
41 | double defaultDouble() default 0;
42 | float defaultFloat() default 0;
43 | ArgumentMode mode() default ArgumentMode.ByRef;
44 | boolean defaultBoolean() default false;
45 | String name();
46 | }
47 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/framework/stdole/StdOleLibrary.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.framework.stdole;
23 |
24 | import org.siphon.visualbasic.Library;
25 | import org.siphon.visualbasic.compile.Compiler;
26 | import org.siphon.visualbasic.compile.JavaClassModuleDecl;
27 | import org.siphon.visualbasic.runtime.framework.vba.Collection;
28 |
29 | public class StdOleLibrary extends Library{
30 |
31 | public StdOleLibrary(Compiler compiler) {
32 | super("stdole");
33 |
34 | this.addModule(new JavaClassModuleDecl(this, compiler, StdFont.class));
35 | }
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/framework/vb/VBLibrary.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.framework.vb;
23 |
24 | import org.siphon.visualbasic.ControlArray;
25 | import org.siphon.visualbasic.Library;
26 | import org.siphon.visualbasic.compile.Compiler;
27 | import org.siphon.visualbasic.compile.JavaClassModuleDecl;
28 | import org.siphon.visualbasic.runtime.framework.vba.Collection;
29 |
30 | public class VBLibrary extends Library{
31 |
32 | public VBLibrary(Compiler compiler) {
33 | super("VB");
34 |
35 | JavaClassModuleDecl formDecl = new JavaClassModuleDecl(this, compiler, Form.class);
36 | this.addModule(formDecl);
37 |
38 | this.addModule(new JavaClassModuleDecl(this, compiler, CommandButton.class));
39 | this.addModule(new JavaClassModuleDecl(this, compiler, TextBox.class));
40 | this.addModule(new JavaClassModuleDecl(this, compiler, Frame.class));
41 | }
42 |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/framework/vba/Constants.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.framework.vba;
23 |
24 | public class Constants {
25 |
26 | public static final String vbBack = String.valueOf((char)8);
27 |
28 | public static final String vbCr = "\r";
29 |
30 | public static final String vbCrLf = "\r\n";
31 |
32 | public static final String vbFormFeed = String.valueOf((char)12);;
33 |
34 | public static final String vbLf = "\n";
35 |
36 | public static final String vbNewLine = System.lineSeparator();
37 |
38 | public static final String vbNullChar = "\0";
39 |
40 | public static final String vbNullString = "";
41 |
42 | public static final long vbObjectError = 0x80040000;
43 |
44 | public static final String vbTab = "\t";
45 |
46 | public static final String vbVerticalTab = String.valueOf((char)11);
47 | }
48 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/interaction/JavaArrayIterator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.interaction;
23 |
24 | import java.util.Iterator;
25 |
26 | import org.apache.commons.collections.iterators.ArrayIterator;
27 | import org.siphon.visualbasic.runtime.VbValue;
28 |
29 | public class JavaArrayIterator extends ArrayIterator {
30 |
31 | public JavaArrayIterator(Object array) {
32 | super(array);
33 | }
34 |
35 | @Override
36 | public VbValue next() {
37 | return VbValue.fromJava(super.next());
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/interaction/VbValueIterator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.interaction;
23 |
24 | import java.util.Iterator;
25 |
26 | import org.siphon.visualbasic.runtime.VbValue;
27 |
28 | public class VbValueIterator implements Iterator {
29 |
30 | private Iterator iterator;
31 |
32 | public VbValueIterator(Iterator it) {
33 | this.iterator = it;
34 | }
35 |
36 | @Override
37 | public boolean hasNext() {
38 | return iterator.hasNext();
39 | }
40 |
41 | @Override
42 | public VbValue next() {
43 | return VbValue.fromJava(iterator.next());
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/AssignStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.SourceLocation;
26 | import org.siphon.visualbasic.runtime.CallFrame;
27 | import org.siphon.visualbasic.runtime.Statement;
28 | import org.siphon.visualbasic.runtime.VbRuntimeException;
29 | import org.siphon.visualbasic.runtime.VbValue;
30 |
31 | public class AssignStatement extends Statement {
32 |
33 | private EvalAssignableStatement evalAssignableStatement;
34 | private Statement valueStatement;
35 |
36 | public AssignStatement(SourceLocation sourceLocation, EvalAssignableStatement evalAssignableStatement, Statement valueStatement) {
37 | super(sourceLocation);
38 | this.evalAssignableStatement = evalAssignableStatement;
39 | this.valueStatement = valueStatement;
40 | assert valueStatement != null;
41 | }
42 |
43 | @Override
44 | public VbValue eval(Interpreter interpreter, CallFrame frame) throws VbRuntimeException {
45 | EvalAssignableObject obj = (EvalAssignableObject) evalAssignableStatement.evalIt(interpreter, frame);
46 | assert obj != null;
47 | VbValue value = valueStatement.eval(interpreter, frame);
48 |
49 | obj.assign(value, interpreter, frame);
50 |
51 | return value;
52 | }
53 |
54 | @Override
55 | public String toString() {
56 | return String.format("Assign %s = %s", evalAssignableStatement, valueStatement);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/BinaryStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.SourceLocation;
26 | import org.siphon.visualbasic.runtime.CallFrame;
27 | import org.siphon.visualbasic.runtime.Statement;
28 | import org.siphon.visualbasic.runtime.VbRuntimeException;
29 | import org.siphon.visualbasic.runtime.VbValue;
30 |
31 | public abstract class BinaryStatement extends Statement {
32 |
33 | protected final Statement v1;
34 | protected final Statement v2;
35 |
36 | public BinaryStatement(SourceLocation sourceLocation, Statement v1, Statement v2) {
37 | super(sourceLocation);
38 | this.v1 = v1;
39 | this.v2 = v2;
40 | }
41 |
42 | @Override
43 | public VbValue eval(Interpreter interpreter, CallFrame frame) throws VbRuntimeException {
44 | VbValue value1 = v1.eval(interpreter, frame);
45 | if(value1.isObject()){
46 | value1 = interpreter.evalDefaultMember(value1, frame, sourceLocation);
47 | }
48 | VbValue value2 = v2.eval(interpreter, frame);
49 | if(value2.isObject()){
50 | value2 = interpreter.evalDefaultMember(value2, frame, sourceLocation);
51 | }
52 | return this.eval(value1, value2, interpreter, frame);
53 | }
54 |
55 | protected abstract VbValue eval(VbValue value1, VbValue value2, Interpreter interpreter, CallFrame frame) throws VbRuntimeException;
56 | }
57 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/EvalAssignableObject.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.runtime.CallFrame;
26 | import org.siphon.visualbasic.runtime.VbRuntimeException;
27 | import org.siphon.visualbasic.runtime.VbValue;
28 |
29 | /*
30 | * 可求值,可赋值的对象结构
31 | */
32 | public abstract class EvalAssignableObject {
33 |
34 | public abstract VbValue apply(Interpreter interpreter, CallFrame frame) throws VbRuntimeException;
35 |
36 |
37 | public abstract void assign(VbValue value, Interpreter interpreter, CallFrame frame) throws VbRuntimeException;
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/ExitMethodStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.SourceLocation;
26 | import org.siphon.visualbasic.runtime.CallFrame;
27 | import org.siphon.visualbasic.runtime.Statement;
28 | import org.siphon.visualbasic.runtime.VbValue;
29 |
30 | public class ExitMethodStatement extends Statement {
31 |
32 | public ExitMethodStatement(SourceLocation sourceLocation) {
33 | super(sourceLocation);
34 | }
35 |
36 | @Override
37 | public VbValue eval(Interpreter interpreter, CallFrame frame) {
38 | frame.nextStatement = frame.method.statements.size();
39 | return null;
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return "EXIT METHOD";
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/GoSubStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.SourceLocation;
26 | import org.siphon.visualbasic.runtime.CallFrame;
27 | import org.siphon.visualbasic.runtime.VbValue;
28 |
29 | public class GoSubStatement extends GotoStatement {
30 |
31 | public GoSubStatement(SourceLocation sourceLocation, Integer statementIndex) {
32 | super(sourceLocation, statementIndex);
33 | }
34 |
35 | @Override
36 | public VbValue eval(Interpreter interpreter, CallFrame frame) {
37 | frame.gosubResumeStack.push(frame.nextStatement);
38 | frame.nextStatement = statementIndex;
39 | return null;
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return "GOSUB " + statementIndex;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/GotoStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import javax.xml.transform.Source;
25 |
26 | import org.siphon.visualbasic.Interpreter;
27 | import org.siphon.visualbasic.SourceLocation;
28 | import org.siphon.visualbasic.runtime.CallFrame;
29 | import org.siphon.visualbasic.runtime.Statement;
30 | import org.siphon.visualbasic.runtime.VbRuntimeException;
31 | import org.siphon.visualbasic.runtime.VbValue;
32 |
33 | public class GotoStatement extends Statement {
34 |
35 | protected int statementIndex;
36 |
37 | public int getNextStatement() {
38 | return statementIndex;
39 | }
40 |
41 | public GotoStatement(SourceLocation sourceLocation, final Integer statementIndex) {
42 | super(sourceLocation);
43 | this.statementIndex = statementIndex;
44 | }
45 |
46 | public GotoStatement(SourceLocation sourceLocation) {
47 | super(sourceLocation);
48 | statementIndex = -1;
49 | }
50 |
51 | @Override
52 | public VbValue eval(Interpreter interpreter, CallFrame frame) throws VbRuntimeException {
53 | frame.nextStatement = statementIndex;
54 | return null;
55 | }
56 |
57 |
58 | public GotoStatement setNextStatement(int nextStatement) {
59 | this.statementIndex = nextStatement;
60 | return this;
61 | }
62 |
63 | @Override
64 | public String toString() {
65 | return "GOTO " + statementIndex;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/IfNotGotoStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.OverflowException;
26 | import org.siphon.visualbasic.SourceLocation;
27 | import org.siphon.visualbasic.runtime.CallFrame;
28 | import org.siphon.visualbasic.runtime.NullValueException;
29 | import org.siphon.visualbasic.runtime.Statement;
30 | import org.siphon.visualbasic.runtime.VbRuntimeException;
31 | import org.siphon.visualbasic.runtime.VbValue;
32 |
33 | public class IfNotGotoStatement extends GotoStatement {
34 |
35 | private final Statement condition;
36 |
37 | public IfNotGotoStatement(SourceLocation sourceLocation, Statement condition) {
38 | super(sourceLocation);
39 | this.condition = condition;
40 | }
41 |
42 | @Override
43 | public VbValue eval(Interpreter interpreter, CallFrame frame) throws VbRuntimeException {
44 | VbValue value = condition.eval(interpreter, frame);
45 |
46 | try{
47 | boolean cond = VbValue.isTrue(value);
48 | if (cond == false) {
49 | frame.nextStatement = this.statementIndex;
50 | }
51 | } catch(ClassCastException e){
52 | throw new VbRuntimeException(VbRuntimeException.类型不匹配, sourceLocation);
53 | } catch(NullValueException e){
54 | throw new VbRuntimeException(VbRuntimeException.Null的使用无效, sourceLocation);
55 | }
56 |
57 | return null;
58 | }
59 |
60 | @Override
61 | public String toString() {
62 | return String.format("IF NOT %s GOTO %s", condition, statementIndex);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/InitLibraryStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.Library;
26 | import org.siphon.visualbasic.ModuleDecl;
27 | import org.siphon.visualbasic.ModuleType;
28 | import org.siphon.visualbasic.SourceLocation;
29 | import org.siphon.visualbasic.runtime.CallFrame;
30 | import org.siphon.visualbasic.runtime.Statement;
31 | import org.siphon.visualbasic.runtime.VbRuntimeException;
32 | import org.siphon.visualbasic.runtime.VbValue;
33 |
34 | public class InitLibraryStatement extends Statement {
35 |
36 | private Library lib;
37 |
38 | public InitLibraryStatement(Library lib) {
39 | super(SourceLocation.Unkown);
40 | this.lib = lib;
41 | }
42 |
43 | @Override
44 | public VbValue eval(Interpreter interpreter, CallFrame frame) throws VbRuntimeException {
45 |
46 | // for (ModuleDecl moduleDecl : lib.modules.values()) {
47 | // if (moduleDecl.moduleType == ModuleType.Module) {
48 | // for (ModuleDecl module : lib.modules.values()) {
49 | //
50 | // }
51 | // }
52 | // }
53 | return null;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/LiteralStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.SourceLocation;
26 | import org.siphon.visualbasic.runtime.CallFrame;
27 | import org.siphon.visualbasic.runtime.Statement;
28 | import org.siphon.visualbasic.runtime.VbValue;
29 |
30 | public class LiteralStatement extends Statement {
31 |
32 | private final VbValue literal;
33 |
34 | public LiteralStatement(VbValue literal) {
35 | super(SourceLocation.ByInterpreter);
36 | assert literal != null;
37 | this.literal = literal;
38 | }
39 |
40 | @Override
41 | public VbValue eval(Interpreter interpreter, CallFrame frame) {
42 | return literal;
43 | }
44 |
45 | @Override
46 | public String toString() {
47 | return literal.toString();
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/PrintStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.SourceLocation;
26 | import org.siphon.visualbasic.runtime.CallFrame;
27 | import org.siphon.visualbasic.runtime.Statement;
28 | import org.siphon.visualbasic.runtime.VbRuntimeException;
29 | import org.siphon.visualbasic.runtime.VbValue;
30 |
31 | public class PrintStatement extends Statement {
32 |
33 | private final Statement valueStatement;
34 |
35 | public PrintStatement(SourceLocation sourceLocation,Statement valueStatement) {
36 | super(sourceLocation);
37 | this.valueStatement = valueStatement;
38 | }
39 |
40 | @Override
41 | public VbValue eval(Interpreter interpreter, CallFrame frame) throws VbRuntimeException {
42 | VbValue value = valueStatement.eval(interpreter, frame);
43 | System.err.println(value.value);
44 | return null;
45 | }
46 |
47 | @Override
48 | public String toString() {
49 | return "Print " + valueStatement;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/ReturnStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.SourceLocation;
26 | import org.siphon.visualbasic.runtime.CallFrame;
27 | import org.siphon.visualbasic.runtime.Statement;
28 | import org.siphon.visualbasic.runtime.VbValue;
29 |
30 | public class ReturnStatement extends Statement {
31 |
32 | public ReturnStatement(SourceLocation sourceLocation) {
33 | super(sourceLocation);
34 | }
35 |
36 | @Override
37 | public VbValue eval(Interpreter interpreter, CallFrame frame) {
38 | frame.nextStatement = frame.gosubResumeStack.pop();
39 | return null;
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return "RETURN (LAST GOTO SUB)";
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/SelectCaseConditionStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.runtime.CallFrame;
26 | import org.siphon.visualbasic.runtime.VbRuntimeException;
27 | import org.siphon.visualbasic.runtime.VbValue;
28 |
29 | public abstract class SelectCaseConditionStatement{
30 |
31 | public abstract boolean test(Interpreter interpreter, CallFrame frame, VbValue value) throws VbRuntimeException;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/StopStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.SourceLocation;
26 | import org.siphon.visualbasic.runtime.CallFrame;
27 | import org.siphon.visualbasic.runtime.Debugger;
28 | import org.siphon.visualbasic.runtime.Statement;
29 | import org.siphon.visualbasic.runtime.VbRuntimeException;
30 | import org.siphon.visualbasic.runtime.VbValue;
31 |
32 | public class StopStatement extends Statement {
33 |
34 | public StopStatement(SourceLocation sourceLocation) {
35 | super(sourceLocation);
36 | }
37 |
38 | @Override
39 | public VbValue eval(Interpreter interpreter, CallFrame frame) throws VbRuntimeException {
40 | Debugger debugger = interpreter.getDebugger();
41 | if(debugger != null){
42 | debugger.stop();
43 | }
44 | return null;
45 | }
46 |
47 | @Override
48 | public String toString() {
49 | return "Stop";
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/UndeterminedLabelGotoStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import java.util.List;
25 |
26 | import org.antlr.v4.runtime.ParserRuleContext;
27 | import org.siphon.visualbasic.Interpreter;
28 | import org.siphon.visualbasic.SourceLocation;
29 | import org.siphon.visualbasic.runtime.CallFrame;
30 | import org.siphon.visualbasic.runtime.Statement;
31 | import org.siphon.visualbasic.runtime.VbValue;
32 |
33 | /**
34 | * 编译时 goto 的 label 的行号未定,先用这个语句占位
35 | */
36 | public class UndeterminedLabelGotoStatement extends Statement {
37 |
38 | public final String label;
39 | public final List owner;
40 |
41 | public UndeterminedLabelGotoStatement(SourceLocation sourceLocation, String label, List owner) {
42 | super(sourceLocation);
43 | this.label = label;
44 | this.owner = owner;
45 | }
46 |
47 | public GotoStatement toGotoStatement(int lineIndex){
48 | return new GotoStatement(sourceLocation, lineIndex);
49 | }
50 |
51 | @Override
52 | public VbValue eval(Interpreter interpreter, CallFrame frame) {
53 | return null;
54 | }
55 |
56 | public static class GoSub extends UndeterminedLabelGotoStatement {
57 |
58 | public GoSub(SourceLocation sourceLocation, String label, List owner) {
59 | super(sourceLocation, label, owner);
60 | }
61 |
62 | public GotoStatement toGotoStatement(int lineIndex){
63 | return new GoSubStatement(sourceLocation, lineIndex);
64 | }
65 |
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/VariableStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.SourceLocation;
26 | import org.siphon.visualbasic.VarDecl;
27 | import org.siphon.visualbasic.runtime.CallFrame;
28 | import org.siphon.visualbasic.runtime.Statement;
29 | import org.siphon.visualbasic.runtime.VbValue;
30 |
31 | public class VariableStatement extends Statement {
32 |
33 | private final VarDecl varDecl;
34 |
35 | public VariableStatement(SourceLocation sourceLocation, VarDecl varDecl) {
36 | super(sourceLocation);
37 | this.varDecl = varDecl;
38 | }
39 |
40 | @Override
41 | public VbValue eval(Interpreter interpreter, CallFrame frame) {
42 | frame.local.put(varDecl, varDecl.createVar());
43 | return null;
44 | }
45 |
46 | @Override
47 | public String toString() {
48 | return "Dim " + varDecl;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/org/siphon/visualbasic/runtime/statements/WithStatement.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (C) 2017 Inshua
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in
12 | * all copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | ******************************************************************************/
22 | package org.siphon.visualbasic.runtime.statements;
23 |
24 | import org.siphon.visualbasic.Interpreter;
25 | import org.siphon.visualbasic.SourceLocation;
26 | import org.siphon.visualbasic.runtime.CallFrame;
27 | import org.siphon.visualbasic.runtime.Statement;
28 | import org.siphon.visualbasic.runtime.VbRuntimeException;
29 | import org.siphon.visualbasic.runtime.VbValue;
30 |
31 | public class WithStatement extends Statement {
32 |
33 | private Statement bindObj;
34 | private VbValue prevWith;
35 |
36 | public WithStatement(SourceLocation sourceLocation, Statement bindObj) {
37 | super(sourceLocation);
38 | this.bindObj = bindObj;
39 | }
40 |
41 | @Override
42 | public VbValue eval(Interpreter interpreter, CallFrame frame) throws VbRuntimeException {
43 | this.prevWith = frame.withObject;
44 | frame.withObject = this.bindObj.eval(interpreter, frame);
45 | return null;
46 | }
47 |
48 | public Statement endWith(SourceLocation sourceLocation) {
49 | return new Statement(sourceLocation) {
50 |
51 | @Override
52 | public VbValue eval(Interpreter interpreter, CallFrame frame) throws VbRuntimeException {
53 | frame.withObject = prevWith;
54 | return null;
55 | }
56 |
57 | @Override
58 | public String toString() {
59 | return "End With";
60 | }
61 | };
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | return "With " + bindObj;
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/target/generated-sources/antlr4/.gitignore:
--------------------------------------------------------------------------------
1 | /vba/
2 | /Vba.tokens
3 | /VbaBaseListener.java
4 | /VbaLexer.java
5 | /VbaLexer.tokens
6 | /VbaListener.java
7 | /VbaParser.java
8 | /vba -package my.package/
9 |
--------------------------------------------------------------------------------
/test/test/Dragon.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | public class Dragon extends Sprite{
4 |
5 | private String name = "Noname";
6 |
7 | public Dragon(){
8 | }
9 |
10 | public Dragon(String name){
11 | this.name = name;
12 | }
13 |
14 | @Override
15 | public void move(String target) {
16 | System.out.println(String.format("Dragon %s move to " + target, name));
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/test/test/JavaReflection.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | import java.lang.reflect.Array;
4 | import java.lang.reflect.Parameter;
5 | import java.lang.reflect.ParameterizedType;
6 | import java.lang.reflect.Type;
7 | import java.lang.reflect.TypeVariable;
8 | import java.util.ArrayList;
9 | import java.util.List;
10 | import java.util.Map;
11 |
12 | import org.apache.commons.lang3.reflect.TypeUtils;
13 |
14 | public class JavaReflection {
15 | public static void main(String[] args) throws InstantiationException, IllegalAccessException {
16 | int[] a = new int[20];
17 | Class clazz = a.getClass();
18 | // System.out.println(clazz.newInstance());
19 | System.out.println(clazz.isArray());
20 | System.out.println(TypeUtils.getArrayComponentType(clazz));
21 | System.out.println(clazz);
22 | Object arr = Array.newInstance(clazz.getComponentType(), 20);
23 | System.out.println(arr);
24 |
25 |
26 | List d = new ArrayList<>();
27 | clazz = d.getClass();
28 | System.out.println(d.getClass().getGenericSuperclass());
29 | System.out.println(d.getClass().getGenericInterfaces()[0]);
30 | ParameterizedType t = (ParameterizedType) clazz.getGenericSuperclass();
31 | System.out.println(t.getActualTypeArguments()[0]);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/test/test/LangTest.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class LangTest {
7 | public static void main(String[] args) {
8 | List ls = new ArrayList<>();
9 | ls.set(2, 2);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/test/Sprite.java:
--------------------------------------------------------------------------------
1 |
2 | package test;
3 |
4 | public class Sprite {
5 |
6 | public String getResourceKey() {
7 | return resourceKey;
8 | }
9 |
10 | public void setResourceKey(String resourceKey) {
11 | this.resourceKey = resourceKey;
12 | }
13 |
14 | private String resourceKey;
15 |
16 | public void move(String target){
17 | System.out.println("Sprite move to " + target);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/test/test/TypesTest.java:
--------------------------------------------------------------------------------
1 | package test;
2 |
3 | import java.util.Date;
4 | import java.util.List;
5 |
6 | import org.apache.commons.lang3.ArrayUtils;
7 | import org.apache.commons.lang3.StringUtils;
8 |
9 | public class TypesTest {
10 |
11 | public void test1(Sprite sprite){
12 | sprite.move("test1");
13 | }
14 |
15 | public void test2(Sprite sprite){
16 | sprite.move("test2 as sprite");
17 | }
18 |
19 | public void test2(Dragon sprite){
20 | sprite.move("test2 as dragon");
21 | }
22 |
23 | public void test2(Object sprite){
24 | System.out.println(sprite + " as object");
25 | }
26 |
27 | public void test3(int[] a, String b, boolean c, Date d){
28 | System.out.println("a: " + ArrayUtils.toString(a));
29 | System.out.println("b: " + b);
30 | System.out.println("c: " + c);
31 | System.out.println("d: " + d);
32 | }
33 |
34 | public void test4(List a, double b, Double c){
35 | System.out.println("a: " + a);
36 | System.out.println("b: " + b);
37 | System.out.println("c: " + c);
38 | }
39 |
40 | public void test5(String a, Object... arr){
41 | System.out.println("a: " + a);
42 | System.out.println("arr: " + StringUtils.join(arr, ","));
43 | }
44 |
45 | public int test6(int a, int b){
46 | return a + b;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/vba/.gitignore:
--------------------------------------------------------------------------------
1 | **/**.vbw
2 |
--------------------------------------------------------------------------------
/vba/AddTest/AddTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="AddTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/AddTest/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/AddTest/Module1.bas
--------------------------------------------------------------------------------
/vba/Calculator/Calc.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Form=Form1.frm
3 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
4 | IconForm="Form1"
5 | Startup="Form1"
6 | ExeName32="Calc.exe"
7 | Command32=""
8 | Name="calc"
9 | HelpContextID="0"
10 | CompatibleMode="0"
11 | MajorVer=1
12 | MinorVer=0
13 | RevisionVer=0
14 | AutoIncrementVer=0
15 | ServerSupportFiles=0
16 | VersionCompanyName="FREE"
17 | CompilationType=0
18 | OptimizationType=0
19 | FavorPentiumPro(tm)=0
20 | CodeViewDebugInfo=0
21 | NoAliasing=0
22 | BoundsCheck=0
23 | OverflowCheck=0
24 | FlPointCheck=0
25 | FDIVCheck=0
26 | UnroundedFP=0
27 | StartMode=0
28 | Unattended=0
29 | Retained=0
30 | ThreadPerObject=0
31 | MaxNumberOfThreads=1
32 |
--------------------------------------------------------------------------------
/vba/Calculator/Form1.frm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/Calculator/Form1.frm
--------------------------------------------------------------------------------
/vba/Calculator/calc_mac.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/Calculator/calc_mac.png
--------------------------------------------------------------------------------
/vba/Calculator/calc_win.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/Calculator/calc_win.png
--------------------------------------------------------------------------------
/vba/Calculator/vb_calc_win.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/Calculator/vb_calc_win.png
--------------------------------------------------------------------------------
/vba/CallTest/CallTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Class=Class1; Class1.cls
5 | Startup="Sub Main"
6 | Command32=""
7 | Name="CallTest"
8 | HelpContextID="0"
9 | CompatibleMode="0"
10 | MajorVer=1
11 | MinorVer=0
12 | RevisionVer=0
13 | AutoIncrementVer=0
14 | ServerSupportFiles=0
15 | VersionCompanyName="FREE"
16 | CompilationType=0
17 | OptimizationType=0
18 | FavorPentiumPro(tm)=0
19 | CodeViewDebugInfo=0
20 | NoAliasing=0
21 | BoundsCheck=0
22 | OverflowCheck=0
23 | FlPointCheck=0
24 | FDIVCheck=0
25 | UnroundedFP=0
26 | StartMode=0
27 | Unattended=0
28 | Retained=0
29 | ThreadPerObject=0
30 | MaxNumberOfThreads=1
31 |
--------------------------------------------------------------------------------
/vba/CallTest/CallTest.vbw:
--------------------------------------------------------------------------------
1 | Module1 = 52, 52, 798, 444, Z
2 | Class1 = 0, 0, 0, 0, C
3 |
--------------------------------------------------------------------------------
/vba/CallTest/Class1.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | Persistable = 0 'NotPersistable
5 | DataBindingBehavior = 0 'vbNone
6 | DataSourceBehavior = 0 'vbNone
7 | MTSTransactionMode = 0 'NotAnMTSObject
8 | END
9 | Attribute VB_Name = "Class1"
10 | Attribute VB_GlobalNameSpace = False
11 | Attribute VB_Creatable = True
12 | Attribute VB_PredeclaredId = False
13 | Attribute VB_Exposed = False
14 | Sub OptionalTest(a As Integer, Optional b As Integer = 3, Optional c As Integer = 4)
15 | Debug.Print a + b + c
16 | End Sub
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/vba/CallTest/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 | Sub Main()
3 | OptionalTest a:=2, c:=3
4 | OptionalTest c:=3, a:=2
5 | ' OptionalTest 2
6 | '
7 | ParamArrayTest 1, 2, 3, 4, 5
8 |
9 | Dim a
10 | Set a = New Class1
11 |
12 | a.OptionalTest a:=2, c:=3
13 | a.OptionalTest c:=3, a:=2
14 | End Sub
15 |
16 | Sub ByRefTest(ByRef a As Integer)
17 | a = a + 1
18 | End Sub
19 |
20 | Sub OptionalTest(a As Integer, Optional b As Integer = 3, Optional c As Integer = 4)
21 | Debug.Print a + b + c
22 | End Sub
23 |
24 | Sub ParamArrayTest(a As Integer, ParamArray b())
25 | For Each i In b
26 | a = a + i
27 | Next
28 | Debug.Print a
29 | End Sub
30 |
31 |
32 |
--------------------------------------------------------------------------------
/vba/Class1.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | END
5 | Attribute VB_Name = "Class1"
6 | Attribute VB_GlobalNameSpace = False
7 | Attribute VB_Creatable = False
8 | Attribute VB_PredeclaredId = False
9 | Attribute VB_Exposed = False
10 |
11 | Public a As Integer
12 |
13 | Public b As Integer
14 |
15 | Public Function add(a As Integer, b As Integer) As Integer
16 | add = a + b
17 | End Function
18 |
19 | Public Function AddB(b As Integer) As Integer
20 | AddB = a + b
21 | End Function
22 |
23 | Public Function AddAB() As Integer
24 | AddAB = a + b
25 | End Function
26 |
27 |
--------------------------------------------------------------------------------
/vba/ClassTest/Class1.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | Persistable = 0 'NotPersistable
5 | DataBindingBehavior = 0 'vbNone
6 | DataSourceBehavior = 0 'vbNone
7 | MTSTransactionMode = 0 'NotAnMTSObject
8 | END
9 | Attribute VB_Name = "Class1"
10 | Attribute VB_GlobalNameSpace = False
11 | Attribute VB_Creatable = True
12 | Attribute VB_PredeclaredId = False
13 | Attribute VB_Exposed = False
14 | Dim n As String
15 | Dim f As Class1
16 |
17 | Dim c As New Collection
18 |
19 | Public Property Get name() As String
20 | name = n
21 | End Property
22 |
23 | Public Property Let name(s As String)
24 | n = s
25 | End Property
26 |
27 |
28 | Public Property Get MyFriend() As Class1
29 | Set MyFriend = f
30 | End Property
31 |
32 |
33 | Public Property Set MyFriend(p As Class1)
34 | Set f = p
35 | End Property
36 |
37 |
38 | Public Property Get Contact(key As String) As Class1
39 | Contact = c(key)
40 | End Property
41 |
42 | Public Property Set Concat(key As String, p As Class1)
43 | c.Add p, key
44 | End Property
45 |
--------------------------------------------------------------------------------
/vba/ClassTest/ClassTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Class=Class1; Class1.cls
4 | Module=Module1; Module1.bas
5 | Startup="Sub Main"
6 | Command32=""
7 | Name="ClassTest"
8 | HelpContextID="0"
9 | CompatibleMode="0"
10 | MajorVer=1
11 | MinorVer=0
12 | RevisionVer=0
13 | AutoIncrementVer=0
14 | ServerSupportFiles=0
15 | VersionCompanyName="aaaa"
16 | CompilationType=0
17 | OptimizationType=0
18 | FavorPentiumPro(tm)=0
19 | CodeViewDebugInfo=0
20 | NoAliasing=0
21 | BoundsCheck=0
22 | OverflowCheck=0
23 | FlPointCheck=0
24 | FDIVCheck=0
25 | UnroundedFP=0
26 | StartMode=0
27 | Unattended=0
28 | Retained=0
29 | ThreadPerObject=0
30 | MaxNumberOfThreads=1
31 |
--------------------------------------------------------------------------------
/vba/ClassTest/ClassTest.vbw:
--------------------------------------------------------------------------------
1 | Class1 = 312, 312, 1346, 1000, Z
2 | Module1 = 130, 130, 1164, 818,
3 |
--------------------------------------------------------------------------------
/vba/ClassTest/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 | Sub main()
3 | Dim c As New Class1
4 |
5 | c.name = "tom"
6 | Dim s
7 | s = "my name is " & c.name
8 | Debug.Print s
9 | '
10 | Set c.MyFriend = New Class1
11 | c.MyFriend.name = "jerry"
12 | Debug.Print "my friend " & c.MyFriend.name
13 |
14 | Set c.MyFriend.MyFriend = New Class1
15 | c.MyFriend.MyFriend.name = "marry"
16 |
17 | Debug.Print "jerry's friend " & c.MyFriend.MyFriend.name
18 | End Sub
19 |
--------------------------------------------------------------------------------
/vba/CollectionTest/CollectionTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="CollectionTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/CollectionTest/CollectionTest.vbw:
--------------------------------------------------------------------------------
1 | Module1 = 26, 26, 931, 392, Z
2 |
--------------------------------------------------------------------------------
/vba/CollectionTest/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/CollectionTest/Module1.bas
--------------------------------------------------------------------------------
/vba/CompareTest/CompareTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="CompareTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/CompareTest/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/CompareTest/Module1.bas
--------------------------------------------------------------------------------
/vba/ConstByRef/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 | Sub Main()
3 | Test True
4 | Debug.Print True
5 | End Sub
6 |
7 |
8 | Sub Test(ByRef a As Boolean)
9 | a = Not a
10 | End Sub
--------------------------------------------------------------------------------
/vba/ConstByRef/Test.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="Test"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/ControlArray/Form1.frm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/ControlArray/Form1.frm
--------------------------------------------------------------------------------
/vba/ControlArray/Test.vbp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/ControlArray/Test.vbp
--------------------------------------------------------------------------------
/vba/CreateObject/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 | Sub Main()
3 | Dim o
4 | Set o = CreateObject("test.Sprite")
5 | 'o.ResourceKey = "Dragon"
6 | 'Debug.Print o.ResourceKey
7 | o.Move "Paris"
8 |
9 | End Sub
10 |
--------------------------------------------------------------------------------
/vba/CreateObject/Test.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="Test"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/CurrencyTest/CurrencyTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="CurrencyTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/CurrencyTest/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/CurrencyTest/Module1.bas
--------------------------------------------------------------------------------
/vba/CustomCollection/ButtonArray.cls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/CustomCollection/ButtonArray.cls
--------------------------------------------------------------------------------
/vba/CustomCollection/Form1.frm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/CustomCollection/Form1.frm
--------------------------------------------------------------------------------
/vba/CustomCollection/MyButton.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | Persistable = 0 'NotPersistable
5 | DataBindingBehavior = 0 'vbNone
6 | DataSourceBehavior = 0 'vbNone
7 | MTSTransactionMode = 0 'NotAnMTSObject
8 | END
9 | Attribute VB_Name = "MyButton"
10 | Attribute VB_GlobalNameSpace = False
11 | Attribute VB_Creatable = True
12 | Attribute VB_PredeclaredId = False
13 | Attribute VB_Exposed = False
14 | Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
15 | Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
16 |
--------------------------------------------------------------------------------
/vba/CustomCollection/工程1.vbp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/CustomCollection/工程1.vbp
--------------------------------------------------------------------------------
/vba/DefaultProperty/Class1.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | Persistable = 0 'NotPersistable
5 | DataBindingBehavior = 0 'vbNone
6 | DataSourceBehavior = 0 'vbNone
7 | MTSTransactionMode = 0 'NotAnMTSObject
8 | END
9 | Attribute VB_Name = "Class1"
10 | Attribute VB_GlobalNameSpace = False
11 | Attribute VB_Creatable = True
12 | Attribute VB_PredeclaredId = False
13 | Attribute VB_Exposed = False
14 | Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
15 | Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
16 | Private mName As String
17 | Private mvarId As Integer
18 | Public Property Let Id(ByVal vData As Integer)
19 | mvarId = vData
20 | End Property
21 |
22 |
23 | Public Property Get Id() As Integer
24 | Attribute Id.VB_UserMemId = 0
25 | Id = mvarId
26 | End Property
27 |
28 |
29 |
30 | Public Property Get Name() As String
31 | Name = mName
32 | End Property
33 |
34 | Public Property Let Name(s As String)
35 | mName = s
36 | End Property
37 |
--------------------------------------------------------------------------------
/vba/DefaultProperty/Form1.frm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/DefaultProperty/Form1.frm
--------------------------------------------------------------------------------
/vba/DefaultProperty/工程1.vbp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/DefaultProperty/工程1.vbp
--------------------------------------------------------------------------------
/vba/DivTest/DivTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="DivTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/DivTest/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/DivTest/Module1.bas
--------------------------------------------------------------------------------
/vba/ErrHandle/ErrHandle.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="ErrHandle"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="FREE"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/ErrHandle/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 |
3 | Sub Main()
4 | test
5 |
6 | Call CallDontHandle
7 | End Sub
8 |
9 | Sub test()
10 | On Error GoTo ErrHandle
11 | Dim a As Integer
12 | Dim b As Integer
13 | a = 2
14 | b = 0
15 | b = a / b
16 | 'Debug.Print b
17 |
18 | Debug.Print a / b
19 | Exit Sub
20 |
21 | ErrHandle:
22 | Debug.Print Err.Description
23 | b = 2
24 | Resume
25 | End Sub
26 |
27 |
28 | Sub DontHandle()
29 | Dim i As Integer
30 | i = Null
31 | End Sub
32 |
33 | Sub CallDontHandle()
34 | DontHandle
35 | End Sub
36 |
--------------------------------------------------------------------------------
/vba/EventTest/Class1.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | Persistable = 0 'NotPersistable
5 | DataBindingBehavior = 0 'vbNone
6 | DataSourceBehavior = 0 'vbNone
7 | MTSTransactionMode = 0 'NotAnMTSObject
8 | END
9 | Attribute VB_Name = "Class1"
10 | Attribute VB_GlobalNameSpace = False
11 | Attribute VB_Creatable = True
12 | Attribute VB_PredeclaredId = False
13 | Attribute VB_Exposed = False
14 | Event OnTest(s As String)
15 | Dim mName As String
16 |
17 | Public Sub test()
18 | RaiseEvent OnTest("hello, i am " & mName)
19 | End Sub
20 |
21 | Property Get Name() As String
22 | Name = mName
23 | End Property
24 |
25 | Property Let Name(v As String)
26 | mName = v
27 | End Property
28 |
29 | Public Sub OnTest()
30 |
31 | End Sub
32 |
33 |
--------------------------------------------------------------------------------
/vba/EventTest/Class2.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | Persistable = 0 'NotPersistable
5 | DataBindingBehavior = 0 'vbNone
6 | DataSourceBehavior = 0 'vbNone
7 | MTSTransactionMode = 0 'NotAnMTSObject
8 | END
9 | Attribute VB_Name = "Class2"
10 | Attribute VB_GlobalNameSpace = False
11 | Attribute VB_Creatable = True
12 | Attribute VB_PredeclaredId = False
13 | Attribute VB_Exposed = False
14 | Private WithEvents c As Class1
15 | Attribute c.VB_VarHelpID = -1
16 |
17 | 'Private WithEvents Class As Class1
18 |
19 | Public Property Get C1() As Class1
20 | Set C1 = c
21 | End Property
22 |
23 | Public Property Set C1(v As Class1)
24 | Set c = v
25 | End Property
26 |
27 | Private Sub c_OnTest(s As String)
28 | Debug.Print "event come " & s
29 | End Sub
30 |
31 | Private Sub Class_OnTest(s As String)
32 | Debug.Print s
33 | End Sub
34 |
35 | Private Sub Class_Initialize()
36 | Debug.Print "Class2 Initialize"
37 | End Sub
38 |
39 | Private Sub Class_Terminate()
40 | Debug.Print "Class2 Terminate"
41 | End Sub
42 |
--------------------------------------------------------------------------------
/vba/EventTest/EventTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Class=Class1; Class1.cls
5 | Class=Class2; Class2.cls
6 | Startup="Sub Main"
7 | Command32=""
8 | Name="EventTest"
9 | HelpContextID="0"
10 | CompatibleMode="0"
11 | MajorVer=1
12 | MinorVer=0
13 | RevisionVer=0
14 | AutoIncrementVer=0
15 | ServerSupportFiles=0
16 | VersionCompanyName="aaaa"
17 | CompilationType=0
18 | OptimizationType=0
19 | FavorPentiumPro(tm)=0
20 | CodeViewDebugInfo=0
21 | NoAliasing=0
22 | BoundsCheck=0
23 | OverflowCheck=0
24 | FlPointCheck=0
25 | FDIVCheck=0
26 | UnroundedFP=0
27 | StartMode=0
28 | Unattended=0
29 | Retained=0
30 | ThreadPerObject=0
31 | MaxNumberOfThreads=1
32 |
--------------------------------------------------------------------------------
/vba/EventTest/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 |
3 | Sub main()
4 | Dim o As New Class2
5 | Set o.C1 = New Class1
6 | o.C1.Name = "tom"
7 | o.C1.test
8 |
9 | o.C1.Name = "jerry"
10 | o.C1.test
11 |
12 | Dim prevC1 As Class1
13 | Set prevC1 = o.C1
14 |
15 | Set o.C1 = New Class1
16 | o.C1.Name = "mary"
17 | o.C1.test
18 |
19 | prevC1.test ' event bind with Set statemnet
20 |
21 |
22 | Dim o2 As New Class2
23 | Set o2.C1 = o.C1
24 | o.C1.test ' print 'mary' twice
25 | End Sub
26 |
--------------------------------------------------------------------------------
/vba/Form1/Form1.frm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/Form1/Form1.frm
--------------------------------------------------------------------------------
/vba/Form1/Proj.vbp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/Form1/Proj.vbp
--------------------------------------------------------------------------------
/vba/FormFromSubMain/Form1.frm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/FormFromSubMain/Form1.frm
--------------------------------------------------------------------------------
/vba/FormFromSubMain/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 | Dim a As Integer
3 | Sub Main()
4 | 'Dim f As Form1
5 | 'Set f = New Form1
6 | 'Call f.Show
7 | Form1.Show
8 | End Sub
9 |
--------------------------------------------------------------------------------
/vba/FormFromSubMain/Test.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Form=Form1.frm
3 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
4 | Module=Module1; Module1.bas
5 | IconForm="Form1"
6 | Startup="Sub Main"
7 | HelpFile=""
8 | Command32=""
9 | Name="Test"
10 | HelpContextID="0"
11 | CompatibleMode="0"
12 | MajorVer=1
13 | MinorVer=0
14 | RevisionVer=0
15 | AutoIncrementVer=0
16 | ServerSupportFiles=0
17 | CompilationType=0
18 | OptimizationType=0
19 | FavorPentiumPro(tm)=0
20 | CodeViewDebugInfo=0
21 | NoAliasing=0
22 | BoundsCheck=0
23 | OverflowCheck=0
24 | FlPointCheck=0
25 | FDIVCheck=0
26 | UnroundedFP=0
27 | StartMode=0
28 | Unattended=0
29 | Retained=0
30 | ThreadPerObject=0
31 | MaxNumberOfThreads=1
32 |
--------------------------------------------------------------------------------
/vba/FormTwoControls/2controls.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/FormTwoControls/2controls.jpg
--------------------------------------------------------------------------------
/vba/FormTwoControls/Form1.frm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/FormTwoControls/Form1.frm
--------------------------------------------------------------------------------
/vba/FormTwoControls/Test.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Form=Form1.frm
3 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
4 | IconForm="Form1"
5 | Startup="Form1"
6 | HelpFile=""
7 | Command32=""
8 | Name="Test"
9 | HelpContextID="0"
10 | CompatibleMode="0"
11 | MajorVer=1
12 | MinorVer=0
13 | RevisionVer=0
14 | AutoIncrementVer=0
15 | ServerSupportFiles=0
16 | CompilationType=0
17 | OptimizationType=0
18 | FavorPentiumPro(tm)=0
19 | CodeViewDebugInfo=0
20 | NoAliasing=0
21 | BoundsCheck=0
22 | OverflowCheck=0
23 | FlPointCheck=0
24 | FDIVCheck=0
25 | UnroundedFP=0
26 | StartMode=0
27 | Unattended=0
28 | Retained=0
29 | ThreadPerObject=0
30 | MaxNumberOfThreads=1
31 |
--------------------------------------------------------------------------------
/vba/Frame/Form1.frm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/Frame/Form1.frm
--------------------------------------------------------------------------------
/vba/Frame/Test.vbp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/Frame/Test.vbp
--------------------------------------------------------------------------------
/vba/IDivMod/DivTest.vbw:
--------------------------------------------------------------------------------
1 | Module1 = 26, 26, 1164, 474, Z
2 |
--------------------------------------------------------------------------------
/vba/IDivMod/IDivModTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="IDivModTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/IDivMod/IDivModTest.vbw:
--------------------------------------------------------------------------------
1 | Module1 = 26, 26, 1120, 506, Z
2 |
--------------------------------------------------------------------------------
/vba/IDivMod/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/IDivMod/Module1.bas
--------------------------------------------------------------------------------
/vba/Implements/Dragon.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | Persistable = 0 'NotPersistable
5 | DataBindingBehavior = 0 'vbNone
6 | DataSourceBehavior = 0 'vbNone
7 | MTSTransactionMode = 0 'NotAnMTSObject
8 | END
9 | Attribute VB_Name = "Dragon"
10 | Attribute VB_GlobalNameSpace = False
11 | Attribute VB_Creatable = True
12 | Attribute VB_PredeclaredId = False
13 | Attribute VB_Exposed = False
14 | Option Explicit
15 |
16 | Implements Sprite
17 | Implements SaveLoadable
18 |
19 | Private Sub SaveLoadable_Load()
20 |
21 | End Sub
22 |
23 | Private Sub SaveLoadable_Save()
24 | Debug.Print "Save " & Sprite_Desc
25 | End Sub
26 |
27 | Private Function Sprite_Desc() As String
28 | Sprite_Desc = "Great Fire Dragon"
29 | End Function
30 |
31 | Public Sub Sprite_Move()
32 | Debug.Print "Dragon Fly"
33 | End Sub
34 |
35 | Private Property Let Sprite_ResourceField(ByVal RHS As String) ' Public Field ������ Property ����
36 |
37 | End Property
38 |
39 | Private Property Get Sprite_ResourceField() As String
40 |
41 | End Property
42 |
43 | Private Property Let Sprite_ResourceKey(RHS As String)
44 | Debug.Print "Resource Key Of Dragon is fixed, will not change to " + RHS
45 | End Property
46 |
47 | Public Property Get Sprite_ResourceKey() As String
48 | Sprite_ResourceKey = "Dragon Resource"
49 | End Property
50 |
51 |
--------------------------------------------------------------------------------
/vba/Implements/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/Implements/Module1.bas
--------------------------------------------------------------------------------
/vba/Implements/SaveLoadable.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | Persistable = 0 'NotPersistable
5 | DataBindingBehavior = 0 'vbNone
6 | DataSourceBehavior = 0 'vbNone
7 | MTSTransactionMode = 0 'NotAnMTSObject
8 | END
9 | Attribute VB_Name = "SaveLoadable"
10 | Attribute VB_GlobalNameSpace = False
11 | Attribute VB_Creatable = True
12 | Attribute VB_PredeclaredId = False
13 | Attribute VB_Exposed = False
14 | Public Sub Save()
15 |
16 | End Sub
17 |
18 | Public Sub Load()
19 |
20 | End Sub
21 |
--------------------------------------------------------------------------------
/vba/Implements/Sprite.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | Persistable = 0 'NotPersistable
5 | DataBindingBehavior = 0 'vbNone
6 | DataSourceBehavior = 0 'vbNone
7 | MTSTransactionMode = 0 'NotAnMTSObject
8 | END
9 | Attribute VB_Name = "Sprite"
10 | Attribute VB_GlobalNameSpace = False
11 | Attribute VB_Creatable = True
12 | Attribute VB_PredeclaredId = False
13 | Attribute VB_Exposed = False
14 |
15 | Public ResourceField As String
16 |
17 | Dim mResourceKey As String
18 | Public Property Get ResourceKey() As String
19 | ResourceKey = mResourceKey
20 | End Property
21 |
22 | Public Property Let ResourceKey(v As String)
23 | 'Implements CheckBox
24 | mResourceKey = v
25 | End Property
26 |
27 | Public Sub Move()
28 | Debug.Print "Sprite Move"
29 | End Sub
30 |
31 | Public Function Desc() As String
32 | 'Fun = "This is a sprite"
33 | End Function
34 |
--------------------------------------------------------------------------------
/vba/Implements/Test.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Class=Sprite; Sprite.cls
5 | Class=Dragon; Dragon.cls
6 | Class=SaveLoadable; SaveLoadable.cls
7 | Startup="Sub Main"
8 | Command32=""
9 | Name="Test"
10 | HelpContextID="0"
11 | CompatibleMode="0"
12 | MajorVer=1
13 | MinorVer=0
14 | RevisionVer=0
15 | AutoIncrementVer=0
16 | ServerSupportFiles=0
17 | VersionCompanyName="aaaa"
18 | CompilationType=0
19 | OptimizationType=0
20 | FavorPentiumPro(tm)=0
21 | CodeViewDebugInfo=0
22 | NoAliasing=0
23 | BoundsCheck=0
24 | OverflowCheck=0
25 | FlPointCheck=0
26 | FDIVCheck=0
27 | UnroundedFP=0
28 | StartMode=0
29 | Unattended=0
30 | Retained=0
31 | ThreadPerObject=0
32 | MaxNumberOfThreads=1
33 |
--------------------------------------------------------------------------------
/vba/Implements/Test.vbw:
--------------------------------------------------------------------------------
1 | Module1 = 26, 26, 1120, 512, Z
2 | Sprite = 52, 52, 1164, 556,
3 | Dragon = 78, 78, 1190, 582,
4 | SaveLoadable = 104, 104, 1216, 608,
5 |
--------------------------------------------------------------------------------
/vba/Interactive/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 | Sub Main()
3 | Dim t As Object
4 | Set t = CreateObject("test.TypesTest")
5 |
6 | Dim d
7 | Set d = CreateObject("test.Dragon", "Jack") ' constructor params
8 |
9 | t.test1 d
10 |
11 | t.test2 d ' auto match signature test2(Dragon d)
12 |
13 | Dim arr(10) As Integer
14 | For i = 0 To 10
15 | arr(i) = i
16 | Next
17 | t.test3 arr, "hello", True, Now
18 |
19 | t.test4 arr, 2.2, Nothing
20 |
21 | t.test5 2,3, "abc", True, Now
22 |
23 | Debug.Print t.test6("2", 3.5) ' auto convert type: int test6(int a, int b)
24 |
25 | Dim ls
26 | Set ls = CreateObject("java.util.ArrayList")
27 | ls.Add 2
28 | ls.Add "hello"
29 | ls(0) = 22 ' access list element like vb array
30 |
31 | Debug.Print ls(1)
32 |
33 | For Each e In ls ' for each over Iterator
34 | Debug.Trace e
35 | Next
36 |
37 | Dim m
38 | Set m = CreateObject("java.util.HashMap")
39 | m!name = "Tom" ' use ! access java map
40 | m!gender = "M"
41 | m!name = m!name & " Armstrong" ' can assign
42 |
43 | For Each k In m.KeySet ' for each over Iterator, for each v in map, equals for each v in m.values
44 | Debug.Print k & ":" & m.get(k)
45 | Next
46 | End Sub
47 |
--------------------------------------------------------------------------------
/vba/Interactive/Test.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="Test"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/LikeTest/LikeTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="LikeTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/LikeTest/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/LikeTest/Module1.bas
--------------------------------------------------------------------------------
/vba/LogicOp/LogicOp.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="LogicOp"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/LogicOp/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/LogicOp/Module1.bas
--------------------------------------------------------------------------------
/vba/Mid/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 | Sub Main()
3 | Dim MyString
4 | MyString = "The dog jumps" ' 设置字符串初值。
5 | Mid(MyString, 5, 3) = "f" ' MyString = "The fog jumps"。
6 | Debug.Trace MyString
7 | Mid(MyString, 5, 3) = "fox" ' MyString = "The fox jumps"。
8 | Debug.Print MyString
9 | Mid(MyString, 5) = "cow" ' MyString = "The cow jumps"。
10 | Debug.Print MyString
11 | Mid(MyString, 5) = "cow jumped over" ' MyString = "The cow jumpe"。
12 | Debug.Print MyString
13 | Mid(MyString, 5, 3) = "duck" ' MyString = "The duc jumpe"。
14 | Debug.Print MyString
15 |
16 |
17 | Dim FirstWord, LastWord, MidWords
18 | MyString = "Mid Function Demo" '建立一个字符串。
19 | FirstWord = Mid(MyString, 1, 3) ' 返回 "Mid"。
20 | Debug.Print FirstWord
21 | LastWord = Mid(MyString, 14, 4) ' 返回 "Demo"。
22 | Debug.Print LastWord
23 | MidWords = Mid(MyString, 5) ' 返回 "Funcion Demo"。
24 | Debug.Print MidWords
25 | End Sub
26 |
--------------------------------------------------------------------------------
/vba/Mid/Test.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="Test"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/MissingTest/MissingTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="MissingTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/MissingTest/MissingTest.vbw:
--------------------------------------------------------------------------------
1 | Module1 = 26, 26, 778, 398, Z
2 |
--------------------------------------------------------------------------------
/vba/MissingTest/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 |
3 | Function ReturnTwice(Optional A)
4 | Debug.Trace a + 2
5 | End Function
6 |
7 | Sub Main()
8 | On Error GoTo ErrHandler
9 |
10 | Dim ReturnValue
11 | ReturnValue = ReturnTwice()
12 | 'Debug.Print ReturnValue
13 | ReturnValue = ReturnTwice(2)
14 | 'Debug.Print ReturnValue
15 |
16 | Exit Sub
17 | ErrHandler:
18 | Debug.Print "Err " & Err * 1
19 | Debug.Print Err.Source & " " & Err & ":" & Err.Description
20 | Resume Next
21 | End Sub
22 |
--------------------------------------------------------------------------------
/vba/MultiTest/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/MultiTest/Module1.bas
--------------------------------------------------------------------------------
/vba/MultiTest/MultiTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="MultiTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/NewMacros.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "NewMacros"
2 | Dim 计算年假 As Integer
3 | Sub 宏1()
4 | 'Attribute 宏1.VB_ProcData.VB_Invoke_Func = "Normal.NewMacros.宏1"
5 | '
6 | 员工通道 = 2
7 | End Sub
8 |
9 | Function 扣钱()
10 |
11 | 扣钱 = 200
12 |
13 | NewMacros.扣钱
14 |
15 | Dim c As New 类1
16 | Dim b As Integer
17 | b = c.add(1, 2)
18 |
19 | End Function
20 |
--------------------------------------------------------------------------------
/vba/PosNegTest/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 | Sub Main()
3 | On Error GoTo ErrHandler
4 |
5 | Dim i As Integer
6 | Dim b As Byte
7 | Dim yn As Boolean
8 | Dim s As String
9 | Dim l As Long
10 | Dim sng As Single
11 | Dim d As Double
12 | Dim dt As Date
13 | dt = Now
14 | Dim c As Currency
15 | Dim v As Variant
16 | Dim e As Variant ' empty
17 |
18 | i = 22
19 | Debug.Trace +i
20 | Debug.Trace -i
21 |
22 | v = i
23 | Debug.Trace +v
24 | Debug.Trace -v
25 |
26 | b = 2
27 | Debug.Trace -b
28 |
29 | s = "111"
30 | Debug.Trace +s
31 | Debug.Trace -s
32 |
33 | yn = True
34 | Debug.Trace +yn
35 | Debug.Trace -yn
36 |
37 | Debug.Trace +e
38 | Debug.Trace -e
39 |
40 | c = 22
41 | Debug.Trace +c
42 | Debug.Trace -c
43 |
44 | Debug.Trace +dt
45 | Debug.Trace -dt
46 |
47 | i = -32768
48 | Debug.Trace i
49 | Debug.Trace -i
50 | v = i
51 | Debug.Trace -v
52 |
53 | dt = 2958465
54 | Debug.Trace -dt
55 | v = dt
56 | Debug.Trace -v
57 |
58 | Exit Sub
59 | ErrHandler:
60 | Debug.Print Err.Source & ":" & Err.Description
61 | Resume Next
62 | End Sub
63 |
--------------------------------------------------------------------------------
/vba/PosNegTest/PosNegTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="PosNegTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/PosNegTest/PosNegTest.vbw:
--------------------------------------------------------------------------------
1 | Module1 = 26, 26, 1120, 506, Z
2 |
--------------------------------------------------------------------------------
/vba/Prj1/MathOp.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | Persistable = 0 'NotPersistable
5 | DataBindingBehavior = 0 'vbNone
6 | DataSourceBehavior = 0 'vbNone
7 | MTSTransactionMode = 0 'NotAnMTSObject
8 | END
9 | Attribute VB_Name = "MathOp"
10 | Attribute VB_GlobalNameSpace = False
11 | Attribute VB_Creatable = True
12 | Attribute VB_PredeclaredId = False
13 | Attribute VB_Exposed = False
14 |
15 | Public Function add(a As Integer, b As Integer) As Integer
16 | add = a + b
17 |
18 | Debug.Print a & " + " & b & " = " & add
19 | End Function
20 |
21 | Private Sub Class_Initialize()
22 | Debug.Print "MathOp Class_Initialize"
23 | End Sub
24 |
25 | Public Function Self() As MathOp
26 | Set Self = Me
27 | End Function
28 |
29 | Public Function This(a As Integer) As MathOp
30 | Set This = Me
31 | End Function
32 |
33 | Public Function arr() As MathOp()
34 | Dim a(2) As MathOp
35 | Set a(0) = Me
36 | Set a(1) = Self
37 | arr = a
38 | End Function
39 |
--------------------------------------------------------------------------------
/vba/Prj1/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/Prj1/Module1.bas
--------------------------------------------------------------------------------
/vba/Prj1/Prj1.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Class=MathOp; MathOp.cls
5 | Startup="Sub Main"
6 | HelpFile=""
7 | Command32=""
8 | Name="Prj1"
9 | HelpContextID="0"
10 | CompatibleMode="0"
11 | MajorVer=1
12 | MinorVer=0
13 | RevisionVer=0
14 | AutoIncrementVer=0
15 | ServerSupportFiles=0
16 | VersionCompanyName="aaaa"
17 | CompilationType=0
18 | OptimizationType=0
19 | FavorPentiumPro(tm)=0
20 | CodeViewDebugInfo=0
21 | NoAliasing=0
22 | BoundsCheck=0
23 | OverflowCheck=0
24 | FlPointCheck=0
25 | FDIVCheck=0
26 | UnroundedFP=0
27 | StartMode=0
28 | Unattended=0
29 | Retained=0
30 | ThreadPerObject=0
31 | MaxNumberOfThreads=1
32 |
--------------------------------------------------------------------------------
/vba/Prj1/Prj1.vbw:
--------------------------------------------------------------------------------
1 | Module1 = 52, 52, 1346, 740,
2 | MathOp = 78, 78, 1112, 766, Z
3 |
--------------------------------------------------------------------------------
/vba/PropertyTest/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 | Sub main()
3 | Dim p As New Person
4 | p.Name = "Tom"
5 | Debug.Print p.Name
6 |
7 | p.Name = p.Name & " Fox"
8 |
9 | Debug.Print p.Name
10 |
11 | Debug.Print p.Age(True, "a")
12 | p.Age(True, "b") = 22
13 |
14 | '
15 | ' Dim col As New Collection1
16 | ' col.Add
17 | ' For Each p In col
18 | '
19 | ' Next
20 | End Sub
21 |
--------------------------------------------------------------------------------
/vba/PropertyTest/Person.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | Persistable = 0 'NotPersistable
5 | DataBindingBehavior = 0 'vbNone
6 | DataSourceBehavior = 0 'vbNone
7 | MTSTransactionMode = 0 'NotAnMTSObject
8 | END
9 | Attribute VB_Name = "Person"
10 | Attribute VB_GlobalNameSpace = False
11 | Attribute VB_Creatable = True
12 | Attribute VB_PredeclaredId = False
13 | Attribute VB_Exposed = False
14 | Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
15 | Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
16 |
17 | Dim name_ As String
18 | Dim mAge As Integer
19 |
20 | Public Property Get Name() As String
21 | Name = name_
22 | End Property
23 |
24 | Public Property Let Name(n As String)
25 | name_ = n
26 | End Property
27 |
28 | Public Property Get Age(mode As Boolean, s As String) As Integer
29 | Age = mAge
30 | End Property
31 |
32 | Public Property Let Age(mode As Boolean, s As String, a As Integer)
33 | mAge = a
34 | End Property
35 |
36 | Public Function get_Name() As String
37 |
38 | End Function
39 |
40 | Public Function getName() As String
41 |
42 | End Function
43 |
44 |
45 |
--------------------------------------------------------------------------------
/vba/PropertyTest/PropertyTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Class=Person; Person.cls
5 | Startup="Sub Main"
6 | Command32=""
7 | Name="PropertyTest"
8 | HelpContextID="0"
9 | CompatibleMode="0"
10 | MajorVer=1
11 | MinorVer=0
12 | RevisionVer=0
13 | AutoIncrementVer=0
14 | ServerSupportFiles=0
15 | VersionCompanyName="FREE"
16 | CompilationType=0
17 | OptimizationType=0
18 | FavorPentiumPro(tm)=0
19 | CodeViewDebugInfo=0
20 | NoAliasing=0
21 | BoundsCheck=0
22 | OverflowCheck=0
23 | FlPointCheck=0
24 | FDIVCheck=0
25 | UnroundedFP=0
26 | StartMode=0
27 | Unattended=0
28 | Retained=0
29 | ThreadPerObject=0
30 | MaxNumberOfThreads=1
31 |
--------------------------------------------------------------------------------
/vba/Random/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 | Sub Main()
3 | Debug.Print Rnd
4 | Debug.Print Rnd(0)
5 | Debug.Print Rnd
6 | Debug.Print Rnd(2)
7 | Debug.Print Rnd(-100)
8 | Debug.Print Rnd(-100)
9 |
10 | Randomize
11 | Debug.Print Rnd(0)
12 | Debug.Print Rnd
13 | Debug.Print Rnd(2)
14 | Debug.Print Rnd(-100)
15 | Debug.Print Rnd(-100)
16 | End Sub
17 |
--------------------------------------------------------------------------------
/vba/Random/Test.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="SubtractTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/RedimTest/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/RedimTest/Module1.bas
--------------------------------------------------------------------------------
/vba/RedimTest/RedimTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="RedimTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/RuleTest/Module1.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Module1"
2 | Sub Main()
3 | Dim r
4 | Stop
5 | r = SqrRoot(1.0, 2)
6 | Debug.Print r
7 | End Sub
8 |
9 | Function IsGoodEnough(guess As Double, x As Double) As Boolean
10 | IsGoodEnough = Abs(x - guess * guess) <= 0.00001
11 | End Function
12 |
13 | Function NewGuess(guess As Double, x As Double) As Double
14 | NewGuess = (guess + x / guess) / 2.0
15 | End Function
16 |
17 | Rule SqrRoot(guess As Double, x As Double) As Double
18 | SqrRoot = SqrRoot(NewGuess(guess, x), x)
19 | End Rule
20 |
21 | Rule SqrRoot When IsGoodEnough(guess, x)
22 | SqrRoot = guess
23 | End Rule
24 |
25 |
--------------------------------------------------------------------------------
/vba/RuleTest/RuleTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="RuleTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/RuleTest/RuleTest.vbw:
--------------------------------------------------------------------------------
1 | Module1 = 0, 0, 0, 0, C
2 |
--------------------------------------------------------------------------------
/vba/SubtractTest/Module1.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inshua/vba-interpreter/c00e8f18b84c33b33b258c7362eda76721402efb/vba/SubtractTest/Module1.bas
--------------------------------------------------------------------------------
/vba/SubtractTest/SubtractTest.vbp:
--------------------------------------------------------------------------------
1 | Type=Exe
2 | Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\..\..\..\Windows\SysWOW64\stdole2.tlb#OLE Automation
3 | Module=Module1; Module1.bas
4 | Startup="Sub Main"
5 | Command32=""
6 | Name="SubtractTest"
7 | HelpContextID="0"
8 | CompatibleMode="0"
9 | MajorVer=1
10 | MinorVer=0
11 | RevisionVer=0
12 | AutoIncrementVer=0
13 | ServerSupportFiles=0
14 | VersionCompanyName="aaaa"
15 | CompilationType=0
16 | OptimizationType=0
17 | FavorPentiumPro(tm)=0
18 | CodeViewDebugInfo=0
19 | NoAliasing=0
20 | BoundsCheck=0
21 | OverflowCheck=0
22 | FlPointCheck=0
23 | FDIVCheck=0
24 | UnroundedFP=0
25 | StartMode=0
26 | Unattended=0
27 | Retained=0
28 | ThreadPerObject=0
29 | MaxNumberOfThreads=1
30 |
--------------------------------------------------------------------------------
/vba/array-dim.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "ArrayDim"
2 |
3 | Sub Main()
4 | 'DayArray 是一个有 51 个索引(从 0 到 50)元素的 Variant 数组,
5 | '假设在当前模块中 Option Base 被设为 0(缺省设置)。
6 | Dim DayArray(50)
7 | DayArray(0) = 2
8 | DayArray(0) = DayArray(0) * 2
9 | Debug.Print DayArray(0)
10 |
11 | 'Matrix 是一个二维 Integer 数组。
12 | Dim Matrix(3, 4) As Integer
13 | Matrix(2, 2) = 8
14 | Matrix(2, 2) = Matrix(2,2) * 8
15 | Debug.Print Matrix(2,2)
16 |
17 | 'MyMatrix 是一个显式指定了上下界
18 | '的三维 double 数组。
19 | Dim MyMatrix(1 To 5, 4 To 9, 3 To 5) As Double
20 |
21 | 'BirthDay 是一个索引从 1 到 10 的 date 数组。
22 | Dim BirthDay(1 To 10) As Double
23 |
24 | 'MyArray 是一个 variant 动态数组。
25 | Dim MyArray()
26 |
27 | End Sub
--------------------------------------------------------------------------------
/vba/array-redim.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "ArrayRedim"
2 |
3 | Sub Main()
4 | Dim MyArray() As Integer '声明动态数组。
5 | Redim MyArray(5) '分配 5 个元素。
6 | For I = 1 To 5 '循环 5 次。
7 | MyArray(I) = I '初始化数组。
8 | Next I
9 |
10 | '下一条语句重定义该数组的大小,并清除其中的元素。
11 |
12 | Redim MyArray(10) '大小重定为 10 个元素。
13 | For I = 1 To 10 '循环 10 次。
14 | MyArray(I) = I '初始化数组。
15 | Next I
16 |
17 | '下面的语句重定义该数组的大小,但没有清除其中的元素。
18 |
19 | Redim Preserve MyArray(15) '大小重定为 15 个元素。
20 | End Sub
--------------------------------------------------------------------------------
/vba/base-type.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "BaseType"
2 |
3 | Sub Main()
4 | Debug.Print 1 / 2
5 | End Sub
6 |
--------------------------------------------------------------------------------
/vba/call.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "Call"
2 |
3 | function abc()
4 | a.b o!k(1,2)
5 |
6 | 'a (1)
7 |
8 | 'a(2,3)
9 |
10 | me.a 2,2
11 |
12 | end function
--------------------------------------------------------------------------------
/vba/call_test.bas:
--------------------------------------------------------------------------------
1 | sub main()
2 |
3 | Debug.Print col!no2
4 |
5 | a 1,2,3
6 | a.b 1,2
7 | a.b!c.d 1,2
8 |
9 | call a(1,2,3)
10 |
11 | a = f(1,3)
12 | a = a.b
13 | a = a.b(1)
14 | a = a!b.t(2)
15 |
16 | abc = fun(1,2)(2).c(22)(33).d!a.t
17 |
18 | call a
19 | call a(1,2,3)()
20 | a 2,3,4
21 | a
22 |
23 | end sub
--------------------------------------------------------------------------------
/vba/class-test.bas:
--------------------------------------------------------------------------------
1 | sub Main()
2 | Debug.Print "hello"
3 |
4 | Dim c As New Class1
5 | Dim r As Integer
6 | r = c.add(1,2)
7 | Debug.Print r
8 |
9 | dim c2 as new class1
10 | c2.a = 12
11 |
12 | c.a = 5
13 | r = c.addB(2)
14 | Debug.Print r
15 |
16 | Debug.Print c2.addB(3) ' c2 and c are diffrent object
17 |
18 | Dim t As New Class1
19 | t.a = 2
20 | t.b = 8
21 | Debug.Print t.AddAB
22 | end sub
--------------------------------------------------------------------------------
/vba/const-enum.bas:
--------------------------------------------------------------------------------
1 | Enum State
2 | Ready = 2
3 | Complete = 3
4 | End Enum
5 |
6 | Const a As Integer = 3
7 | Const b As Integer = a * 2
8 | Const cc As Integer = Ready * 2
9 | Const ccc As Integer = State.Complete * 2
10 | Sub Main()
11 | Dim st As State
12 | 'st = Ready
13 | st = State.Complete
14 |
15 | 'Const a As Integer = 2
16 |
17 | 'Dim arr(a To b) As Integer
18 |
19 | 'Debug.Print cc
20 | 'Debug.Print ccc
21 |
22 |
23 | End Sub
24 |
--------------------------------------------------------------------------------
/vba/decls.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "decls"
2 |
3 | dim 1x as integer
4 |
5 | dim x1 as integer
6 |
7 | dim arr1(-1 to "2") as integer
8 |
9 | dim arr2(2.0 to 12 + 3 + 5) as integer
10 |
11 | function f1(a as integer, b as integer) as integer
12 |
13 | end function
14 |
15 | function f2(a as integer, b as integer) as integer()
16 |
17 | end function
18 |
19 | funtcion f3()
20 |
21 | end function
22 |
23 | function f4(a as integer, b as integer) as integer()
24 |
25 | end function
26 |
--------------------------------------------------------------------------------
/vba/do-while.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "DoWhile"
2 |
3 | Sub Main()
4 | Dim i As Integer
5 | Do While i < 5
6 | Debug.Print i
7 | i = i + 1
8 | Loop
9 | Debug.Print "at last " & i
10 |
11 | i = 0
12 | Do Until i > 5
13 | Debug.Print i
14 | i = i + 1
15 | Loop
16 | Debug.Print "at last " & i
17 |
18 | i = 0
19 | Do
20 | Debug.Print i
21 | i = i + 1
22 | Loop While i < 5
23 | Debug.Print "at last " & i
24 |
25 | i = 0
26 | Do
27 | Debug.Print i
28 | i = i + 1
29 | Loop Until i > 5
30 | Debug.Print "at last " & i
31 |
32 |
33 | i = 0
34 | While i < 5
35 | Debug.Print i
36 | i = i + 1
37 | WEnd
38 | Debug.Print "at last " & i
39 |
40 | msdn
41 | End Sub
42 |
43 | Sub msdn()
44 | Dim Check, Counter
45 | Check = True: Counter = 0 ' 设置变量初始值。
46 | Do ' 外层循环。
47 | Do While Counter < 20 ' 内层循环。
48 | Counter = Counter + 1 ' 计数器加一。
49 | If Counter = 10 Then ' 如果条件成立。
50 | Check = False ' 将标志值设成 False。
51 | Exit Do ' 退出内层循环。
52 | End If
53 | Loop
54 | Loop Until Check = False ' 退出外层循环。
55 |
56 | Debug.Print Check
57 | End Sub
--------------------------------------------------------------------------------
/vba/every_call/MOp.cls:
--------------------------------------------------------------------------------
1 | VERSION 1.0 CLASS
2 | BEGIN
3 | MultiUse = -1 'True
4 | END
5 | Attribute VB_Name = "MOp"
6 | Attribute VB_GlobalNameSpace = False
7 | Attribute VB_Creatable = False
8 | Attribute VB_PredeclaredId = False
9 | Attribute VB_Exposed = False
10 |
11 | Public Function add(a As Integer, b As Integer) As Integer
12 | add = a + b
13 |
14 | Debug.Print a & " + " & b & "=" & add
15 | End Function
16 |
--------------------------------------------------------------------------------
/vba/every_call/test.bas:
--------------------------------------------------------------------------------
1 | Sub Main()
2 | Dim op As MOp
3 | Set op = New MOp
4 |
5 | op.add 1,2
6 |
7 | Call op.add(1,2)
8 | End Sub
--------------------------------------------------------------------------------
/vba/for-next.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "ForNext"
2 |
3 | Sub Main()
4 | Debug.Print "hello"
5 |
6 | Dim i As Integer
7 | For i = 1 To 10
8 | Debug.Print i
9 | Next
10 |
11 | Dim arr(1 To 10) As Integer
12 | For i = 1 To 10
13 | arr(i) = i
14 | Next
15 |
16 | Debug.Print "Sum:" & SumOf(arr)
17 |
18 | For i = 1 To 10
19 | Debug.Print arr(i)
20 | If arr(i) > 5 Then Exit For
21 | Next
22 | End Sub
23 |
24 | Function SumOf(arr() As Integer) As Integer
25 | Dim i As Integer
26 | For i = 1 To 10
27 | SumOf = SumOf + arr(i)
28 | Next
29 | End Function
30 |
--------------------------------------------------------------------------------
/vba/func-call.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "FuncCall"
2 |
3 | Sub Main()
4 | Dim r As Double
5 | r = CalculateSquareRoot(2)
6 | Debug.Print r
7 |
8 | Dim n As Double
9 | n = aNumber
10 | Debug.Print n
11 |
12 | Stop
13 | r = SqrRoot(1.0, n)
14 | Debug.Print r
15 | End Sub
16 |
17 | Function aNumber() As Double
18 | aNumber = 2.0
19 | End Function
20 |
21 | Function add(a As Integer, b as Integer) As Double
22 | add = a + b
23 | End Function
24 |
25 | '下面的用户自定义函数返回
26 | '它的参数的平方根。
27 | Function CalculateSquareRoot(NumberArg As Double) As Double
28 | If NumberArg < 0 Then '评估参数。
29 | Exit Function '退出调用过程。
30 | Else
31 | CalculateSquareRoot = Sqr(NumberArg) '返回平方根。
32 | End If
33 | End Function
34 |
35 | Function IsGoodEnough(guess As Double, x As Double) As Boolean
36 | IsGoodEnough = Abs(x - guess * guess) <= 0.00001
37 | End Function
38 |
39 | Function NewGuess(guess As Double, x As Double) As Double
40 | NewGuess = (guess + x / guess) / 2.0
41 | End Function
42 |
43 | Function SqrRoot(guess As Double, x As Double) As Double
44 | 'Debug.Print "guess " & guess
45 | If IsGoodEnough(guess, x) Then
46 | SqrRoot = guess
47 | Else
48 | SqrRoot = SqrRoot(NewGuess(guess, x), x)
49 | End If
50 | End Function
51 |
52 |
--------------------------------------------------------------------------------
/vba/gosub.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "gosub"
2 |
3 | Sub Main()
4 | Debug.Print 1
5 | GoSub a
6 | Debug.Print 2
7 | Exit Sub
8 | a:
9 | Debug.Print 3
10 | Debug.Print 4
11 | GoSub b
12 | Debug.Print "4.1"
13 | Return
14 | Exit Sub
15 | b:
16 | Debug.Print 5
17 | Return
18 | End Sub
19 |
--------------------------------------------------------------------------------
/vba/goto.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "goto"
2 |
3 | Sub Main()
4 | Debug.Print 1
5 | GoTo a
6 | Debug.Print 2
7 | Exit Sub
8 | a:
9 | Debug.Print 3
10 | Debug.Print 4
11 | End Sub
12 |
--------------------------------------------------------------------------------
/vba/if-then-else.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "IfThenElse"
2 |
3 | Sub Main()
4 | Dim Number As Integer, Digits As Integer, MyString As String
5 | Number = 52 ' 设置变量初始值。
6 | If Number < 10 Then
7 | Digits = 1
8 | ElseIf Number < 100 Then
9 | ' 若判断结果为 True,则完成下一行语句。
10 | Digits = 2
11 | Else
12 | Digits = 3
13 | End If
14 |
15 | Debug.Print Digits
16 |
17 | If Number > 50 Then
18 | Debug.Print "large than 50"
19 | End If
20 |
21 | If Number < 50 Then
22 | Debug.Print "little than 50"
23 | Else
24 | Debug.Print "ge 50"
25 | End If
26 |
27 | If Digits = 1 Then MyString = "One" Else MyString = "More than one"
28 | Debug.Print MyString
29 |
30 | End Sub
31 |
32 |
33 |
--------------------------------------------------------------------------------
/vba/select-case.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "SelectCase"
2 |
3 | Sub Main()
4 | Dim Number
5 | Number = 9 ' 设置变量初值。
6 | Select Case Number ' 判断 Number 的值。
7 | Case Is <= 5 ' Number 的值在 1 到 5 之间,包含1 和 5 。
8 | Debug.Print "Between 1 and 5"
9 | ' 下一个 Case 子句是本示例中唯一判断值为 True 的子句。
10 | Case 6, 7, 8 ' Number 的值在 6 到 8 之间。
11 | Debug.Print "Between 6 and 8"
12 | Case 9 To 10 ' Number 的值为 9 或 10。
13 | Debug.Print "Greater than 8"
14 | Case Else ' 其他数值。
15 | Debug.Print "Not between 1 and 10"
16 | End Select
17 | Debug.Print "OVER"
18 | End Sub
19 |
20 |
21 |
--------------------------------------------------------------------------------
/vba/test.bas:
--------------------------------------------------------------------------------
1 | Attribute VB_Name = "test"
2 | option explicit
3 | option base 2
4 | option compare text
5 |
6 | Dim a as integer
7 | Dim b as String
8 |
9 | dim 汉字 as variant
10 | sub f
11 | f = (guess + x / guess) / 2
12 | end sub
13 |
14 | Function NewGuess(guess As Double, x As Double) As Double
15 | Debug.Print NewGuess
16 | End Function
17 |
18 | function add(a as integer, b as integer) as integer
19 | dim c as integer
20 | c = a + b
21 | add = c
22 | end function
23 |
24 |
--------------------------------------------------------------------------------
/vba/udt.bas:
--------------------------------------------------------------------------------
1 | Enum State
2 | Ready = 2
3 | Complete = 3
4 | End Enum
5 |
6 | Type EmployeeRecord '创建用户自定义的类型。
7 | ID As Integer '定义元素的数据类型。
8 | Name As String * Ready
9 | Address As String '* 30
10 | Phone As Long
11 | 'HireDate As Date
12 | End Type
13 |
14 | Sub Main()
15 | Dim MyRecord As EmployeeRecord '声明变量。
16 |
17 | '对 EmployeeRecord 变量的赋值必须在过程内进行。
18 | MyRecord.ID = 12003 '给一个元素赋值。
19 |
20 | Debug.Print "MyRecrod " & MyRecord.ID
21 |
22 | Dim b As EmployeeRecord
23 | b = MyRecord
24 |
25 | Debug.Print "Clonner " & b.ID
26 |
27 | b.ID = 11111
28 |
29 | Debug.Print "Clonner Become " & b.ID
30 |
31 | Debug.Print "MyRecrod Still " & MyRecord.ID
32 |
33 | End Sub
34 |
35 |
36 |
--------------------------------------------------------------------------------